diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/CMakeLists.txt unity-system-compositor-0.4.3+16.04.20160323/CMakeLists.txt --- unity-system-compositor-0.4.2+16.04.20160219.1/CMakeLists.txt 2016-02-19 14:55:20.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/CMakeLists.txt 2016-03-23 11:06:39.000000000 +0000 @@ -17,7 +17,7 @@ project(UnitySystemCompositor) set(USC_VERSION_MAJOR 0) set(USC_VERSION_MINOR 4) -set(USC_VERSION_PATCH 2) +set(USC_VERSION_PATCH 3) set(USC_VERSION "${USC_VERSION_MAJOR}.${USC_VERSION_MINOR}.${USC_VERSION_PATCH}") cmake_minimum_required(VERSION 2.8) @@ -43,11 +43,16 @@ pkg_check_modules(MIRCLIENT REQUIRED mirclient) pkg_check_modules(MIRSERVER REQUIRED mirserver) pkg_check_modules(DBUS REQUIRED dbus-1) +pkg_check_modules(UBUNTU_PLATFORM_HARDWARE_API ubuntu-platform-hardware-api) find_package(Boost 1.48.0 COMPONENTS system REQUIRED) find_package(GLESv2 REQUIRED) find_package(PIL REQUIRED) +if (UBUNTU_PLATFORM_HARDWARE_API_FOUND) + add_definitions(-DUSC_HAVE_UBUNTU_PLATFORM_HARDWARE_API) +endif() + add_subdirectory(spinner/) add_subdirectory(src/) diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/debian/changelog unity-system-compositor-0.4.3+16.04.20160323/debian/changelog --- unity-system-compositor-0.4.2+16.04.20160219.1/debian/changelog 2016-03-30 13:51:19.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/debian/changelog 2016-03-30 13:51:19.000000000 +0000 @@ -1,3 +1,16 @@ +unity-system-compositor (0.4.3+16.04.20160323-0ubuntu1) xenial; urgency=medium + + [ CI Train Bot ] + * No-change rebuild. + + -- Thomas Voß Wed, 23 Mar 2016 11:06:43 +0000 + +unity-system-compositor (0.4.3) xenial; urgency=medium + + * Gracefully fallback if ubuntu's platform hw api is not available. + + -- Thomas Voß Tue, 22 Mar 2016 16:34:23 +0100 + unity-system-compositor (0.4.2+16.04.20160219.1-0ubuntu1) xenial; urgency=medium [ Alan Griffiths, Alexandros Frantzis, Brandon Schaefer ] diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/debian/control unity-system-compositor-0.4.3+16.04.20160323/debian/control --- unity-system-compositor-0.4.2+16.04.20160219.1/debian/control 2016-03-30 13:51:19.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/debian/control 2016-03-30 13:51:19.000000000 +0000 @@ -21,6 +21,7 @@ python:any (>= 2.7), python-setuptools, python-pil, + libubuntu-platform-hardware-api-dev [!arm64 !ppc64el !powerpc !s390x], Standards-Version: 3.9.4 Homepage: https://launchpad.net/unity-system-compositor # if you don't have have commit access to this branch but would like to upload diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/CMakeLists.txt unity-system-compositor-0.4.3+16.04.20160323/src/CMakeLists.txt --- unity-system-compositor-0.4.2+16.04.20160219.1/src/CMakeLists.txt 2016-02-19 14:55:20.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/CMakeLists.txt 2016-03-23 11:06:39.000000000 +0000 @@ -14,15 +14,23 @@ # # Authored by: Robert Ancell +if (UBUNTU_PLATFORM_HARDWARE_API_FOUND) + set(PERFORMANCE_BOOSTER_IMPL_SRCS hw_performance_booster.cpp null_performance_booster.cpp) +else() + set(PERFORMANCE_BOOSTER_IMPL_SRCS null_performance_booster.cpp) +endif() + set(USC_SRCS asio_dm_connection.cpp dbus_connection_handle.cpp dbus_event_loop.cpp dbus_message_handle.cpp display_configuration_policy.cpp - external_spinner.cpp + external_spinner.cpp mir_screen.cpp mir_input_configuration.cpp + performance_booster.h + performance_booster.cpp powerd_mediator.cpp screen_event_handler.cpp server.cpp @@ -36,6 +44,8 @@ unity_screen_service.cpp unity_screen_service_introspection.h window_manager.cpp + + ${PERFORMANCE_BOOSTER_IMPL_SRCS} ) # Generate unity_screen_service_introspection.h from the introspection XML file @@ -74,6 +84,7 @@ ${MIRSERVER_INCLUDE_DIRS} ${MIRCLIENT_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS} + ${UBUNTU_PLATFORM_HARDWARE_API_INCLUDE_DIRS} ) add_definitions( -DDEFAULT_SPINNER="${CMAKE_INSTALL_FULL_BINDIR}/unity-system-compositor-spinner" @@ -87,6 +98,7 @@ ${Boost_LIBRARIES} ${GLESv2_LIBRARIES} ${DBUS_LIBRARIES} + ${UBUNTU_PLATFORM_HARDWARE_API_LIBRARIES} ) target_link_libraries(unity-system-compositor diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/hw_performance_booster.cpp unity-system-compositor-0.4.3+16.04.20160323/src/hw_performance_booster.cpp --- unity-system-compositor-0.4.2+16.04.20160219.1/src/hw_performance_booster.cpp 1970-01-01 00:00:00.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/hw_performance_booster.cpp 2016-03-23 11:06:39.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * Copyright © 2016 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include "hw_performance_booster.h" + +#include + +#include + +namespace +{ +UHardwareBooster* create_hw_booster_or_throw() +{ + if (auto result = u_hardware_booster_new()) + return result; + + BOOST_THROW_EXCEPTION(std::runtime_error{"Failed to acquire a valid UHardwareBooster instance."}); +} +} + +usc::HwPerformanceBooster::HwPerformanceBooster() : hw_booster{create_hw_booster_or_throw(), [](UHardwareBooster* booster) { if (booster) u_hardware_booster_unref(booster); }} +{ +} + +void usc::HwPerformanceBooster::enable_performance_boost_during_user_interaction() +{ + u_hardware_booster_enable_scenario(hw_booster.get(), U_HARDWARE_BOOSTER_SCENARIO_USER_INTERACTION); +} + +void usc::HwPerformanceBooster::disable_performance_boost_during_user_interaction() +{ + u_hardware_booster_disable_scenario(hw_booster.get(), U_HARDWARE_BOOSTER_SCENARIO_USER_INTERACTION); +} diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/hw_performance_booster.h unity-system-compositor-0.4.3+16.04.20160323/src/hw_performance_booster.h --- unity-system-compositor-0.4.2+16.04.20160219.1/src/hw_performance_booster.h 1970-01-01 00:00:00.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/hw_performance_booster.h 2016-03-23 11:06:39.000000000 +0000 @@ -0,0 +1,44 @@ +/* + * Copyright © 2016 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef USC_HW_PERFORMANCE_BOOSTER_H_ +#define USC_HW_PERFORMANCE_BOOSTER_H_ + +#include "performance_booster.h" + +#include + +#include + +namespace usc +{ +class HwPerformanceBooster : public PerformanceBooster +{ +public: + // Throws std::runtime_error if we fail to gain access to the hw booster. + HwPerformanceBooster(); + + void enable_performance_boost_during_user_interaction() override; + void disable_performance_boost_during_user_interaction() override; + +protected: + const std::shared_ptr hw_booster; +}; +} + +#endif // USC_HW_PERFORMANCE_BOOSTER_H_ diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/mir_screen.cpp unity-system-compositor-0.4.3+16.04.20160323/src/mir_screen.cpp --- unity-system-compositor-0.4.2+16.04.20160219.1/src/mir_screen.cpp 2016-02-19 14:55:20.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/mir_screen.cpp 2016-03-23 11:06:39.000000000 +0000 @@ -31,6 +31,8 @@ #include #include + +#include "performance_booster.h" #include "screen_hardware.h" #include "power_state_change_reason.h" #include "server.h" @@ -102,6 +104,7 @@ }; usc::MirScreen::MirScreen( + std::shared_ptr const& perf_booster, std::shared_ptr const& screen_hardware, std::shared_ptr const& compositor, std::shared_ptr const& display, @@ -111,7 +114,8 @@ Timeouts inactivity_timeouts, Timeouts notification_timeouts, Timeouts snap_decision_timeouts) - : screen_hardware{screen_hardware}, + : perf_booster{perf_booster}, + screen_hardware{screen_hardware}, compositor{compositor}, display{display}, touch_visualizer{touch_visualizer}, @@ -306,11 +310,13 @@ bool const power_on = mode == MirPowerMode::mir_power_mode_on; if (power_on) { + perf_booster->enable_performance_boost_during_user_interaction(); //Some devices do not turn screen on properly from suspend mode screen_hardware->disable_suspend(); } else { + perf_booster->disable_performance_boost_during_user_interaction(); screen_hardware->turn_off_backlight(); } diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/mir_screen.h unity-system-compositor-0.4.3+16.04.20160323/src/mir_screen.h --- unity-system-compositor-0.4.2+16.04.20160219.1/src/mir_screen.h 2016-02-19 14:55:20.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/mir_screen.h 2016-03-23 11:06:39.000000000 +0000 @@ -36,6 +36,7 @@ namespace usc { +class PerformanceBooster; class Server; class ScreenHardware; class Clock; @@ -49,7 +50,8 @@ std::chrono::milliseconds dimming_timeout; }; - MirScreen(std::shared_ptr const& screen_hardware, + MirScreen(std::shared_ptr const& perf_booster, + std::shared_ptr const& screen_hardware, std::shared_ptr const& compositor, std::shared_ptr const& display, std::shared_ptr const& touch_visualizer, @@ -97,6 +99,7 @@ void long_press_alarm_notification(); + std::shared_ptr const perf_booster; std::shared_ptr const screen_hardware; std::shared_ptr const compositor; std::shared_ptr const display; diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/null_performance_booster.cpp unity-system-compositor-0.4.3+16.04.20160323/src/null_performance_booster.cpp --- unity-system-compositor-0.4.2+16.04.20160219.1/src/null_performance_booster.cpp 1970-01-01 00:00:00.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/null_performance_booster.cpp 2016-03-23 11:06:39.000000000 +0000 @@ -0,0 +1,28 @@ +/* + * Copyright © 2016 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#include "null_performance_booster.h" + + +void usc::NullPerformanceBooster::enable_performance_boost_during_user_interaction() +{ +} + +void usc::NullPerformanceBooster::disable_performance_boost_during_user_interaction() +{ +} diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/null_performance_booster.h unity-system-compositor-0.4.3+16.04.20160323/src/null_performance_booster.h --- unity-system-compositor-0.4.2+16.04.20160219.1/src/null_performance_booster.h 1970-01-01 00:00:00.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/null_performance_booster.h 2016-03-23 11:06:39.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * Copyright © 2016 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef USC_NULL_PERFORMANCE_BOOSTER_H_ +#define USC_NULL_PERFORMANCE_BOOSTER_H_ + +#include "performance_booster.h" + +namespace usc +{ +class NullPerformanceBooster : public PerformanceBooster +{ +public: + void enable_performance_boost_during_user_interaction() override; + void disable_performance_boost_during_user_interaction() override; +}; +} + +#endif // USC_NULL_PERFORMANCE_BOOSTER_H_ diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/performance_booster.cpp unity-system-compositor-0.4.3+16.04.20160323/src/performance_booster.cpp --- unity-system-compositor-0.4.2+16.04.20160219.1/src/performance_booster.cpp 1970-01-01 00:00:00.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/performance_booster.cpp 2016-03-23 11:06:39.000000000 +0000 @@ -0,0 +1,52 @@ +/* + * Copyright © 2016 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#define MIR_LOG_COMPONENT "UnitySystemCompositor" + +#include "performance_booster.h" +#include "null_performance_booster.h" + +#include + +#include + +#if defined(USC_HAVE_UBUNTU_PLATFORM_HARDWARE_API) +#include "hw_performance_booster.h" + +std::shared_ptr usc::platform_default_performance_booster() +{ + // We are treating access to a functional implementation of PerformanceBooster as optional. + // With that, we gracefully fall back to a NullImplementation if we cannot gain access + // to hw-provided booster capabilities. + try + { + return std::make_shared(); + } + catch (boost::exception const& e) + { + mir::log_warning(boost::diagnostic_information(e)); + } + + return std::make_shared(); +} +#else +std::shared_ptr usc::platform_default_performance_booster() +{ + return std::make_shared(); +} +#endif // USC_HAVE_UBUNTU_PLATFORM_HARDWARE_API diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/performance_booster.h unity-system-compositor-0.4.3+16.04.20160323/src/performance_booster.h --- unity-system-compositor-0.4.2+16.04.20160219.1/src/performance_booster.h 1970-01-01 00:00:00.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/performance_booster.h 2016-03-23 11:06:39.000000000 +0000 @@ -0,0 +1,41 @@ +/* + * Copyright © 2016 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authored by: Thomas Voß + */ + +#ifndef USC_PERFORMANCE_BOOSTER_H_ +#define USC_PERFORMANCE_BOOSTER_H_ + +#include + +namespace usc +{ +class PerformanceBooster +{ +public: + PerformanceBooster() = default; + PerformanceBooster(const PerformanceBooster&) = delete; + virtual ~PerformanceBooster() = default; + PerformanceBooster& operator=(const PerformanceBooster&) = delete; + + virtual void enable_performance_boost_during_user_interaction() = 0; + virtual void disable_performance_boost_during_user_interaction() = 0; +}; + +std::shared_ptr platform_default_performance_booster(); +} + +#endif // USC_PERFORMANCE_BOOSTER_H_ diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/server.cpp unity-system-compositor-0.4.3+16.04.20160323/src/server.cpp --- unity-system-compositor-0.4.2+16.04.20160219.1/src/server.cpp 2016-02-19 14:55:20.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/server.cpp 2016-03-23 11:06:39.000000000 +0000 @@ -16,6 +16,8 @@ * Authored by: Alexandros Frantzis */ +#define MIR_LOG_COMPONENT "UnitySystemCompositor" + #include "server.h" #include "external_spinner.h" #include "asio_dm_connection.h" @@ -24,6 +26,7 @@ #include "mir_screen.h" #include "mir_input_configuration.h" #include "screen_event_handler.h" +#include "performance_booster.h" #include "powerd_mediator.h" #include "unity_screen_service.h" #include "unity_input_service.h" @@ -37,9 +40,12 @@ #include #include #include +#include #include #include +#include + #include namespace msh = mir::shell; @@ -201,6 +207,11 @@ apply_settings(); } +std::shared_ptr usc::Server::the_performance_booster() +{ + return platform_default_performance_booster(); +} + std::shared_ptr usc::Server::the_spinner() { return spinner( @@ -288,6 +299,7 @@ [this] { return std::make_shared( + the_performance_booster(), the_screen_hardware(), the_compositor(), the_display(), diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/src/server.h unity-system-compositor-0.4.3+16.04.20160323/src/server.h --- unity-system-compositor-0.4.2+16.04.20160219.1/src/server.h 2016-02-19 14:55:20.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/src/server.h 2016-03-23 11:06:39.000000000 +0000 @@ -39,6 +39,7 @@ class SessionSwitcher; class DMMessageHandler; class DMConnection; +class PerformanceBooster; class Screen; class ScreenHardware; class UnityScreenService; @@ -61,6 +62,7 @@ using mir::Server::the_compositor; using mir::Server::the_touch_visualizer; + virtual std::shared_ptr the_performance_booster(); virtual std::shared_ptr the_spinner(); virtual std::shared_ptr the_dm_message_handler(); virtual std::shared_ptr the_dm_connection(); diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/tests/integration-tests/test_deadlock_lp1491566.cpp unity-system-compositor-0.4.3+16.04.20160323/tests/integration-tests/test_deadlock_lp1491566.cpp --- unity-system-compositor-0.4.2+16.04.20160219.1/tests/integration-tests/test_deadlock_lp1491566.cpp 2016-02-19 14:55:20.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/tests/integration-tests/test_deadlock_lp1491566.cpp 2016-03-23 11:06:39.000000000 +0000 @@ -18,6 +18,7 @@ #include "src/server.h" #include "src/mir_screen.h" +#include "src/performance_booster.h" #include "src/screen_hardware.h" #include "src/power_state_change_reason.h" #include "spin_wait.h" @@ -47,6 +48,11 @@ void stop() override {} }; +struct StubPerformanceBooster : usc::PerformanceBooster +{ + void enable_performance_boost_during_user_interaction() override {} + void disable_performance_boost_during_user_interaction() override {} +}; struct StubScreenHardware : usc::ScreenHardware { @@ -153,6 +159,7 @@ std::chrono::milliseconds const dimmer_timeout{100}; TestMirScreen mir_screen{ + std::make_shared(), std::make_shared(), std::make_shared(), std::make_shared<::testing::NiceMock>(), diff -Nru unity-system-compositor-0.4.2+16.04.20160219.1/tests/unit-tests/test_mir_screen.cpp unity-system-compositor-0.4.3+16.04.20160323/tests/unit-tests/test_mir_screen.cpp --- unity-system-compositor-0.4.2+16.04.20160219.1/tests/unit-tests/test_mir_screen.cpp 2016-02-19 14:55:20.000000000 +0000 +++ unity-system-compositor-0.4.3+16.04.20160323/tests/unit-tests/test_mir_screen.cpp 2016-03-23 11:06:39.000000000 +0000 @@ -17,6 +17,7 @@ */ #include "src/mir_screen.h" +#include "src/performance_booster.h" #include "src/screen_hardware.h" #include "src/power_state_change_reason.h" #include "advanceable_timer.h" @@ -45,6 +46,12 @@ MOCK_METHOD0(stop, void()); }; +struct MockPerformanceBooster : usc::PerformanceBooster +{ + MOCK_METHOD0(enable_performance_boost_during_user_interaction, void()); + MOCK_METHOD0(disable_performance_boost_during_user_interaction, void()); +}; + struct MockScreenHardware : usc::ScreenHardware { MOCK_METHOD0(set_dim_backlight, void()); @@ -137,6 +144,18 @@ std::chrono::seconds const fourty_seconds{40}; std::chrono::seconds const fifty_seconds{50}; + void expect_performance_boost_is_enabled() + { + using namespace testing; + EXPECT_CALL(*performance_booster, enable_performance_boost_during_user_interaction()); + } + + void expect_performance_boost_is_disabled() + { + using namespace testing; + EXPECT_CALL(*performance_booster, disable_performance_boost_during_user_interaction()); + } + void expect_screen_is_turned_off() { using namespace testing; @@ -274,6 +293,8 @@ Mock::VerifyAndClearExpectations(compositor.get()); } + std::shared_ptr performance_booster{ + std::make_shared>()}; std::shared_ptr screen_hardware{ std::make_shared>()}; std::shared_ptr compositor{ @@ -286,6 +307,7 @@ std::make_shared()}; usc::MirScreen mir_screen{ + performance_booster, screen_hardware, compositor, display, @@ -297,8 +319,51 @@ {call_power_off_timeout, call_dimmer_timeout}}; }; +struct AParameterizedMirScreen : public AMirScreen, public ::testing::WithParamInterface {}; +struct ImmediatePowerOnMirScreen : public AParameterizedMirScreen {}; +struct DeferredPowerOnMirScreen : public AParameterizedMirScreen {}; + +} + +TEST_P(ImmediatePowerOnMirScreen, enables_performance_boost_for_screen_on) +{ + turn_screen_off(); + expect_performance_boost_is_enabled(); + mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on, GetParam()); } +TEST_P(DeferredPowerOnMirScreen, enables_performance_boost_for_screen_on_with_reason_proximity) +{ + turn_screen_off(); + expect_performance_boost_is_enabled(); + mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on, GetParam()); + mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_on, PowerStateChangeReason::proximity); +} + +TEST_P(AParameterizedMirScreen, disables_performance_boost_for_screen_off) +{ + turn_screen_on(); + expect_performance_boost_is_disabled(); + mir_screen.set_screen_power_mode(MirPowerMode::mir_power_mode_off, GetParam()); +} + +INSTANTIATE_TEST_CASE_P( + AParameterizedMirScreen, + AParameterizedMirScreen, + ::testing::Values(PowerStateChangeReason::unknown, PowerStateChangeReason::inactivity, PowerStateChangeReason::power_key, + PowerStateChangeReason::proximity, PowerStateChangeReason::notification, PowerStateChangeReason::snap_decision, + PowerStateChangeReason::call_done)); + +INSTANTIATE_TEST_CASE_P( + ImmediatePowerOnMirScreen, + ImmediatePowerOnMirScreen, + ::testing::Values(PowerStateChangeReason::unknown, PowerStateChangeReason::inactivity, PowerStateChangeReason::power_key)); + +INSTANTIATE_TEST_CASE_P( + DeferredPowerOnMirScreen, + DeferredPowerOnMirScreen, + ::testing::Values(PowerStateChangeReason::notification, PowerStateChangeReason::snap_decision, PowerStateChangeReason::call_done)); + TEST_F(AMirScreen, turns_screen_off_after_power_off_timeout) { expect_screen_is_turned_off();