1 /* 2 * Copyright 2020 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 #undef LOG_TAG 18 #define LOG_TAG "LibSurfaceFlingerUnittests" 19 20 #include <chrono> 21 #include <thread> 22 23 #include "DisplayTransactionTestHelpers.h" 24 25 #include <android/hardware/power/Boost.h> 26 27 namespace android { 28 namespace { 29 30 using android::hardware::power::Boost; 31 TEST_F(DisplayTransactionTest,notifyPowerBoostNotifiesTouchEvent)32TEST_F(DisplayTransactionTest, notifyPowerBoostNotifiesTouchEvent) { 33 using namespace std::chrono_literals; 34 35 mFlinger.scheduler()->replaceTouchTimer(100); 36 std::this_thread::sleep_for(10ms); // wait for callback to be triggered 37 EXPECT_TRUE(mFlinger.scheduler()->isTouchActive()); // Starting timer activates touch 38 39 std::this_thread::sleep_for(110ms); // wait for reset touch timer to expire and trigger callback 40 EXPECT_FALSE(mFlinger.scheduler()->isTouchActive()); 41 42 EXPECT_EQ(NO_ERROR, mFlinger.notifyPowerBoost(static_cast<int32_t>(Boost::CAMERA_SHOT))); 43 std::this_thread::sleep_for(10ms); // wait for callback to maybe be triggered 44 EXPECT_FALSE(mFlinger.scheduler()->isTouchActive()); 45 46 std::this_thread::sleep_for(110ms); // wait for reset touch timer to expire and trigger callback 47 EXPECT_FALSE(mFlinger.scheduler()->isTouchActive()); 48 49 EXPECT_EQ(NO_ERROR, mFlinger.notifyPowerBoost(static_cast<int32_t>(Boost::INTERACTION))); 50 std::this_thread::sleep_for(10ms); // wait for callback to be triggered. 51 EXPECT_TRUE(mFlinger.scheduler()->isTouchActive()); 52 } 53 54 } // namespace 55 } // namespace android 56