Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: ash/system/night_light/night_light_controller_unittest.cc

Issue 2921973002: Hide Night Light behind a flag (Closed)
Patch Set: James' comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/night_light/night_light_controller.h" 5 #include "ash/system/night_light/night_light_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 9
10 #include "ash/ash_switches.h"
10 #include "ash/public/cpp/ash_pref_names.h" 11 #include "ash/public/cpp/ash_pref_names.h"
11 #include "ash/public/cpp/config.h" 12 #include "ash/public/cpp/config.h"
12 #include "ash/public/cpp/session_types.h" 13 #include "ash/public/cpp/session_types.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
15 #include "ash/test/ash_test_helper.h" 16 #include "ash/test/ash_test_helper.h"
16 #include "ash/test/test_session_controller_client.h" 17 #include "ash/test/test_session_controller_client.h"
17 #include "ash/test/test_shell_delegate.h" 18 #include "ash/test/test_shell_delegate.h"
19 #include "base/command_line.h"
18 #include "base/macros.h" 20 #include "base/macros.h"
19 #include "components/prefs/testing_pref_service.h" 21 #include "components/prefs/testing_pref_service.h"
20 #include "ui/compositor/layer.h" 22 #include "ui/compositor/layer.h"
21 23
22 namespace ash { 24 namespace ash {
23 25
24 namespace { 26 namespace {
25 27
26 constexpr char kUser1Email[] = "user1@nightlight"; 28 constexpr char kUser1Email[] = "user1@nightlight";
27 constexpr char kUser2Email[] = "user2@nightlight"; 29 constexpr char kUser2Email[] = "user2@nightlight";
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 71
70 TestingPrefServiceSimple* user1_pref_service() { 72 TestingPrefServiceSimple* user1_pref_service() {
71 return &user1_pref_service_; 73 return &user1_pref_service_;
72 } 74 }
73 TestingPrefServiceSimple* user2_pref_service() { 75 TestingPrefServiceSimple* user2_pref_service() {
74 return &user2_pref_service_; 76 return &user2_pref_service_;
75 } 77 }
76 78
77 // ash::test::AshTestBase: 79 // ash::test::AshTestBase:
78 void SetUp() override { 80 void SetUp() override {
81 // Explicitly enable the NightLight feature for the tests.
82 base::CommandLine::ForCurrentProcess()->AppendSwitch(
83 ash::switches::kAshEnableNightLight);
84
79 test::AshTestBase::SetUp(); 85 test::AshTestBase::SetUp();
80 CreateTestUserSessions(); 86 CreateTestUserSessions();
81 Shell::RegisterPrefs(user1_pref_service_.registry()); 87 Shell::RegisterPrefs(user1_pref_service_.registry());
82 Shell::RegisterPrefs(user2_pref_service_.registry()); 88 Shell::RegisterPrefs(user2_pref_service_.registry());
83 89
84 // Simulate user 1 login. 90 // Simulate user 1 login.
85 InjectTestPrefService(&user1_pref_service_); 91 InjectTestPrefService(&user1_pref_service_);
86 SwitchActiveUser(kUser1Email); 92 SwitchActiveUser(kUser1Email);
87 } 93 }
88 94
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 user1_pref_service()->SetDouble(prefs::kNightLightTemperature, temperature2); 247 user1_pref_service()->SetDouble(prefs::kNightLightTemperature, temperature2);
242 EXPECT_EQ(temperature2, controller->GetColorTemperature()); 248 EXPECT_EQ(temperature2, controller->GetColorTemperature());
243 EXPECT_TRUE(TestLayersTemperature(temperature2)); 249 EXPECT_TRUE(TestLayersTemperature(temperature2));
244 user1_pref_service()->SetBoolean(prefs::kNightLightEnabled, false); 250 user1_pref_service()->SetBoolean(prefs::kNightLightEnabled, false);
245 EXPECT_FALSE(controller->GetEnabled()); 251 EXPECT_FALSE(controller->GetEnabled());
246 } 252 }
247 253
248 } // namespace 254 } // namespace
249 255
250 } // namespace ash 256 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/night_light/night_light_controller.cc ('k') | ash/system/night_light/tray_night_light_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698