1 /* 2 * Copyright (C) 2019 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 MockApi : public ::aidl::android::hardware::vibrator::Vibrator::HwApi { 24 public: 25 MOCK_METHOD0(destructor, void()); 26 MOCK_METHOD1(setF0, bool(uint32_t value)); 27 MOCK_METHOD1(setF0Offset, bool(uint32_t value)); 28 MOCK_METHOD1(setRedc, bool(uint32_t value)); 29 MOCK_METHOD1(setQ, bool(uint32_t value)); 30 MOCK_METHOD1(setActivate, bool(bool value)); 31 MOCK_METHOD1(setDuration, bool(uint32_t value)); 32 MOCK_METHOD1(getEffectCount, bool(uint32_t *value)); 33 MOCK_METHOD1(getEffectDuration, bool(uint32_t *value)); 34 MOCK_METHOD1(setEffectIndex, bool(uint32_t value)); 35 MOCK_METHOD1(setEffectQueue, bool(std::string value)); 36 MOCK_METHOD0(hasEffectScale, bool()); 37 MOCK_METHOD1(setEffectScale, bool(uint32_t value)); 38 MOCK_METHOD1(setGlobalScale, bool(uint32_t value)); 39 MOCK_METHOD1(setState, bool(bool value)); 40 MOCK_METHOD0(hasAspEnable, bool()); 41 MOCK_METHOD1(getAspEnable, bool(bool *value)); 42 MOCK_METHOD1(setAspEnable, bool(bool value)); 43 MOCK_METHOD1(setGpioFallIndex, bool(uint32_t value)); 44 MOCK_METHOD1(setGpioFallScale, bool(uint32_t value)); 45 MOCK_METHOD1(setGpioRiseIndex, bool(uint32_t value)); 46 MOCK_METHOD1(setGpioRiseScale, bool(uint32_t value)); 47 MOCK_METHOD2(pollVibeState, bool(uint32_t value, int32_t timeoutMs)); 48 MOCK_METHOD1(setClabEnable, bool(bool value)); 49 MOCK_METHOD1(getAvailablePwleSegments, bool(uint32_t *value)); 50 MOCK_METHOD0(hasPwle, bool()); 51 MOCK_METHOD1(setPwle, bool(std::string value)); 52 MOCK_METHOD1(setPwleRampDown, bool(uint32_t value)); 53 MOCK_METHOD1(debug, void(int fd)); 54 ~MockApi()55 ~MockApi() override { destructor(); }; 56 }; 57 58 class MockCal : public ::aidl::android::hardware::vibrator::Vibrator::HwCal { 59 public: 60 MOCK_METHOD0(destructor, void()); 61 MOCK_METHOD1(getVersion, bool(uint32_t *value)); 62 MOCK_METHOD1(getF0, bool(uint32_t *value)); 63 MOCK_METHOD1(getRedc, bool(uint32_t *value)); 64 MOCK_METHOD1(getQ, bool(uint32_t *value)); 65 MOCK_METHOD1(getLongFrequencyShift, bool(int32_t *value)); 66 MOCK_METHOD1(getVolLevels, bool(std::array<uint32_t, 6> *value)); 67 MOCK_METHOD1(getTickVolLevels, bool(std::array<uint32_t, 2> *value)); 68 MOCK_METHOD1(getClickVolLevels, bool(std::array<uint32_t, 2> *value)); 69 MOCK_METHOD1(getLongVolLevels, bool(std::array<uint32_t, 2> *value)); 70 MOCK_METHOD0(isChirpEnabled, bool()); 71 MOCK_METHOD1(getDeviceMass, bool(float *value)); 72 MOCK_METHOD1(getLocCoeff, bool(float *value)); 73 MOCK_METHOD1(debug, void(int fd)); 74 ~MockCal()75 ~MockCal() override { destructor(); }; 76 }; 77 78 class MockStats : public ::aidl::android::hardware::vibrator::Vibrator::StatsApi { 79 public: 80 MOCK_METHOD0(destructor, void()); 81 MOCK_METHOD1(logPrimitive, bool(uint16_t effectIndex)); 82 MOCK_METHOD2(logWaveform, bool(uint16_t effectIndex, int32_t duration)); 83 MOCK_METHOD1(logError, bool(uint16_t errorIndex)); 84 MOCK_METHOD1(logLatencyStart, bool(uint16_t latencyIndex)); 85 MOCK_METHOD0(logLatencyEnd, bool()); 86 MOCK_METHOD1(debug, void(int fd)); 87 ~MockStats()88 ~MockStats() override { destructor(); }; 89 }; 90 91 class MockVibratorCallback : public aidl::android::hardware::vibrator::BnVibratorCallback { 92 public: 93 MOCK_METHOD(ndk::ScopedAStatus, onComplete, ()); 94 }; 95 96 #endif // ANDROID_HARDWARE_VIBRATOR_TEST_MOCKS_H 97