| OLD | NEW |
| 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/tray_night_light.h" | 5 #include "ash/system/night_light/tray_night_light.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" |
| 7 #include "ash/public/cpp/config.h" | 8 #include "ash/public/cpp/config.h" |
| 8 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 9 #include "ash/system/night_light/night_light_controller.h" | 10 #include "ash/system/night_light/night_light_controller.h" |
| 10 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
| 11 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/ash_test_helper.h" | 13 #include "ash/test/ash_test_helper.h" |
| 13 #include "ash/test/test_shell_delegate.h" | 14 #include "ash/test/test_shell_delegate.h" |
| 15 #include "base/command_line.h" |
| 14 #include "base/macros.h" | 16 #include "base/macros.h" |
| 15 #include "components/prefs/testing_pref_service.h" | 17 #include "components/prefs/testing_pref_service.h" |
| 16 | 18 |
| 17 namespace ash { | 19 namespace ash { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 constexpr char kFakeUserEmail[] = "fake_user@nightlight"; | 23 constexpr char kFakeUserEmail[] = "fake_user@nightlight"; |
| 22 | 24 |
| 23 class TrayNightLightTest : public test::AshTestBase { | 25 class TrayNightLightTest : public test::AshTestBase { |
| 24 public: | 26 public: |
| 25 TrayNightLightTest() = default; | 27 TrayNightLightTest() = default; |
| 26 ~TrayNightLightTest() override = default; | 28 ~TrayNightLightTest() override = default; |
| 27 | 29 |
| 28 // ash::test::AshTestBase: | 30 // ash::test::AshTestBase: |
| 29 void SetUp() override { | 31 void SetUp() override { |
| 32 // Explicitly enable the NightLight feature for the tests. |
| 33 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 34 ash::switches::kAshEnableNightLight); |
| 35 |
| 30 test::AshTestBase::SetUp(); | 36 test::AshTestBase::SetUp(); |
| 31 GetSessionControllerClient()->Reset(); | 37 GetSessionControllerClient()->Reset(); |
| 32 GetSessionControllerClient()->AddUserSession(kFakeUserEmail); | 38 GetSessionControllerClient()->AddUserSession(kFakeUserEmail); |
| 33 Shell::RegisterPrefs(pref_service_.registry()); | 39 Shell::RegisterPrefs(pref_service_.registry()); |
| 34 | 40 |
| 35 ash_test_helper()->test_shell_delegate()->set_active_user_pref_service( | 41 ash_test_helper()->test_shell_delegate()->set_active_user_pref_service( |
| 36 &pref_service_); | 42 &pref_service_); |
| 37 GetSessionControllerClient()->SwitchActiveUser( | 43 GetSessionControllerClient()->SwitchActiveUser( |
| 38 AccountId::FromUserEmail(kFakeUserEmail)); | 44 AccountId::FromUserEmail(kFakeUserEmail)); |
| 39 } | 45 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 63 ASSERT_FALSE(controller->GetEnabled()); | 69 ASSERT_FALSE(controller->GetEnabled()); |
| 64 EXPECT_FALSE(tray_night_light->tray_view()->visible()); | 70 EXPECT_FALSE(tray_night_light->tray_view()->visible()); |
| 65 controller->Toggle(); | 71 controller->Toggle(); |
| 66 ASSERT_TRUE(controller->GetEnabled()); | 72 ASSERT_TRUE(controller->GetEnabled()); |
| 67 EXPECT_TRUE(tray_night_light->tray_view()->visible()); | 73 EXPECT_TRUE(tray_night_light->tray_view()->visible()); |
| 68 } | 74 } |
| 69 | 75 |
| 70 } // namespace | 76 } // namespace |
| 71 | 77 |
| 72 } // namespace ash | 78 } // namespace ash |
| OLD | NEW |