diff --git a/ash/ambient/ambient_controller.cc b/ash/ambient/ambient_controller.cc index 398a7a0f992845..4887ca2ca9ae6f 100644 --- a/ash/ambient/ambient_controller.cc +++ b/ash/ambient/ambient_controller.cc @@ -300,6 +300,9 @@ void AmbientController::OnPowerStatusChanged() { void AmbientController::ScreenBrightnessChanged( const power_manager::BacklightBrightnessChange& change) { + DVLOG(1) << "ScreenBrightnessChanged: " + << (change.has_percent() ? change.percent() : -1); + if (!change.has_percent()) return; @@ -307,6 +310,8 @@ void AmbientController::ScreenBrightnessChanged( if (change.percent() < kMinBrightness) { if (is_screen_off_) return; + + DVLOG(1) << "Screen is off, close ambient mode."; is_screen_off_ = true; // If screen is off, turn everything off. This covers: // 1. Manually turn screen off. @@ -332,9 +337,16 @@ void AmbientController::ScreenBrightnessChanged( void AmbientController::ScreenIdleStateChanged( const power_manager::ScreenIdleState& idle_state) { + DVLOG(1) << "ScreenIdleStateChanged: dimmed(" << idle_state.dimmed() + << ") off(" << idle_state.off() << ")"; + if (!IsAmbientModeEnabled()) return; + // "off" state should already be handled by the screen brightness handler. + if (idle_state.off()) + return; + if (!idle_state.dimmed()) return; @@ -361,6 +373,8 @@ void AmbientController::RemoveAmbientViewDelegateObserver( } void AmbientController::ShowUi(AmbientUiMode mode) { + DVLOG(1) << "ShowUi: " << mode; + // TODO(meilinw): move the eligibility check to the idle entry point once // implemented: b/149246117. if (!IsAmbientModeEnabled()) { diff --git a/ash/ambient/ambient_controller_unittest.cc b/ash/ambient/ambient_controller_unittest.cc index 5b4c0568f000f6..d679fdd6994518 100644 --- a/ash/ambient/ambient_controller_unittest.cc +++ b/ash/ambient/ambient_controller_unittest.cc @@ -352,11 +352,13 @@ TEST_F(AmbientControllerTest, ShouldHideAmbientScreenWhenDisplayIsOff) { // Should dismiss ambient mode screen. SetScreenBrightnessAndWait(/*percent=*/0); SetScreenIdleStateAndWait(/*dimmed=*/true, /*off=*/true); + FastForwardToNextImage(); EXPECT_FALSE(ambient_controller()->IsShown()); // Screen back on again, should not have ambient screen. SetScreenBrightnessAndWait(/*percent=*/50); SetScreenIdleStateAndWait(/*dimmed=*/false, /*off=*/false); + FastForwardToNextImage(); EXPECT_FALSE(ambient_controller()->IsShown()); } @@ -378,6 +380,8 @@ TEST_F(AmbientControllerTest, // Should dismiss ambient mode screen. SetScreenBrightnessAndWait(/*percent=*/0); SetScreenIdleStateAndWait(/*dimmed=*/true, /*off=*/true); + FastForwardToInactivity(); + FastForwardToNextImage(); EXPECT_FALSE(ambient_controller()->IsShown()); // Screen back on again, should not have ambient screen, but still has lock diff --git a/ash/public/cpp/ambient/ambient_ui_model.cc b/ash/public/cpp/ambient/ambient_ui_model.cc index 11120a19321708..deb56380aa2e01 100644 --- a/ash/public/cpp/ambient/ambient_ui_model.cc +++ b/ash/public/cpp/ambient/ambient_ui_model.cc @@ -56,4 +56,16 @@ void AmbientUiModel::NotifyAmbientUiVisibilityChanged() { observer.OnAmbientUiVisibilityChanged(ui_visibility_); } +std::ostream& operator<<(std::ostream& out, AmbientUiMode mode) { + switch (mode) { + case AmbientUiMode::kLockScreenUi: + out << "kLockScreenUi"; + break; + case AmbientUiMode::kInSessionUi: + out << "kInSessionUi"; + break; + } + return out; +} + } // namespace ash diff --git a/ash/public/cpp/ambient/ambient_ui_model.h b/ash/public/cpp/ambient/ambient_ui_model.h index a97a5847b26b11..a2837a7fb426e7 100644 --- a/ash/public/cpp/ambient/ambient_ui_model.h +++ b/ash/public/cpp/ambient/ambient_ui_model.h @@ -65,6 +65,9 @@ class ASH_PUBLIC_EXPORT AmbientUiModel { base::ObserverList observers_; }; +ASH_PUBLIC_EXPORT std::ostream& operator<<(std::ostream& out, + AmbientUiMode mode); + } // namespace ash #endif // ASH_PUBLIC_CPP_AMBIENT_AMBIENT_UI_MODEL_H_