device_google_lynx/vibrator/cs40l26/tests/mocks.h
Chris Paulo 0db068b63c device/vibrator: Add contextual haptics feature
Add capability for vibrator HAL to detect whether the device is face-up
and adjust/scale haptic alerts to avoid loud and startling buzzing when
there is no case on the device. Added global compile-time disable that
can be set in the environment.

Bug: 198239103
Test: Verified tests and functionality
Change-Id: I6b2355acb7fa5e0323b8eca6327bb19ac42a2c56
Signed-off-by: Chris Paulo <chrispaulo@google.com>
2022-11-16 20:19:54 +00:00

85 lines
3.8 KiB
C++

/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_HARDWARE_VIBRATOR_TEST_MOCKS_H
#define ANDROID_HARDWARE_VIBRATOR_TEST_MOCKS_H
#include <aidl/android/hardware/vibrator/BnVibratorCallback.h>
#include "Vibrator.h"
class MockApi : public ::aidl::android::hardware::vibrator::Vibrator::HwApi {
public:
MOCK_METHOD0(destructor, void());
MOCK_METHOD1(setF0, bool(std::string value));
MOCK_METHOD1(setF0Offset, bool(uint32_t value));
MOCK_METHOD1(setRedc, bool(std::string value));
MOCK_METHOD1(setQ, bool(std::string value));
MOCK_METHOD1(getEffectCount, bool(uint32_t *value));
MOCK_METHOD2(pollVibeState, bool(uint32_t value, int32_t timeoutMs));
MOCK_METHOD0(hasOwtFreeSpace, bool());
MOCK_METHOD1(getOwtFreeSpace, bool(uint32_t *value));
MOCK_METHOD1(setF0CompEnable, bool(bool value));
MOCK_METHOD1(setRedcCompEnable, bool(bool value));
MOCK_METHOD1(setMinOnOffInterval, bool(uint32_t value));
MOCK_METHOD0(getContextScale, uint32_t());
MOCK_METHOD0(getContextEnable, bool());
MOCK_METHOD0(getContextSettlingTime, uint32_t());
MOCK_METHOD0(getContextCooldownTime, uint32_t());
MOCK_METHOD0(getContextFadeEnable, bool());
MOCK_METHOD2(setFFGain, bool(int fd, uint16_t value));
MOCK_METHOD3(setFFEffect, bool(int fd, struct ff_effect *effect, uint16_t timeoutMs));
MOCK_METHOD3(setFFPlay, bool(int fd, int8_t index, bool value));
MOCK_METHOD2(getHapticAlsaDevice, bool(int *card, int *device));
MOCK_METHOD4(setHapticPcmAmp, bool(struct pcm **haptic_pcm, bool enable, int card, int device));
MOCK_METHOD6(uploadOwtEffect,
bool(int fd, uint8_t *owtData, uint32_t numBytes, struct ff_effect *effect,
uint32_t *outEffectIndex, int *status));
MOCK_METHOD3(eraseOwtEffect, bool(int fd, int8_t effectIndex, std::vector<ff_effect> *effect));
MOCK_METHOD1(debug, void(int fd));
~MockApi() override { destructor(); };
};
class MockCal : public ::aidl::android::hardware::vibrator::Vibrator::HwCal {
public:
MOCK_METHOD0(destructor, void());
MOCK_METHOD1(getVersion, bool(uint32_t *value));
MOCK_METHOD1(getF0, bool(std::string &value));
MOCK_METHOD1(getRedc, bool(std::string &value));
MOCK_METHOD1(getQ, bool(std::string &value));
MOCK_METHOD1(getLongFrequencyShift, bool(int32_t *value));
MOCK_METHOD1(getTickVolLevels, bool(std::array<uint32_t, 2> *value));
MOCK_METHOD1(getClickVolLevels, bool(std::array<uint32_t, 2> *value));
MOCK_METHOD1(getLongVolLevels, bool(std::array<uint32_t, 2> *value));
MOCK_METHOD0(isChirpEnabled, bool());
MOCK_METHOD1(getSupportedPrimitives, bool(uint32_t *value));
MOCK_METHOD0(isF0CompEnabled, bool());
MOCK_METHOD0(isRedcCompEnabled, bool());
MOCK_METHOD1(debug, void(int fd));
~MockCal() override { destructor(); };
// b/132668253: Workaround gMock Compilation Issue
bool getF0(std::string *value) { return getF0(*value); }
bool getRedc(std::string *value) { return getRedc(*value); }
bool getQ(std::string *value) { return getQ(*value); }
};
class MockVibratorCallback : public aidl::android::hardware::vibrator::BnVibratorCallback {
public:
MOCK_METHOD(ndk::ScopedAStatus, onComplete, ());
};
#endif // ANDROID_HARDWARE_VIBRATOR_TEST_MOCKS_H