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