Commit eebe273b authored by dnicoara's avatar dnicoara Committed by Commit bot

Make SetDisplayPower() take a callback to signal completion

SetDisplayPower() is called by powerd to turn the panel on. After that
powerd will set the backlight level. Since DisplayConfigurator may be
executing the SetDisplayPower() operation asynchronously, the panel
may still be off when powerd tries to set the backlight level. So
powerd's operation would be ignored by the driver.

BUG=chrome-os-partner:35662

Review URL: https://codereview.chromium.org/886103002

Cr-Commit-Position: refs/heads/master@{#313983}
parent 5d692492
...@@ -19,7 +19,8 @@ ChromeDisplayPowerServiceProviderDelegate:: ...@@ -19,7 +19,8 @@ ChromeDisplayPowerServiceProviderDelegate::
} }
void ChromeDisplayPowerServiceProviderDelegate::SetDisplayPower( void ChromeDisplayPowerServiceProviderDelegate::SetDisplayPower(
DisplayPowerState power_state) { DisplayPowerState power_state,
const ResponseCallback& callback) {
// Turning displays off when the device becomes idle or on just before // Turning displays off when the device becomes idle or on just before
// we suspend may trigger a mouse move, which would then be incorrectly // we suspend may trigger a mouse move, which would then be incorrectly
// reported as user activity. Let the UserActivityDetector // reported as user activity. Let the UserActivityDetector
...@@ -27,7 +28,7 @@ void ChromeDisplayPowerServiceProviderDelegate::SetDisplayPower( ...@@ -27,7 +28,7 @@ void ChromeDisplayPowerServiceProviderDelegate::SetDisplayPower(
ui::UserActivityDetector::Get()->OnDisplayPowerChanging(); ui::UserActivityDetector::Get()->OnDisplayPowerChanging();
ash::Shell::GetInstance()->display_configurator()->SetDisplayPower( ash::Shell::GetInstance()->display_configurator()->SetDisplayPower(
power_state, ui::DisplayConfigurator::kSetDisplayPowerNoFlags); power_state, ui::DisplayConfigurator::kSetDisplayPowerNoFlags, callback);
} }
void ChromeDisplayPowerServiceProviderDelegate::SetDimming(bool dimmed) { void ChromeDisplayPowerServiceProviderDelegate::SetDimming(bool dimmed) {
......
...@@ -17,7 +17,8 @@ class ChromeDisplayPowerServiceProviderDelegate ...@@ -17,7 +17,8 @@ class ChromeDisplayPowerServiceProviderDelegate
~ChromeDisplayPowerServiceProviderDelegate() override; ~ChromeDisplayPowerServiceProviderDelegate() override;
// DisplayPowerServiceProvider::Delegate overrides: // DisplayPowerServiceProvider::Delegate overrides:
void SetDisplayPower(DisplayPowerState power_state) override; void SetDisplayPower(DisplayPowerState power_state,
const ResponseCallback& callback) override;
void SetDimming(bool dimmed) override; void SetDimming(bool dimmed) override;
private: private:
......
...@@ -10,6 +10,17 @@ ...@@ -10,6 +10,17 @@
namespace chromeos { namespace chromeos {
namespace {
void RunConfigurationCallback(
dbus::MethodCall* method_call,
dbus::ExportedObject::ResponseSender response_sender,
bool status) {
response_sender.Run(dbus::Response::FromMethodCall(method_call));
}
} // namespace
DisplayPowerServiceProvider::DisplayPowerServiceProvider( DisplayPowerServiceProvider::DisplayPowerServiceProvider(
scoped_ptr<Delegate> delegate) scoped_ptr<Delegate> delegate)
: delegate_(delegate.Pass()), : delegate_(delegate.Pass()),
...@@ -50,14 +61,15 @@ void DisplayPowerServiceProvider::SetDisplayPower( ...@@ -50,14 +61,15 @@ void DisplayPowerServiceProvider::SetDisplayPower(
dbus::ExportedObject::ResponseSender response_sender) { dbus::ExportedObject::ResponseSender response_sender) {
dbus::MessageReader reader(method_call); dbus::MessageReader reader(method_call);
int int_state = 0; int int_state = 0;
Delegate::ResponseCallback callback =
base::Bind(&RunConfigurationCallback, method_call, response_sender);
if (reader.PopInt32(&int_state)) { if (reader.PopInt32(&int_state)) {
DisplayPowerState state = static_cast<DisplayPowerState>(int_state); DisplayPowerState state = static_cast<DisplayPowerState>(int_state);
delegate_->SetDisplayPower(state); delegate_->SetDisplayPower(state, callback);
} else { } else {
LOG(ERROR) << "Unable to parse " << kSetDisplayPower << " request"; LOG(ERROR) << "Unable to parse " << kSetDisplayPower << " request";
callback.Run(false);
} }
response_sender.Run(dbus::Response::FromMethodCall(method_call));
} }
void DisplayPowerServiceProvider::SetDisplaySoftwareDimming( void DisplayPowerServiceProvider::SetDisplaySoftwareDimming(
......
...@@ -31,10 +31,14 @@ class CHROMEOS_EXPORT DisplayPowerServiceProvider ...@@ -31,10 +31,14 @@ class CHROMEOS_EXPORT DisplayPowerServiceProvider
public: public:
class Delegate { class Delegate {
public: public:
typedef base::Callback<void(bool)> ResponseCallback;
virtual ~Delegate() {} virtual ~Delegate() {}
// Sets the display power state. // Sets the display power state. After the display power is set, |callback|
virtual void SetDisplayPower(DisplayPowerState power_state) = 0; // is called with the operation status.
virtual void SetDisplayPower(DisplayPowerState power_state,
const ResponseCallback& callback) = 0;
// Dims or undims the screen. // Dims or undims the screen.
virtual void SetDimming(bool dimmed) = 0; virtual void SetDimming(bool dimmed) = 0;
......
...@@ -32,6 +32,9 @@ const int kConfigureDelayMs = 500; ...@@ -32,6 +32,9 @@ const int kConfigureDelayMs = 500;
// such that we read an up to date state. // such that we read an up to date state.
const int kResumeDelayMs = 500; const int kResumeDelayMs = 500;
void DoNothing(bool status) {
}
} // namespace } // namespace
...@@ -460,6 +463,9 @@ DisplayConfigurator::DisplayConfigurator() ...@@ -460,6 +463,9 @@ DisplayConfigurator::DisplayConfigurator()
DisplayConfigurator::~DisplayConfigurator() { DisplayConfigurator::~DisplayConfigurator() {
if (native_display_delegate_) if (native_display_delegate_)
native_display_delegate_->RemoveObserver(this); native_display_delegate_->RemoveObserver(this);
CallAndClearInProgressCallbacks(false);
CallAndClearQueuedCallbacks(false);
} }
void DisplayConfigurator::SetDelegateForTesting( void DisplayConfigurator::SetDelegateForTesting(
...@@ -759,21 +765,27 @@ void DisplayConfigurator::PrepareForExit() { ...@@ -759,21 +765,27 @@ void DisplayConfigurator::PrepareForExit() {
void DisplayConfigurator::SetDisplayPower( void DisplayConfigurator::SetDisplayPower(
chromeos::DisplayPowerState power_state, chromeos::DisplayPowerState power_state,
int flags) { int flags,
if (!configure_display_ || display_externally_controlled_) const ConfigurationCallback& callback) {
if (!configure_display_ || display_externally_controlled_) {
callback.Run(false);
return; return;
}
VLOG(1) << "SetDisplayPower: power_state=" VLOG(1) << "SetDisplayPower: power_state="
<< DisplayPowerStateToString(power_state) << " flags=" << flags << DisplayPowerStateToString(power_state) << " flags=" << flags
<< ", configure timer=" << ", configure timer="
<< (configure_timer_.IsRunning() ? "Running" : "Stopped"); << (configure_timer_.IsRunning() ? "Running" : "Stopped");
if (power_state == requested_power_state_ && if (power_state == requested_power_state_ &&
!(flags & kSetDisplayPowerForceProbe)) !(flags & kSetDisplayPowerForceProbe)) {
callback.Run(true);
return; return;
}
requested_power_state_ = power_state; requested_power_state_ = power_state;
requested_power_state_change_ = true; requested_power_state_change_ = true;
requested_power_flags_ = flags; requested_power_flags_ = flags;
queued_configuration_callbacks_.push_back(callback);
RunPendingConfiguration(); RunPendingConfiguration();
} }
...@@ -836,7 +848,8 @@ void DisplayConfigurator::SuspendDisplays() { ...@@ -836,7 +848,8 @@ void DisplayConfigurator::SuspendDisplays() {
// into the "on" state, which greatly reduces resume times. // into the "on" state, which greatly reduces resume times.
if (requested_power_state_ == chromeos::DISPLAY_POWER_ALL_OFF) { if (requested_power_state_ == chromeos::DISPLAY_POWER_ALL_OFF) {
SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON,
kSetDisplayPowerOnlyIfSingleInternalDisplay); kSetDisplayPowerOnlyIfSingleInternalDisplay,
base::Bind(&DoNothing));
// We need to make sure that the monitor configuration we just did actually // We need to make sure that the monitor configuration we just did actually
// completes before we return, because otherwise the X message could be // completes before we return, because otherwise the X message could be
...@@ -870,6 +883,7 @@ void DisplayConfigurator::RunPendingConfiguration() { ...@@ -870,6 +883,7 @@ void DisplayConfigurator::RunPendingConfiguration() {
if (!ShouldRunConfigurationTask()) { if (!ShouldRunConfigurationTask()) {
LOG(ERROR) << "Called RunPendingConfiguration without any changes" LOG(ERROR) << "Called RunPendingConfiguration without any changes"
" requested"; " requested";
CallAndClearQueuedCallbacks(true);
return; return;
} }
...@@ -886,6 +900,9 @@ void DisplayConfigurator::RunPendingConfiguration() { ...@@ -886,6 +900,9 @@ void DisplayConfigurator::RunPendingConfiguration() {
requested_power_state_change_ = false; requested_power_state_change_ = false;
requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID; requested_display_state_ = MULTIPLE_DISPLAY_STATE_INVALID;
DCHECK(in_progress_configuration_callbacks_.empty());
in_progress_configuration_callbacks_.swap(queued_configuration_callbacks_);
configuration_task_->Run(); configuration_task_->Run();
} }
...@@ -914,12 +931,18 @@ void DisplayConfigurator::OnConfigured( ...@@ -914,12 +931,18 @@ void DisplayConfigurator::OnConfigured(
configuration_task_.reset(); configuration_task_.reset();
NotifyObservers(success, new_display_state); NotifyObservers(success, new_display_state);
CallAndClearInProgressCallbacks(success);
if (success && !configure_timer_.IsRunning() && if (success && !configure_timer_.IsRunning() &&
ShouldRunConfigurationTask()) { ShouldRunConfigurationTask()) {
configure_timer_.Start(FROM_HERE, configure_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kConfigureDelayMs), base::TimeDelta::FromMilliseconds(kConfigureDelayMs),
this, &DisplayConfigurator::RunPendingConfiguration); this, &DisplayConfigurator::RunPendingConfiguration);
} else {
// If a new configuration task isn't scheduled respond to all queued
// callbacks (for example if requested state is current state).
if (!configure_timer_.IsRunning())
CallAndClearQueuedCallbacks(success);
} }
} }
...@@ -939,10 +962,25 @@ bool DisplayConfigurator::ShouldRunConfigurationTask() const { ...@@ -939,10 +962,25 @@ bool DisplayConfigurator::ShouldRunConfigurationTask() const {
return false; return false;
} }
void DisplayConfigurator::CallAndClearInProgressCallbacks(bool success) {
for (const auto& callback : in_progress_configuration_callbacks_)
callback.Run(success);
in_progress_configuration_callbacks_.clear();
}
void DisplayConfigurator::CallAndClearQueuedCallbacks(bool success) {
for (const auto& callback : queued_configuration_callbacks_)
callback.Run(success);
queued_configuration_callbacks_.clear();
}
void DisplayConfigurator::RestoreRequestedPowerStateAfterResume() { void DisplayConfigurator::RestoreRequestedPowerStateAfterResume() {
// Force probing to ensure that we pick up any changes that were made while // Force probing to ensure that we pick up any changes that were made while
// the system was suspended. // the system was suspended.
SetDisplayPower(requested_power_state_, kSetDisplayPowerForceProbe); SetDisplayPower(requested_power_state_, kSetDisplayPowerForceProbe,
base::Bind(&DoNothing));
} }
void DisplayConfigurator::NotifyObservers( void DisplayConfigurator::NotifyObservers(
......
...@@ -40,6 +40,8 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { ...@@ -40,6 +40,8 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
typedef uint64_t ContentProtectionClientId; typedef uint64_t ContentProtectionClientId;
static const ContentProtectionClientId kInvalidClientId = 0; static const ContentProtectionClientId kInvalidClientId = 0;
typedef base::Callback<void(bool)> ConfigurationCallback;
struct DisplayState { struct DisplayState {
DisplayState(); DisplayState();
...@@ -222,9 +224,12 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { ...@@ -222,9 +224,12 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
// Called when powerd notifies us that some set of displays should be turned // Called when powerd notifies us that some set of displays should be turned
// on or off. This requires enabling or disabling the CRTC associated with // on or off. This requires enabling or disabling the CRTC associated with
// the display(s) in question so that the low power state is engaged. // the display(s) in question so that the low power state is engaged.
// |flags| contains bitwise-or-ed kSetDisplayPower* values. Returns true if // |flags| contains bitwise-or-ed kSetDisplayPower* values. After the
// the system successfully enters (or was already in) |power_state|. // configuration finishes |callback| is called with the status of the
void SetDisplayPower(chromeos::DisplayPowerState power_state, int flags); // operation.
void SetDisplayPower(chromeos::DisplayPowerState power_state,
int flags,
const ConfigurationCallback& callback);
// Force switching the display mode to |new_state|. Returns false if // Force switching the display mode to |new_state|. Returns false if
// switching failed (possibly because |new_state| is invalid for the // switching failed (possibly because |new_state| is invalid for the
...@@ -334,6 +339,13 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { ...@@ -334,6 +339,13 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
// otherwise. // otherwise.
bool ShouldRunConfigurationTask() const; bool ShouldRunConfigurationTask() const;
// Helper functions which will call the callbacks in
// |in_progress_configuration_callbacks_| and
// |queued_configuration_callbacks_| and clear the lists after. |success| is
// the configuration status used when calling the callbacks.
void CallAndClearInProgressCallbacks(bool success);
void CallAndClearQueuedCallbacks(bool success);
StateController* state_controller_; StateController* state_controller_;
SoftwareMirroringController* mirroring_controller_; SoftwareMirroringController* mirroring_controller_;
scoped_ptr<NativeDisplayDelegate> native_display_delegate_; scoped_ptr<NativeDisplayDelegate> native_display_delegate_;
...@@ -367,6 +379,15 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver { ...@@ -367,6 +379,15 @@ class DISPLAY_EXPORT DisplayConfigurator : public NativeDisplayObserver {
// Bitwise-or value of the |kSetDisplayPower*| flags defined above. // Bitwise-or value of the |kSetDisplayPower*| flags defined above.
int requested_power_flags_; int requested_power_flags_;
// List of callbacks from callers waiting for the display configuration to
// start/finish. Note these callbacks belong to the pending request, not a
// request currently active.
std::vector<ConfigurationCallback> queued_configuration_callbacks_;
// List of callbacks belonging to the currently running display configuration
// task.
std::vector<ConfigurationCallback> in_progress_configuration_callbacks_;
// True if the caller wants to force the display configuration process. // True if the caller wants to force the display configuration process.
bool force_configure_; bool force_configure_;
......
...@@ -113,11 +113,18 @@ class TestMirroringController ...@@ -113,11 +113,18 @@ class TestMirroringController
class DisplayConfiguratorTest : public testing::Test { class DisplayConfiguratorTest : public testing::Test {
public: public:
enum CallbackResult {
CALLBACK_FAILURE,
CALLBACK_SUCCESS,
CALLBACK_NOT_CALLED,
};
DisplayConfiguratorTest() DisplayConfiguratorTest()
: small_mode_(gfx::Size(1366, 768), false, 60.0f), : small_mode_(gfx::Size(1366, 768), false, 60.0f),
big_mode_(gfx::Size(2560, 1600), false, 60.0f), big_mode_(gfx::Size(2560, 1600), false, 60.0f),
observer_(&configurator_), observer_(&configurator_),
test_api_(&configurator_) {} test_api_(&configurator_),
callback_result_(CALLBACK_NOT_CALLED) {}
~DisplayConfiguratorTest() override {} ~DisplayConfiguratorTest() override {}
void SetUp() override { void SetUp() override {
...@@ -153,6 +160,10 @@ class DisplayConfiguratorTest : public testing::Test { ...@@ -153,6 +160,10 @@ class DisplayConfiguratorTest : public testing::Test {
UpdateOutputs(2, false); UpdateOutputs(2, false);
} }
void OnConfiguredCallback(bool status) {
callback_result_ = (status ? CALLBACK_SUCCESS : CALLBACK_FAILURE);
}
// Predefined modes that can be used by outputs. // Predefined modes that can be used by outputs.
const DisplayMode small_mode_; const DisplayMode small_mode_;
const DisplayMode big_mode_; const DisplayMode big_mode_;
...@@ -192,6 +203,12 @@ class DisplayConfiguratorTest : public testing::Test { ...@@ -192,6 +203,12 @@ class DisplayConfiguratorTest : public testing::Test {
log_->GetActionsAndClear()); log_->GetActionsAndClear());
} }
CallbackResult PopCallbackResult() {
CallbackResult result = callback_result_;
callback_result_ = CALLBACK_NOT_CALLED;
return result;
}
base::MessageLoop message_loop_; base::MessageLoop message_loop_;
TestStateController state_controller_; TestStateController state_controller_;
TestMirroringController mirroring_controller_; TestMirroringController mirroring_controller_;
...@@ -203,6 +220,8 @@ class DisplayConfiguratorTest : public testing::Test { ...@@ -203,6 +220,8 @@ class DisplayConfiguratorTest : public testing::Test {
TestDisplaySnapshot outputs_[2]; TestDisplaySnapshot outputs_[2];
CallbackResult callback_result_;
private: private:
DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest); DISALLOW_COPY_AND_ASSIGN(DisplayConfiguratorTest);
}; };
...@@ -429,7 +448,10 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { ...@@ -429,7 +448,10 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
observer_.Reset(); observer_.Reset();
configurator_.SetDisplayPower( configurator_.SetDisplayPower(
chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags); DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ( EXPECT_EQ(
JoinActions( JoinActions(
kGrab, kGrab,
...@@ -447,8 +469,12 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { ...@@ -447,8 +469,12 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
// When all displays are turned off, the framebuffer should switch back // When all displays are turned off, the framebuffer should switch back
// to the mirrored size. // to the mirrored size.
observer_.Reset(); observer_.Reset();
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_OFF,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ( EXPECT_EQ(
JoinActions(kGrab, JoinActions(kGrab,
GetFramebufferAction( GetFramebufferAction(
...@@ -464,8 +490,12 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { ...@@ -464,8 +490,12 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
// Turn all displays on and check that mirroring is still used. // Turn all displays on and check that mirroring is still used.
observer_.Reset(); observer_.Reset();
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ( EXPECT_EQ(
JoinActions( JoinActions(
kGrab, kGrab,
...@@ -515,7 +545,10 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { ...@@ -515,7 +545,10 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
observer_.Reset(); observer_.Reset();
configurator_.SetDisplayPower( configurator_.SetDisplayPower(
chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags); DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ( EXPECT_EQ(
JoinActions( JoinActions(
kGrab, kGrab,
...@@ -534,8 +567,12 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { ...@@ -534,8 +567,12 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
// When all displays are turned off, the framebuffer should switch back // When all displays are turned off, the framebuffer should switch back
// to the extended + software mirroring. // to the extended + software mirroring.
observer_.Reset(); observer_.Reset();
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_OFF,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ( EXPECT_EQ(
JoinActions( JoinActions(
kGrab, kGrab,
...@@ -559,8 +596,12 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) { ...@@ -559,8 +596,12 @@ TEST_F(DisplayConfiguratorTest, SetDisplayPower) {
// Turn all displays on and check that mirroring is still used. // Turn all displays on and check that mirroring is still used.
observer_.Reset(); observer_.Reset();
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ( EXPECT_EQ(
JoinActions( JoinActions(
kGrab, kGrab,
...@@ -606,8 +647,12 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) { ...@@ -606,8 +647,12 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
// Now turn the display off before suspending and check that the // Now turn the display off before suspending and check that the
// configurator turns it back on and syncs with the server. // configurator turns it back on and syncs with the server.
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_OFF,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ( EXPECT_EQ(
JoinActions( JoinActions(
kGrab, kGrab,
...@@ -656,8 +701,12 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) { ...@@ -656,8 +701,12 @@ TEST_F(DisplayConfiguratorTest, SuspendAndResume) {
NULL), NULL),
log_->GetActionsAndClear()); log_->GetActionsAndClear());
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_OFF,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ( EXPECT_EQ(
JoinActions(kGrab, JoinActions(kGrab,
GetFramebufferAction( GetFramebufferAction(
...@@ -698,11 +747,19 @@ TEST_F(DisplayConfiguratorTest, Headless) { ...@@ -698,11 +747,19 @@ TEST_F(DisplayConfiguratorTest, Headless) {
// Not much should happen when the display power state is changed while // Not much should happen when the display power state is changed while
// no displays are connected. // no displays are connected.
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_OFF, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_OFF,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear()); EXPECT_EQ(JoinActions(kGrab, kUngrab, NULL), log_->GetActionsAndClear());
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL), EXPECT_EQ(JoinActions(kGrab, kForceDPMS, kUngrab, NULL),
log_->GetActionsAndClear()); log_->GetActionsAndClear());
...@@ -1071,7 +1128,10 @@ TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) { ...@@ -1071,7 +1128,10 @@ TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) {
// Turn off the internal display, simulating docked mode. // Turn off the internal display, simulating docked mode.
configurator_.SetDisplayPower( configurator_.SetDisplayPower(
chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags); DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ(1, observer_.num_changes()); EXPECT_EQ(1, observer_.num_changes());
EXPECT_EQ(0, observer_.num_failures()); EXPECT_EQ(0, observer_.num_failures());
log_->GetActionsAndClear(); log_->GetActionsAndClear();
...@@ -1079,8 +1139,12 @@ TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) { ...@@ -1079,8 +1139,12 @@ TEST_F(DisplayConfiguratorTest, SaveDisplayPowerStateOnConfigFailure) {
// Make all subsequent configuration requests fail and try to turn the // Make all subsequent configuration requests fail and try to turn the
// internal display back on. // internal display back on.
native_display_delegate_->set_max_configurable_pixels(1); native_display_delegate_->set_max_configurable_pixels(1);
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_FAILURE, PopCallbackResult());
EXPECT_EQ(1, observer_.num_changes()); EXPECT_EQ(1, observer_.num_changes());
EXPECT_EQ(1, observer_.num_failures()); EXPECT_EQ(1, observer_.num_failures());
log_->GetActionsAndClear(); log_->GetActionsAndClear();
...@@ -1112,7 +1176,10 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) { ...@@ -1112,7 +1176,10 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) {
// Turn off the internal display, simulating docked mode. // Turn off the internal display, simulating docked mode.
configurator_.SetDisplayPower( configurator_.SetDisplayPower(
chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON, chromeos::DISPLAY_POWER_INTERNAL_OFF_EXTERNAL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags); DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ(1, observer_.num_changes()); EXPECT_EQ(1, observer_.num_changes());
EXPECT_EQ(0, observer_.num_failures()); EXPECT_EQ(0, observer_.num_failures());
EXPECT_EQ( EXPECT_EQ(
...@@ -1133,8 +1200,12 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) { ...@@ -1133,8 +1200,12 @@ TEST_F(DisplayConfiguratorTest, DontRestoreStalePowerStateAfterResume) {
configurator_.ResumeDisplays(); configurator_.ResumeDisplays();
// Before the task runs, exit docked mode. // Before the task runs, exit docked mode.
configurator_.SetDisplayPower(chromeos::DISPLAY_POWER_ALL_ON, configurator_.SetDisplayPower(
DisplayConfigurator::kSetDisplayPowerNoFlags); chromeos::DISPLAY_POWER_ALL_ON,
DisplayConfigurator::kSetDisplayPowerNoFlags,
base::Bind(&DisplayConfiguratorTest::OnConfiguredCallback,
base::Unretained(this)));
EXPECT_EQ(CALLBACK_SUCCESS, PopCallbackResult());
EXPECT_EQ(2, observer_.num_changes()); EXPECT_EQ(2, observer_.num_changes());
EXPECT_EQ(0, observer_.num_failures()); EXPECT_EQ(0, observer_.num_failures());
EXPECT_EQ( EXPECT_EQ(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment