Commit b0d1929b authored by wutao's avatar wutao Committed by Commit Bot

ambient: Make the ambient mode pref default off

Bug: b/164190937
Test: manual
Change-Id: I8b2f4bf1ec90cb1869add3f1f71c8b96175589a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2382214
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802861}
parent 7493fb31
......@@ -161,7 +161,7 @@ void AmbientController::RegisterProfilePrefs(PrefRegistrySimple* registry) {
// Do not sync across devices to allow different usages for different
// devices.
registry->RegisterBooleanPref(ash::ambient::prefs::kAmbientModeEnabled,
true);
false);
// Used to upload usage metrics. Derived from |AmbientSettings| when
// settings are successfully saved by the user. This pref is not displayed
......
......@@ -54,6 +54,28 @@ TEST_F(AmbientControllerTest, ShowAmbientScreenUponLock) {
EXPECT_FALSE(ambient_controller()->IsShown());
}
TEST_F(AmbientControllerTest, NotShowAmbientWhenPrefNotEnabled) {
SetAmbientModeEnabled(false);
LockScreen();
// Lockscreen will not immediately show Ambient mode.
EXPECT_FALSE(ambient_controller()->IsShown());
// Ambient mode will not show after inacivity and successfully loading first
// image.
FastForwardToInactivity();
FastForwardToNextImage();
EXPECT_FALSE(container_view());
EXPECT_EQ(AmbientUiModel::Get()->ui_visibility(),
AmbientUiVisibility::kClosed);
EXPECT_FALSE(ambient_controller()->IsShown());
// Clean up.
UnlockScreen();
EXPECT_FALSE(ambient_controller()->IsShown());
}
TEST_F(AmbientControllerTest, HideAmbientScreen) {
LockScreen();
FastForwardToInactivity();
......@@ -109,6 +131,18 @@ TEST_F(AmbientControllerTest, ShouldRequestAccessTokenWhenLockingScreen) {
EXPECT_FALSE(IsAccessTokenRequestPending());
}
TEST_F(AmbientControllerTest, ShouldNotRequestAccessTokenWhenPrefNotEnabled) {
SetAmbientModeEnabled(false);
EXPECT_FALSE(IsAccessTokenRequestPending());
// Lock the screen will not request a token.
LockScreen();
EXPECT_FALSE(IsAccessTokenRequestPending());
UnlockScreen();
EXPECT_FALSE(IsAccessTokenRequestPending());
}
TEST_F(AmbientControllerTest, ShouldReturnCachedAccessToken) {
EXPECT_FALSE(IsAccessTokenRequestPending());
......
......@@ -16,7 +16,9 @@
#include "ash/ambient/ui/media_string_view.h"
#include "ash/ambient/ui/photo_view.h"
#include "ash/assistant/ui/assistant_view_ids.h"
#include "ash/public/cpp/ambient/ambient_prefs.h"
#include "ash/public/cpp/ambient/fake_ambient_backend_controller_impl.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "base/callback.h"
#include "base/memory/ptr_util.h"
......@@ -118,6 +120,7 @@ void AmbientAshTestBase::SetUp() {
std::make_unique<TestAmbientImageDecoderImpl>());
token_controller()->SetTokenUsageBufferForTesting(
base::TimeDelta::FromSeconds(30));
SetAmbientModeEnabled(true);
base::RunLoop().RunUntilIdle();
}
......@@ -128,6 +131,11 @@ void AmbientAshTestBase::TearDown() {
AshTestBase::TearDown();
}
void AmbientAshTestBase::SetAmbientModeEnabled(bool enabled) {
Shell::Get()->session_controller()->GetPrimaryUserPrefService()->SetBoolean(
ambient::prefs::kAmbientModeEnabled, enabled);
}
void AmbientAshTestBase::ShowAmbientScreen() {
// The widget will be destroyed in |AshTestBase::TearDown()|.
ambient_controller()->ShowUi(AmbientUiMode::kInSessionUi);
......
......@@ -36,6 +36,9 @@ class AmbientAshTestBase : public AshTestBase {
void SetUp() override;
void TearDown() override;
// Enables/disables ambient mode.
void SetAmbientModeEnabled(bool enabled);
// Creates ambient screen in its own widget.
void ShowAmbientScreen();
......
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