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 18 #include <gtest/gtest.h> 19 20 #include "TestInputListener.h" 21 22 namespace android { 23 24 // --- TestInputListener --- 25 TestInputListener()26TestInputListener::TestInputListener() { } 27 ~TestInputListener()28TestInputListener::~TestInputListener() { } 29 assertNotifyConfigurationChangedWasCalled(NotifyConfigurationChangedArgs * outEventArgs)30void TestInputListener::assertNotifyConfigurationChangedWasCalled( 31 NotifyConfigurationChangedArgs* outEventArgs) { 32 ASSERT_FALSE(mNotifyConfigurationChangedArgsQueue.empty()) 33 << "Expected notifyConfigurationChanged() to have been called."; 34 if (outEventArgs) { 35 *outEventArgs = *mNotifyConfigurationChangedArgsQueue.begin(); 36 } 37 mNotifyConfigurationChangedArgsQueue.erase(mNotifyConfigurationChangedArgsQueue.begin()); 38 } 39 assertNotifyConfigurationChangedWasNotCalled()40void TestInputListener::assertNotifyConfigurationChangedWasNotCalled() { 41 ASSERT_TRUE(mNotifyConfigurationChangedArgsQueue.empty()) 42 << "Expected notifyConfigurationChanged() to not have been called."; 43 } 44 assertNotifyDeviceResetWasCalled(NotifyDeviceResetArgs * outEventArgs)45void TestInputListener::assertNotifyDeviceResetWasCalled( 46 NotifyDeviceResetArgs* outEventArgs) { 47 ASSERT_FALSE(mNotifyDeviceResetArgsQueue.empty()) 48 << "Expected notifyDeviceReset() to have been called."; 49 if (outEventArgs) { 50 *outEventArgs = *mNotifyDeviceResetArgsQueue.begin(); 51 } 52 mNotifyDeviceResetArgsQueue.erase(mNotifyDeviceResetArgsQueue.begin()); 53 } 54 assertNotifyDeviceResetWasNotCalled()55void TestInputListener::assertNotifyDeviceResetWasNotCalled() { 56 ASSERT_TRUE(mNotifyDeviceResetArgsQueue.empty()) 57 << "Expected notifyDeviceReset() to not have been called."; 58 } 59 assertNotifyKeyWasCalled(NotifyKeyArgs * outEventArgs)60void TestInputListener::assertNotifyKeyWasCalled(NotifyKeyArgs* outEventArgs) { 61 ASSERT_FALSE(mNotifyKeyArgsQueue.empty()) << "Expected notifyKey() to have been called."; 62 if (outEventArgs) { 63 *outEventArgs = *mNotifyKeyArgsQueue.begin(); 64 } 65 mNotifyKeyArgsQueue.erase(mNotifyKeyArgsQueue.begin()); 66 } 67 assertNotifyKeyWasNotCalled()68void TestInputListener::assertNotifyKeyWasNotCalled() { 69 ASSERT_TRUE(mNotifyKeyArgsQueue.empty()) << "Expected notifyKey() to not have been called."; 70 } 71 assertNotifyMotionWasCalled(NotifyMotionArgs * outEventArgs)72void TestInputListener::assertNotifyMotionWasCalled(NotifyMotionArgs* outEventArgs) { 73 ASSERT_FALSE(mNotifyMotionArgsQueue.empty()) << "Expected notifyMotion() to have been called."; 74 if (outEventArgs) { 75 *outEventArgs = *mNotifyMotionArgsQueue.begin(); 76 } 77 mNotifyMotionArgsQueue.erase(mNotifyMotionArgsQueue.begin()); 78 } 79 assertNotifyMotionWasNotCalled()80void TestInputListener::assertNotifyMotionWasNotCalled() { 81 ASSERT_TRUE(mNotifyMotionArgsQueue.empty()) 82 << "Expected notifyMotion() to not have been called."; 83 } 84 assertNotifySwitchWasCalled(NotifySwitchArgs * outEventArgs)85void TestInputListener::assertNotifySwitchWasCalled(NotifySwitchArgs* outEventArgs) { 86 ASSERT_FALSE(mNotifySwitchArgsQueue.empty()) 87 << "Expected notifySwitch() to have been called."; 88 if (outEventArgs) { 89 *outEventArgs = *mNotifySwitchArgsQueue.begin(); 90 } 91 mNotifySwitchArgsQueue.erase(mNotifySwitchArgsQueue.begin()); 92 } 93 notifyConfigurationChanged(const NotifyConfigurationChangedArgs * args)94void TestInputListener::notifyConfigurationChanged(const NotifyConfigurationChangedArgs* args) { 95 mNotifyConfigurationChangedArgsQueue.push_back(*args); 96 } 97 notifyDeviceReset(const NotifyDeviceResetArgs * args)98void TestInputListener::notifyDeviceReset(const NotifyDeviceResetArgs* args) { 99 mNotifyDeviceResetArgsQueue.push_back(*args); 100 } 101 notifyKey(const NotifyKeyArgs * args)102void TestInputListener::notifyKey(const NotifyKeyArgs* args) { 103 mNotifyKeyArgsQueue.push_back(*args); 104 } 105 notifyMotion(const NotifyMotionArgs * args)106void TestInputListener::notifyMotion(const NotifyMotionArgs* args) { 107 mNotifyMotionArgsQueue.push_back(*args); 108 } 109 notifySwitch(const NotifySwitchArgs * args)110void TestInputListener::notifySwitch(const NotifySwitchArgs* args) { 111 mNotifySwitchArgsQueue.push_back(*args); 112 } 113 114 115 } // namespace android 116