Siarhei Vishniakou | 979f2d8 | 2023-05-16 14:26:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2023 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 | |
| 17 | #pragma once |
| 18 | |
| 19 | #include <android-base/logging.h> |
| 20 | #include <gmock/gmock.h> |
| 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | class MockInputReaderContext : public InputReaderContext { |
| 25 | public: |
| 26 | MOCK_METHOD(void, updateGlobalMetaState, (), (override)); |
| 27 | int32_t getGlobalMetaState() override { return 0; }; |
| 28 | |
| 29 | MOCK_METHOD(void, disableVirtualKeysUntil, (nsecs_t time), (override)); |
| 30 | MOCK_METHOD(bool, shouldDropVirtualKey, (nsecs_t now, int32_t keyCode, int32_t scanCode), |
| 31 | (override)); |
| 32 | |
| 33 | MOCK_METHOD(void, fadePointer, (), (override)); |
| 34 | MOCK_METHOD(std::shared_ptr<PointerControllerInterface>, getPointerController, |
| 35 | (int32_t deviceId), (override)); |
| 36 | |
| 37 | MOCK_METHOD(void, requestTimeoutAtTime, (nsecs_t when), (override)); |
| 38 | MOCK_METHOD(int32_t, bumpGeneration, (), (override)); |
| 39 | |
| 40 | MOCK_METHOD(void, getExternalStylusDevices, (std::vector<InputDeviceInfo> & outDevices), |
| 41 | (override)); |
| 42 | MOCK_METHOD(std::list<NotifyArgs>, dispatchExternalStylusState, (const StylusState& outState), |
| 43 | (override)); |
| 44 | |
| 45 | MOCK_METHOD(InputReaderPolicyInterface*, getPolicy, (), (override)); |
| 46 | MOCK_METHOD(EventHubInterface*, getEventHub, (), (override)); |
| 47 | |
| 48 | int32_t getNextId() override { return 1; }; |
| 49 | |
| 50 | MOCK_METHOD(void, updateLedMetaState, (int32_t metaState), (override)); |
| 51 | MOCK_METHOD(int32_t, getLedMetaState, (), (override)); |
Arpit Singh | a5ea7c1 | 2023-07-05 15:39:25 +0000 | [diff] [blame^] | 52 | |
| 53 | MOCK_METHOD(void, setPreventingTouchpadTaps, (bool prevent), (override)); |
| 54 | MOCK_METHOD(bool, isPreventingTouchpadTaps, (), (override)); |
Siarhei Vishniakou | 979f2d8 | 2023-05-16 14:26:24 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | class MockEventHubInterface : public EventHubInterface { |
| 58 | public: |
| 59 | MOCK_METHOD(ftl::Flags<InputDeviceClass>, getDeviceClasses, (int32_t deviceId), (const)); |
| 60 | MOCK_METHOD(InputDeviceIdentifier, getDeviceIdentifier, (int32_t deviceId), (const)); |
| 61 | MOCK_METHOD(int32_t, getDeviceControllerNumber, (int32_t deviceId), (const)); |
| 62 | MOCK_METHOD(std::optional<PropertyMap>, getConfiguration, (int32_t deviceId), (const)); |
| 63 | MOCK_METHOD(status_t, getAbsoluteAxisInfo, |
| 64 | (int32_t deviceId, int axis, RawAbsoluteAxisInfo* outAxisInfo), (const)); |
| 65 | MOCK_METHOD(bool, hasRelativeAxis, (int32_t deviceId, int axis), (const)); |
| 66 | MOCK_METHOD(bool, hasInputProperty, (int32_t deviceId, int property), (const)); |
| 67 | MOCK_METHOD(bool, hasMscEvent, (int32_t deviceId, int mscEvent), (const)); |
| 68 | MOCK_METHOD(void, addKeyRemapping, (int32_t deviceId, int fromKeyCode, int toKeyCode), (const)); |
| 69 | MOCK_METHOD(status_t, mapKey, |
| 70 | (int32_t deviceId, int scanCode, int usageCode, int32_t metaState, |
| 71 | int32_t* outKeycode, int32_t* outMetaState, uint32_t* outFlags), |
| 72 | (const)); |
| 73 | MOCK_METHOD(status_t, mapAxis, (int32_t deviceId, int scanCode, AxisInfo* outAxisInfo), |
| 74 | (const)); |
| 75 | MOCK_METHOD(void, setExcludedDevices, (const std::vector<std::string>& devices)); |
| 76 | MOCK_METHOD(std::vector<RawEvent>, getEvents, (int timeoutMillis)); |
| 77 | MOCK_METHOD(std::vector<TouchVideoFrame>, getVideoFrames, (int32_t deviceId)); |
| 78 | MOCK_METHOD((base::Result<std::pair<InputDeviceSensorType, int32_t>>), mapSensor, |
| 79 | (int32_t deviceId, int32_t absCode), (const, override)); |
| 80 | MOCK_METHOD(std::vector<int32_t>, getRawBatteryIds, (int32_t deviceId), (const, override)); |
| 81 | MOCK_METHOD(std::optional<RawBatteryInfo>, getRawBatteryInfo, |
| 82 | (int32_t deviceId, int32_t BatteryId), (const, override)); |
| 83 | MOCK_METHOD(std::vector<int32_t>, getRawLightIds, (int32_t deviceId), (const, override)); |
| 84 | MOCK_METHOD(std::optional<RawLightInfo>, getRawLightInfo, (int32_t deviceId, int32_t lightId), |
| 85 | (const, override)); |
| 86 | MOCK_METHOD(std::optional<int32_t>, getLightBrightness, (int32_t deviceId, int32_t lightId), |
| 87 | (const, override)); |
| 88 | MOCK_METHOD(void, setLightBrightness, (int32_t deviceId, int32_t lightId, int32_t brightness), |
| 89 | (override)); |
| 90 | MOCK_METHOD((std::optional<std::unordered_map<LightColor, int32_t>>), getLightIntensities, |
| 91 | (int32_t deviceId, int32_t lightId), (const, override)); |
| 92 | MOCK_METHOD(void, setLightIntensities, |
| 93 | (int32_t deviceId, int32_t lightId, |
| 94 | (std::unordered_map<LightColor, int32_t>)intensities), |
| 95 | (override)); |
| 96 | |
| 97 | MOCK_METHOD(std::optional<RawLayoutInfo>, getRawLayoutInfo, (int32_t deviceId), |
| 98 | (const, override)); |
| 99 | MOCK_METHOD(int32_t, getScanCodeState, (int32_t deviceId, int32_t scanCode), (const, override)); |
| 100 | MOCK_METHOD(int32_t, getKeyCodeState, (int32_t deviceId, int32_t keyCode), (const, override)); |
| 101 | MOCK_METHOD(int32_t, getSwitchState, (int32_t deviceId, int32_t sw), (const, override)); |
| 102 | |
| 103 | MOCK_METHOD(status_t, getAbsoluteAxisValue, (int32_t deviceId, int32_t axis, int32_t* outValue), |
| 104 | (const, override)); |
| 105 | MOCK_METHOD(int32_t, getKeyCodeForKeyLocation, (int32_t deviceId, int32_t locationKeyCode), |
| 106 | (const, override)); |
| 107 | MOCK_METHOD(bool, markSupportedKeyCodes, |
| 108 | (int32_t deviceId, const std::vector<int32_t>& keyCodes, uint8_t* outFlags), |
| 109 | (const, override)); |
| 110 | |
| 111 | MOCK_METHOD(bool, hasScanCode, (int32_t deviceId, int32_t scanCode), (const, override)); |
| 112 | |
| 113 | MOCK_METHOD(bool, hasKeyCode, (int32_t deviceId, int32_t keyCode), (const, override)); |
| 114 | |
| 115 | MOCK_METHOD(bool, hasLed, (int32_t deviceId, int32_t led), (const, override)); |
| 116 | |
| 117 | MOCK_METHOD(void, setLedState, (int32_t deviceId, int32_t led, bool on), (override)); |
| 118 | |
| 119 | MOCK_METHOD(void, getVirtualKeyDefinitions, |
| 120 | (int32_t deviceId, std::vector<VirtualKeyDefinition>& outVirtualKeys), |
| 121 | (const, override)); |
| 122 | |
| 123 | MOCK_METHOD(const std::shared_ptr<KeyCharacterMap>, getKeyCharacterMap, (int32_t deviceId), |
| 124 | (const, override)); |
| 125 | |
| 126 | MOCK_METHOD(bool, setKeyboardLayoutOverlay, |
| 127 | (int32_t deviceId, std::shared_ptr<KeyCharacterMap> map), (override)); |
| 128 | |
| 129 | MOCK_METHOD(void, vibrate, (int32_t deviceId, const VibrationElement& effect), (override)); |
| 130 | MOCK_METHOD(void, cancelVibrate, (int32_t deviceId), (override)); |
| 131 | |
| 132 | MOCK_METHOD(std::vector<int32_t>, getVibratorIds, (int32_t deviceId), (const, override)); |
| 133 | MOCK_METHOD(std::optional<int32_t>, getBatteryCapacity, (int32_t deviceId, int32_t batteryId), |
| 134 | (const, override)); |
| 135 | |
| 136 | MOCK_METHOD(std::optional<int32_t>, getBatteryStatus, (int32_t deviceId, int32_t batteryId), |
| 137 | (const, override)); |
| 138 | MOCK_METHOD(void, requestReopenDevices, (), (override)); |
| 139 | MOCK_METHOD(void, wake, (), (override)); |
| 140 | |
| 141 | MOCK_METHOD(void, dump, (std::string & dump), (const, override)); |
| 142 | MOCK_METHOD(void, monitor, (), (const, override)); |
| 143 | MOCK_METHOD(bool, isDeviceEnabled, (int32_t deviceId), (const, override)); |
| 144 | MOCK_METHOD(status_t, enableDevice, (int32_t deviceId), (override)); |
| 145 | MOCK_METHOD(status_t, disableDevice, (int32_t deviceId), (override)); |
| 146 | MOCK_METHOD(void, sysfsNodeChanged, (const std::string& sysfsNodePath), (override)); |
| 147 | }; |
| 148 | |
| 149 | } // namespace android |