Home | History | Annotate | Download | only in test
      1 // Copyright 2016 The Android Open Source Project
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //      http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 //
     15 
     16 // Mock of AudioDeviceHandler.
     17 
     18 #ifndef BRILLO_AUDIO_AUDIOSERVICE_TEST_AUDIO_DEVICE_HANDLER_MOCK_H_
     19 #define BRILLO_AUDIO_AUDIOSERVICE_TEST_AUDIO_DEVICE_HANDLER_MOCK_H_
     20 
     21 #include <base/files/file_path.h>
     22 #include <gmock/gmock.h>
     23 #include <gtest/gtest_prod.h>
     24 #include <system/audio.h>
     25 #include <system/audio_policy.h>
     26 
     27 #include "audio_device_handler.h"
     28 
     29 namespace brillo {
     30 
     31 class AudioDeviceHandlerMock : public AudioDeviceHandler {
     32  public:
     33   AudioDeviceHandlerMock() = default;
     34   ~AudioDeviceHandlerMock() {}
     35 
     36   // Reset all local data.
     37   void Reset() {
     38     connected_input_devices_.clear();
     39     connected_output_devices_.clear();
     40     headphone_ = false;
     41     microphone_ = false;
     42   }
     43 
     44  private:
     45   friend class AudioDeviceHandlerTest;
     46   FRIEND_TEST(AudioDeviceHandlerTest,
     47               DisconnectAllSupportedDevicesCallsDisconnect);
     48   FRIEND_TEST(AudioDeviceHandlerTest, InitCallsDisconnectAllSupportedDevices);
     49   FRIEND_TEST(AudioDeviceHandlerTest, InitialAudioStateMic);
     50   FRIEND_TEST(AudioDeviceHandlerTest, InitialAudioStateHeadphone);
     51   FRIEND_TEST(AudioDeviceHandlerTest, InitialAudioStateHeadset);
     52   FRIEND_TEST(AudioDeviceHandlerTest, InitialAudioStateNone);
     53   FRIEND_TEST(AudioDeviceHandlerTest, InitialAudioStateInvalid);
     54   FRIEND_TEST(AudioDeviceHandlerTest, InitCallsDisconnect);
     55   FRIEND_TEST(AudioDeviceHandlerTest, ProcessEventEmpty);
     56   FRIEND_TEST(AudioDeviceHandlerTest, ProcessEventMicrophonePresent);
     57   FRIEND_TEST(AudioDeviceHandlerTest, ProcessEventHeadphonePresent);
     58   FRIEND_TEST(AudioDeviceHandlerTest, ProcessEventMicrophoneNotPresent);
     59   FRIEND_TEST(AudioDeviceHandlerTest, ProcessEventHeadphoneNotPresent);
     60   FRIEND_TEST(AudioDeviceHandlerTest, ProcessEventInvalid);
     61   FRIEND_TEST(AudioDeviceHandlerTest, UpdateAudioSystemNone);
     62   FRIEND_TEST(AudioDeviceHandlerTest, UpdateAudioSystemConnectMic);
     63   FRIEND_TEST(AudioDeviceHandlerTest, UpdateAudioSystemConnectHeadphone);
     64   FRIEND_TEST(AudioDeviceHandlerTest, UpdateAudioSystemConnectHeadset);
     65   FRIEND_TEST(AudioDeviceHandlerTest, UpdateAudioSystemDisconnectMic);
     66   FRIEND_TEST(AudioDeviceHandlerTest, UpdateAudioSystemDisconnectHeadphone);
     67   FRIEND_TEST(AudioDeviceHandlerTest, UpdateAudioSystemDisconnectHeadset);
     68   FRIEND_TEST(AudioDeviceHandlerTest, ConnectAudioDeviceInput);
     69   FRIEND_TEST(AudioDeviceHandlerTest, ConnectAudioDeviceOutput);
     70   FRIEND_TEST(AudioDeviceHandlerTest, DisconnectAudioDeviceInput);
     71   FRIEND_TEST(AudioDeviceHandlerTest, DisconnectAudioDeviceOutput);
     72 
     73   MOCK_METHOD2(NotifyAudioPolicyService,
     74                void(audio_devices_t device, audio_policy_dev_state_t state));
     75   MOCK_METHOD1(TriggerCallback, void(DeviceConnectionState));
     76 };
     77 
     78 }  // namespace brillo
     79 
     80 #endif  // BRILLO_AUDIO_AUDIOSERVICE_TEST_AUDIO_DEVICE_HANDLER_MOCK_H_
     81