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

Side by Side Diff: chrome/browser/chromeos/policy/device_system_use_24hour_clock_browsertest.cc

Issue 2381753002: Use mojo SystemTray interfaces for both mash and classic ash (Closed)
Patch Set: rebase again Created 4 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/login_status.h" 5 #include "ash/common/login_status.h"
6 #include "ash/common/system/date/date_default_view.h" 6 #include "ash/common/system/date/date_default_view.h"
7 #include "ash/common/system/date/date_view.h" 7 #include "ash/common/system/date/date_view.h"
8 #include "ash/common/system/tray/system_tray.h"
8 #include "ash/common/wm_shell.h" 9 #include "ash/common/wm_shell.h"
9 #include "ash/shell.h" 10 #include "ash/shell.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/run_loop.h" 14 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/browser_process_platform_part.h"
16 #include "chrome/browser/chromeos/login/ui/login_display_host.h" 19 #include "chrome/browser/chromeos/login/ui/login_display_host.h"
17 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" 20 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h"
18 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 21 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
19 #include "chrome/browser/chromeos/settings/cros_settings.h" 22 #include "chrome/browser/chromeos/settings/cros_settings.h"
23 #include "chrome/browser/chromeos/system/system_clock.h"
20 #include "chrome/browser/lifetime/application_lifetime.h" 24 #include "chrome/browser/lifetime/application_lifetime.h"
21 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
22 #include "chromeos/chromeos_switches.h" 25 #include "chromeos/chromeos_switches.h"
23 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
24 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
25 28
26 namespace em = enterprise_management; 29 namespace em = enterprise_management;
27 30
28 namespace chromeos { 31 namespace chromeos {
29 32
30 class SystemUse24HourClockPolicyTest 33 class SystemUse24HourClockPolicyTest
31 : public policy::DevicePolicyCrosBrowserTest { 34 : public policy::DevicePolicyCrosBrowserTest {
(...skipping 25 matching lines...) Expand all
57 void RefreshPolicyAndWaitDeviceSettingsUpdated() { 60 void RefreshPolicyAndWaitDeviceSettingsUpdated() {
58 base::RunLoop run_loop; 61 base::RunLoop run_loop;
59 std::unique_ptr<CrosSettings::ObserverSubscription> observer = 62 std::unique_ptr<CrosSettings::ObserverSubscription> observer =
60 CrosSettings::Get()->AddSettingsObserver( 63 CrosSettings::Get()->AddSettingsObserver(
61 kSystemUse24HourClock, run_loop.QuitWhenIdleClosure()); 64 kSystemUse24HourClock, run_loop.QuitWhenIdleClosure());
62 65
63 RefreshDevicePolicy(); 66 RefreshDevicePolicy();
64 run_loop.Run(); 67 run_loop.Run();
65 } 68 }
66 69
67 static bool GetSystemTrayDelegateShouldUse24HourClock() { 70 static bool SystemClockShouldUse24Hour() {
68 chromeos::SystemTrayDelegateChromeOS* tray_delegate = 71 return g_browser_process->platform_part()
69 static_cast<chromeos::SystemTrayDelegateChromeOS*>( 72 ->GetSystemClock()
70 ash::WmShell::Get()->system_tray_delegate()); 73 ->ShouldUse24HourClock();
71 return tray_delegate->GetShouldUse24HourClockForTesting();
72 } 74 }
73 75
74 static base::HourClockType TestGetPrimarySystemTrayTimeHourType() { 76 static base::HourClockType TestGetPrimarySystemTrayTimeHourType() {
75 const ash::TrayDate* tray_date = ash::Shell::GetInstance() 77 const ash::TrayDate* tray_date = ash::Shell::GetInstance()
76 ->GetPrimarySystemTray() 78 ->GetPrimarySystemTray()
77 ->GetTrayDateForTesting(); 79 ->GetTrayDateForTesting();
78 const ash::tray::TimeView* time_tray = tray_date->GetTimeTrayForTesting(); 80 const ash::tray::TimeView* time_tray = tray_date->GetTimeTrayForTesting();
79 81
80 return time_tray->GetHourTypeForTesting(); 82 return time_tray->GetHourTypeForTesting();
81 } 83 }
(...skipping 26 matching lines...) Expand all
108 110
109 private: 111 private:
110 DISALLOW_COPY_AND_ASSIGN(SystemUse24HourClockPolicyTest); 112 DISALLOW_COPY_AND_ASSIGN(SystemUse24HourClockPolicyTest);
111 }; 113 };
112 114
113 IN_PROC_BROWSER_TEST_F(SystemUse24HourClockPolicyTest, CheckUnset) { 115 IN_PROC_BROWSER_TEST_F(SystemUse24HourClockPolicyTest, CheckUnset) {
114 bool system_use_24hour_clock; 116 bool system_use_24hour_clock;
115 EXPECT_FALSE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock, 117 EXPECT_FALSE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock,
116 &system_use_24hour_clock)); 118 &system_use_24hour_clock));
117 119
118 EXPECT_FALSE(GetSystemTrayDelegateShouldUse24HourClock()); 120 EXPECT_FALSE(SystemClockShouldUse24Hour());
119 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType()); 121 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType());
120 EXPECT_FALSE(TestPrimarySystemTrayHasDateDefaultView()); 122 EXPECT_FALSE(TestPrimarySystemTrayHasDateDefaultView());
121 123
122 TestPrimarySystemTrayCreateDefaultView(); 124 TestPrimarySystemTrayCreateDefaultView();
123 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType()); 125 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType());
124 } 126 }
125 127
126 IN_PROC_BROWSER_TEST_F(SystemUse24HourClockPolicyTest, CheckTrue) { 128 IN_PROC_BROWSER_TEST_F(SystemUse24HourClockPolicyTest, CheckTrue) {
127 bool system_use_24hour_clock = true; 129 bool system_use_24hour_clock = true;
128 EXPECT_FALSE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock, 130 EXPECT_FALSE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock,
129 &system_use_24hour_clock)); 131 &system_use_24hour_clock));
130 EXPECT_FALSE(TestPrimarySystemTrayHasDateDefaultView()); 132 EXPECT_FALSE(TestPrimarySystemTrayHasDateDefaultView());
131 133
132 EXPECT_FALSE(GetSystemTrayDelegateShouldUse24HourClock()); 134 EXPECT_FALSE(SystemClockShouldUse24Hour());
133 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType()); 135 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType());
134 TestPrimarySystemTrayCreateDefaultView(); 136 TestPrimarySystemTrayCreateDefaultView();
135 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType()); 137 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType());
136 138
137 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); 139 em::ChromeDeviceSettingsProto& proto(device_policy()->payload());
138 proto.mutable_use_24hour_clock()->set_use_24hour_clock(true); 140 proto.mutable_use_24hour_clock()->set_use_24hour_clock(true);
139 RefreshPolicyAndWaitDeviceSettingsUpdated(); 141 RefreshPolicyAndWaitDeviceSettingsUpdated();
140 142
141 system_use_24hour_clock = false; 143 system_use_24hour_clock = false;
142 EXPECT_TRUE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock, 144 EXPECT_TRUE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock,
143 &system_use_24hour_clock)); 145 &system_use_24hour_clock));
144 EXPECT_TRUE(system_use_24hour_clock); 146 EXPECT_TRUE(system_use_24hour_clock);
145 EXPECT_TRUE(GetSystemTrayDelegateShouldUse24HourClock()); 147 EXPECT_TRUE(SystemClockShouldUse24Hour());
146 EXPECT_EQ(base::k24HourClock, TestGetPrimarySystemTrayTimeHourType()); 148 EXPECT_EQ(base::k24HourClock, TestGetPrimarySystemTrayTimeHourType());
147 149
148 EXPECT_TRUE(TestPrimarySystemTrayHasDateDefaultView()); 150 EXPECT_TRUE(TestPrimarySystemTrayHasDateDefaultView());
149 EXPECT_EQ(base::k24HourClock, TestGetPrimarySystemTrayDateHourType()); 151 EXPECT_EQ(base::k24HourClock, TestGetPrimarySystemTrayDateHourType());
150 } 152 }
151 153
152 IN_PROC_BROWSER_TEST_F(SystemUse24HourClockPolicyTest, CheckFalse) { 154 IN_PROC_BROWSER_TEST_F(SystemUse24HourClockPolicyTest, CheckFalse) {
153 bool system_use_24hour_clock = true; 155 bool system_use_24hour_clock = true;
154 EXPECT_FALSE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock, 156 EXPECT_FALSE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock,
155 &system_use_24hour_clock)); 157 &system_use_24hour_clock));
156 EXPECT_FALSE(TestPrimarySystemTrayHasDateDefaultView()); 158 EXPECT_FALSE(TestPrimarySystemTrayHasDateDefaultView());
157 159
158 EXPECT_FALSE(GetSystemTrayDelegateShouldUse24HourClock()); 160 EXPECT_FALSE(SystemClockShouldUse24Hour());
159 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType()); 161 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType());
160 TestPrimarySystemTrayCreateDefaultView(); 162 TestPrimarySystemTrayCreateDefaultView();
161 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType()); 163 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType());
162 164
163 em::ChromeDeviceSettingsProto& proto(device_policy()->payload()); 165 em::ChromeDeviceSettingsProto& proto(device_policy()->payload());
164 proto.mutable_use_24hour_clock()->set_use_24hour_clock(false); 166 proto.mutable_use_24hour_clock()->set_use_24hour_clock(false);
165 RefreshPolicyAndWaitDeviceSettingsUpdated(); 167 RefreshPolicyAndWaitDeviceSettingsUpdated();
166 168
167 system_use_24hour_clock = true; 169 system_use_24hour_clock = true;
168 EXPECT_TRUE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock, 170 EXPECT_TRUE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock,
169 &system_use_24hour_clock)); 171 &system_use_24hour_clock));
170 EXPECT_FALSE(system_use_24hour_clock); 172 EXPECT_FALSE(system_use_24hour_clock);
171 EXPECT_FALSE(GetSystemTrayDelegateShouldUse24HourClock()); 173 EXPECT_FALSE(SystemClockShouldUse24Hour());
172 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType()); 174 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType());
173 EXPECT_TRUE(TestPrimarySystemTrayHasDateDefaultView()); 175 EXPECT_TRUE(TestPrimarySystemTrayHasDateDefaultView());
174 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType()); 176 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType());
175 } 177 }
176 178
177 } // namespace chromeos 179 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_interface_factory.cc ('k') | chrome/browser/ui/ash/chrome_shell_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698