• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef ANDROID_HARDWARE_VIBRATOR_TEST_MOCKS_H
17 #define ANDROID_HARDWARE_VIBRATOR_TEST_MOCKS_H
18 
19 #include <aidl/android/hardware/vibrator/BnVibratorCallback.h>
20 
21 #include "Vibrator.h"
22 
23 class MockGPIO : public ::aidl::android::hardware::vibrator::Vibrator::HwGPIO {
24   public:
25     MOCK_METHOD0(destructor, void());
26     MOCK_METHOD0(getGPIO, bool());
27     MOCK_METHOD0(initGPIO, bool());
28     MOCK_METHOD1(setGPIOOutput, bool(bool value));
29     MOCK_METHOD1(debug, void(int fd));
30 
~MockGPIO()31     ~MockGPIO() override { destructor(); };
32 };
33 
34 class MockApi : public ::aidl::android::hardware::vibrator::Vibrator::HwApi {
35   public:
36     MOCK_METHOD0(destructor, void());
37     MOCK_METHOD1(setF0, bool(std::string value));
38     MOCK_METHOD1(setF0Offset, bool(uint32_t value));
39     MOCK_METHOD1(setRedc, bool(std::string value));
40     MOCK_METHOD1(setQ, bool(std::string value));
41     MOCK_METHOD1(getEffectCount, bool(uint32_t *value));
42     MOCK_METHOD2(pollVibeState, bool(uint32_t value, int32_t timeoutMs));
43     MOCK_METHOD0(hasOwtFreeSpace, bool());
44     MOCK_METHOD1(getOwtFreeSpace, bool(uint32_t *value));
45     MOCK_METHOD1(setF0CompEnable, bool(bool value));
46     MOCK_METHOD1(setRedcCompEnable, bool(bool value));
47     MOCK_METHOD1(setMinOnOffInterval, bool(uint32_t value));
48     MOCK_METHOD2(setFFGain, bool(int fd, uint16_t value));
49     MOCK_METHOD3(setFFEffect, bool(int fd, struct ff_effect *effect, uint16_t timeoutMs));
50     MOCK_METHOD3(setFFPlay, bool(int fd, int8_t index, bool value));
51     MOCK_METHOD2(getHapticAlsaDevice, bool(int *card, int *device));
52     MOCK_METHOD4(setHapticPcmAmp, bool(struct pcm **haptic_pcm, bool enable, int card, int device));
53     MOCK_METHOD6(uploadOwtEffect,
54                  bool(int fd, uint8_t *owtData, uint32_t numBytes, struct ff_effect *effect,
55                       uint32_t *outEffectIndex, int *status));
56     MOCK_METHOD3(eraseOwtEffect, bool(int fd, int8_t effectIndex, std::vector<ff_effect> *effect));
57     MOCK_METHOD1(debug, void(int fd));
58 
~MockApi()59     ~MockApi() override { destructor(); };
60 };
61 
62 class MockCal : public ::aidl::android::hardware::vibrator::Vibrator::HwCal {
63   public:
64     MOCK_METHOD0(destructor, void());
65     MOCK_METHOD1(getVersion, bool(uint32_t *value));
66     MOCK_METHOD1(getF0, bool(std::string &value));
67     MOCK_METHOD1(getF0SyncOffset, bool(uint32_t *value));
68     MOCK_METHOD1(getRedc, bool(std::string &value));
69     MOCK_METHOD1(getQ, bool(std::string &value));
70     MOCK_METHOD1(getLongFrequencyShift, bool(int32_t *value));
71     MOCK_METHOD1(getTickVolLevels, bool(std::array<uint32_t, 2> *value));
72     MOCK_METHOD1(getClickVolLevels, bool(std::array<uint32_t, 2> *value));
73     MOCK_METHOD1(getLongVolLevels, bool(std::array<uint32_t, 2> *value));
74     MOCK_METHOD0(isChirpEnabled, bool());
75     MOCK_METHOD1(getSupportedPrimitives, bool(uint32_t *value));
76     MOCK_METHOD0(isF0CompEnabled, bool());
77     MOCK_METHOD0(isRedcCompEnabled, bool());
78     MOCK_METHOD1(debug, void(int fd));
79 
~MockCal()80     ~MockCal() override { destructor(); };
81     // b/132668253: Workaround gMock Compilation Issue
getF0(std::string * value)82     bool getF0(std::string *value) { return getF0(*value); }
getRedc(std::string * value)83     bool getRedc(std::string *value) { return getRedc(*value); }
getQ(std::string * value)84     bool getQ(std::string *value) { return getQ(*value); }
85 };
86 
87 class MockVibratorCallback : public aidl::android::hardware::vibrator::BnVibratorCallback {
88   public:
89     MOCK_METHOD(ndk::ScopedAStatus, onComplete, ());
90 };
91 
92 #endif  // ANDROID_HARDWARE_VIBRATOR_TEST_MOCKS_H
93