• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
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 #ifndef BLUETOOTH_HFP_MOCK_INTERFACE_H
17 #define BLUETOOTH_HFP_MOCK_INTERFACE_H
18 
19 #include <memory>
20 #include <gtest/gtest.h>
21 #include <gmock/gmock.h>
22 #include "bluetooth_hfp_interface.h"
23 
24 namespace OHOS {
25 namespace Bluetooth {
26 class BluetoothHfpMockInterface : public BluetoothHfpInterface {
27 public:
BluetoothHfpMockInterface()28     BluetoothHfpMockInterface() {}
29     ~BluetoothHfpMockInterface() = default;
30 
31     MOCK_METHOD2(GetDeviceState, int32_t(const BluetoothRemoteDevice &, int32_t &));
32     MOCK_METHOD1(GetScoState, AudioScoState(const BluetoothRemoteDevice &));
33     MOCK_METHOD1(GetCurrentCategory, int32_t(ScoCategory &));
34     MOCK_METHOD1(ConnectSco, int32_t(uint8_t));
35     MOCK_METHOD1(DisconnectSco, int32_t(uint8_t));
36     MOCK_METHOD1(OpenVoiceRecognition, int32_t(const BluetoothRemoteDevice &));
37     MOCK_METHOD1(CloseVoiceRecognition, int32_t(const BluetoothRemoteDevice &));
38     MOCK_METHOD1(SetActiveDevice, int32_t(const BluetoothRemoteDevice &));
39 
40     MOCK_METHOD1(RegisterObserver, void(std::shared_ptr<HandsFreeAudioGatewayObserver>));
41     MOCK_METHOD1(DeregisterObserver, void(std::shared_ptr<HandsFreeAudioGatewayObserver>));
42     MOCK_METHOD1(GetDevicesByStates, std::vector<BluetoothRemoteDevice>(std::vector<int>));
43     MOCK_METHOD1(GetVirtualDeviceList, void(std::vector<std::string> &));
44     MOCK_METHOD0(GetActiveDevice, BluetoothRemoteDevice());
45     MOCK_METHOD1(Connect, int32_t(const BluetoothRemoteDevice &));
46     MOCK_METHOD1(IsInbandRingingEnabled, int32_t(bool &));
47 
GetLastError()48     int32_t GetLastError() override
49     {
50         return 0;
51     }
52 
GetLastOpration()53     std::string GetLastOpration() override
54     {
55         return "";
56     }
57 
58     static std::shared_ptr<BluetoothHfpMockInterface> mockInterface_;
59 };
60 
61 std::shared_ptr<BluetoothHfpMockInterface> BluetoothHfpMockInterface::mockInterface_ = nullptr;
62 
GetInstance()63 BluetoothHfpInterface &BluetoothHfpInterface::GetInstance()
64 {
65     if (BluetoothHfpMockInterface::mockInterface_ == nullptr) {
66         static BluetoothHfpMockInterface defaultInterface;
67         return defaultInterface;
68     }
69     return *(BluetoothHfpMockInterface::mockInterface_.get());
70 }
71 }
72 }
73 #endif