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