| OLD | NEW |
| 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/material_design/material_design_controller.h" | |
| 7 #include "ash/common/system/date/date_default_view.h" | 6 #include "ash/common/system/date/date_default_view.h" |
| 8 #include "ash/common/system/date/date_view.h" | 7 #include "ash/common/system/date/date_view.h" |
| 9 #include "ash/common/system/date/system_info_default_view.h" | 8 #include "ash/common/system/date/system_info_default_view.h" |
| 10 #include "ash/common/system/date/tray_system_info.h" | 9 #include "ash/common/system/date/tray_system_info.h" |
| 11 #include "ash/common/system/tray/system_tray.h" | 10 #include "ash/common/system/tray/system_tray.h" |
| 12 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 13 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 14 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 15 #include "base/location.h" | 14 #include "base/location.h" |
| 16 #include "base/macros.h" | 15 #include "base/macros.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 run_loop.Run(); | 69 run_loop.Run(); |
| 71 } | 70 } |
| 72 | 71 |
| 73 static bool SystemClockShouldUse24Hour() { | 72 static bool SystemClockShouldUse24Hour() { |
| 74 return g_browser_process->platform_part() | 73 return g_browser_process->platform_part() |
| 75 ->GetSystemClock() | 74 ->GetSystemClock() |
| 76 ->ShouldUse24HourClock(); | 75 ->ShouldUse24HourClock(); |
| 77 } | 76 } |
| 78 | 77 |
| 79 static base::HourClockType TestGetPrimarySystemTrayTimeHourType() { | 78 static base::HourClockType TestGetPrimarySystemTrayTimeHourType() { |
| 80 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { | 79 const ash::TraySystemInfo* tray_system_info = |
| 81 const ash::TraySystemInfo* tray_system_info = | 80 ash::Shell::GetInstance() |
| 82 ash::Shell::GetInstance() | 81 ->GetPrimarySystemTray() |
| 83 ->GetPrimarySystemTray() | 82 ->GetTraySystemInfoForTesting(); |
| 84 ->GetTraySystemInfoForTesting(); | 83 const ash::tray::TimeView* time_tray = |
| 85 const ash::tray::TimeView* time_tray = | 84 tray_system_info->GetTimeTrayForTesting(); |
| 86 tray_system_info->GetTimeTrayForTesting(); | |
| 87 | |
| 88 return time_tray->GetHourTypeForTesting(); | |
| 89 } | |
| 90 | |
| 91 const ash::TrayDate* tray_date = ash::Shell::GetInstance() | |
| 92 ->GetPrimarySystemTray() | |
| 93 ->GetTrayDateForTesting(); | |
| 94 const ash::tray::TimeView* time_tray = tray_date->GetTimeTrayForTesting(); | |
| 95 | 85 |
| 96 return time_tray->GetHourTypeForTesting(); | 86 return time_tray->GetHourTypeForTesting(); |
| 97 } | 87 } |
| 98 | 88 |
| 99 static bool TestPrimarySystemTrayHasDateDefaultView() { | 89 static bool TestPrimarySystemTrayHasDateDefaultView() { |
| 100 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { | 90 const ash::TraySystemInfo* tray_system_info = |
| 101 const ash::TraySystemInfo* tray_system_info = | 91 ash::Shell::GetInstance() |
| 102 ash::Shell::GetInstance() | 92 ->GetPrimarySystemTray() |
| 103 ->GetPrimarySystemTray() | 93 ->GetTraySystemInfoForTesting(); |
| 104 ->GetTraySystemInfoForTesting(); | 94 const ash::SystemInfoDefaultView* system_info_default_view = |
| 105 const ash::SystemInfoDefaultView* system_info_default_view = | 95 tray_system_info->GetDefaultViewForTesting(); |
| 106 tray_system_info->GetDefaultViewForTesting(); | 96 return system_info_default_view != nullptr; |
| 107 return system_info_default_view != nullptr; | |
| 108 } | |
| 109 | |
| 110 const ash::TrayDate* tray_date = ash::Shell::GetInstance() | |
| 111 ->GetPrimarySystemTray() | |
| 112 ->GetTrayDateForTesting(); | |
| 113 const ash::DateDefaultView* date_default_view = | |
| 114 tray_date->GetDefaultViewForTesting(); | |
| 115 return date_default_view != nullptr; | |
| 116 } | 97 } |
| 117 | 98 |
| 118 static void TestPrimarySystemTrayCreateDefaultView() { | 99 static void TestPrimarySystemTrayCreateDefaultView() { |
| 119 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { | 100 ash::TraySystemInfo* tray_system_info = ash::Shell::GetInstance() |
| 120 ash::TraySystemInfo* tray_system_info = | 101 ->GetPrimarySystemTray() |
| 121 ash::Shell::GetInstance() | 102 ->GetTraySystemInfoForTesting(); |
| 122 ->GetPrimarySystemTray() | 103 tray_system_info->CreateDefaultViewForTesting( |
| 123 ->GetTraySystemInfoForTesting(); | 104 ash::LoginStatus::NOT_LOGGED_IN); |
| 124 tray_system_info->CreateDefaultViewForTesting( | |
| 125 ash::LoginStatus::NOT_LOGGED_IN); | |
| 126 } else { | |
| 127 ash::TrayDate* tray_date = ash::Shell::GetInstance() | |
| 128 ->GetPrimarySystemTray() | |
| 129 ->GetTrayDateForTesting(); | |
| 130 tray_date->CreateDefaultViewForTesting(ash::LoginStatus::NOT_LOGGED_IN); | |
| 131 } | |
| 132 } | 105 } |
| 133 | 106 |
| 134 static base::HourClockType TestGetPrimarySystemTrayDateHourType() { | 107 static base::HourClockType TestGetPrimarySystemTrayDateHourType() { |
| 135 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { | 108 const ash::TraySystemInfo* tray_system_info = |
| 136 const ash::TraySystemInfo* tray_system_info = | 109 ash::Shell::GetInstance() |
| 137 ash::Shell::GetInstance() | 110 ->GetPrimarySystemTray() |
| 138 ->GetPrimarySystemTray() | 111 ->GetTraySystemInfoForTesting(); |
| 139 ->GetTraySystemInfoForTesting(); | 112 const ash::SystemInfoDefaultView* system_info_default_view = |
| 140 const ash::SystemInfoDefaultView* system_info_default_view = | 113 tray_system_info->GetDefaultViewForTesting(); |
| 141 tray_system_info->GetDefaultViewForTesting(); | |
| 142 | 114 |
| 143 return system_info_default_view->GetDateView()->GetHourTypeForTesting(); | 115 return system_info_default_view->GetDateView()->GetHourTypeForTesting(); |
| 144 } | |
| 145 | |
| 146 const ash::TrayDate* tray_date = ash::Shell::GetInstance() | |
| 147 ->GetPrimarySystemTray() | |
| 148 ->GetTrayDateForTesting(); | |
| 149 const ash::DateDefaultView* date_default_view = | |
| 150 tray_date->GetDefaultViewForTesting(); | |
| 151 | |
| 152 return date_default_view->GetDateView()->GetHourTypeForTesting(); | |
| 153 } | 116 } |
| 154 | 117 |
| 155 private: | 118 private: |
| 156 DISALLOW_COPY_AND_ASSIGN(SystemUse24HourClockPolicyTest); | 119 DISALLOW_COPY_AND_ASSIGN(SystemUse24HourClockPolicyTest); |
| 157 }; | 120 }; |
| 158 | 121 |
| 159 IN_PROC_BROWSER_TEST_F(SystemUse24HourClockPolicyTest, CheckUnset) { | 122 IN_PROC_BROWSER_TEST_F(SystemUse24HourClockPolicyTest, CheckUnset) { |
| 160 bool system_use_24hour_clock; | 123 bool system_use_24hour_clock; |
| 161 EXPECT_FALSE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock, | 124 EXPECT_FALSE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock, |
| 162 &system_use_24hour_clock)); | 125 &system_use_24hour_clock)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 EXPECT_TRUE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock, | 177 EXPECT_TRUE(CrosSettings::Get()->GetBoolean(kSystemUse24HourClock, |
| 215 &system_use_24hour_clock)); | 178 &system_use_24hour_clock)); |
| 216 EXPECT_FALSE(system_use_24hour_clock); | 179 EXPECT_FALSE(system_use_24hour_clock); |
| 217 EXPECT_FALSE(SystemClockShouldUse24Hour()); | 180 EXPECT_FALSE(SystemClockShouldUse24Hour()); |
| 218 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType()); | 181 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayTimeHourType()); |
| 219 EXPECT_TRUE(TestPrimarySystemTrayHasDateDefaultView()); | 182 EXPECT_TRUE(TestPrimarySystemTrayHasDateDefaultView()); |
| 220 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType()); | 183 EXPECT_EQ(base::k12HourClock, TestGetPrimarySystemTrayDateHourType()); |
| 221 } | 184 } |
| 222 | 185 |
| 223 } // namespace chromeos | 186 } // namespace chromeos |
| OLD | NEW |