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 17 #ifndef _UI_TEST_INPUT_LISTENER_H 18 #define _UI_TEST_INPUT_LISTENER_H 19 20 #include <gtest/gtest.h> 21 #include "InputListener.h" 22 23 namespace android { 24 25 // --- TestInputListener --- 26 27 class TestInputListener : public InputListenerInterface { 28 private: 29 std::vector<NotifyConfigurationChangedArgs> mNotifyConfigurationChangedArgsQueue; 30 std::vector<NotifyDeviceResetArgs> mNotifyDeviceResetArgsQueue; 31 std::vector<NotifyKeyArgs> mNotifyKeyArgsQueue; 32 std::vector<NotifyMotionArgs> mNotifyMotionArgsQueue; 33 std::vector<NotifySwitchArgs> mNotifySwitchArgsQueue; 34 35 protected: 36 virtual ~TestInputListener(); 37 38 public: 39 TestInputListener(); 40 41 void assertNotifyConfigurationChangedWasCalled( 42 NotifyConfigurationChangedArgs* outEventArgs = nullptr); 43 44 void assertNotifyConfigurationChangedWasNotCalled(); 45 46 void assertNotifyDeviceResetWasCalled(NotifyDeviceResetArgs* outEventArgs = nullptr); 47 48 void assertNotifyDeviceResetWasNotCalled(); 49 50 void assertNotifyKeyWasCalled(NotifyKeyArgs* outEventArgs = nullptr); 51 52 void assertNotifyKeyWasNotCalled(); 53 54 void assertNotifyMotionWasCalled(NotifyMotionArgs* outEventArgs = nullptr); 55 56 void assertNotifyMotionWasNotCalled(); 57 58 void assertNotifySwitchWasCalled(NotifySwitchArgs* outEventArgs = nullptr); 59 60 private: 61 virtual void notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args); 62 63 virtual void notifyDeviceReset(const NotifyDeviceResetArgs* args); 64 65 virtual void notifyKey(const NotifyKeyArgs* args); 66 67 virtual void notifyMotion(const NotifyMotionArgs* args); 68 69 virtual void notifySwitch(const NotifySwitchArgs* args); 70 }; 71 72 } // namespace android 73 #endif 74