| 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 "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/common/material_design/material_design_controller.h" | |
| 10 #include "ash/common/system/date/date_default_view.h" | 9 #include "ash/common/system/date/date_default_view.h" |
| 11 #include "ash/common/system/date/date_view.h" | 10 #include "ash/common/system/date/date_view.h" |
| 12 #include "ash/common/system/date/system_info_default_view.h" | 11 #include "ash/common/system/date/system_info_default_view.h" |
| 13 #include "ash/common/system/date/tray_date.h" | 12 #include "ash/common/system/date/tray_date.h" |
| 14 #include "ash/common/system/date/tray_system_info.h" | 13 #include "ash/common/system/date/tray_system_info.h" |
| 15 #include "ash/common/system/tray/system_tray.h" | 14 #include "ash/common/system/tray/system_tray.h" |
| 16 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 17 #include "base/macros.h" | 16 #include "base/macros.h" |
| 18 #include "chrome/browser/chromeos/login/login_manager_test.h" | 17 #include "chrome/browser/chromeos/login/login_manager_test.h" |
| 19 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 18 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 | 30 |
| 32 namespace { | 31 namespace { |
| 33 | 32 |
| 34 // Because policy is not needed this test it is better to use e-mails that | 33 // Because policy is not needed this test it is better to use e-mails that |
| 35 // are definitely not enterprise. This lets us to avoid faking of policy fetch | 34 // are definitely not enterprise. This lets us to avoid faking of policy fetch |
| 36 // procedure. | 35 // procedure. |
| 37 const char kUser1[] = "user1@gmail.com"; | 36 const char kUser1[] = "user1@gmail.com"; |
| 38 const char kUser2[] = "user2@gmail.com"; | 37 const char kUser2[] = "user2@gmail.com"; |
| 39 | 38 |
| 40 base::HourClockType GetHourType() { | 39 base::HourClockType GetHourType() { |
| 41 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { | 40 const ash::TraySystemInfo* tray_system_info = |
| 42 const ash::TraySystemInfo* tray_system_info = | 41 ash::Shell::GetInstance() |
| 43 ash::Shell::GetInstance() | 42 ->GetPrimarySystemTray() |
| 44 ->GetPrimarySystemTray() | 43 ->GetTraySystemInfoForTesting(); |
| 45 ->GetTraySystemInfoForTesting(); | 44 const ash::SystemInfoDefaultView* system_info_default_view = |
| 46 const ash::SystemInfoDefaultView* system_info_default_view = | 45 tray_system_info->GetDefaultViewForTesting(); |
| 47 tray_system_info->GetDefaultViewForTesting(); | |
| 48 | 46 |
| 49 return system_info_default_view->GetDateView()->GetHourTypeForTesting(); | 47 return system_info_default_view->GetDateView()->GetHourTypeForTesting(); |
| 50 } | |
| 51 | |
| 52 const ash::TrayDate* tray_date = ash::Shell::GetInstance() | |
| 53 ->GetPrimarySystemTray() | |
| 54 ->GetTrayDateForTesting(); | |
| 55 const ash::DateDefaultView* date_default_view = | |
| 56 tray_date->GetDefaultViewForTesting(); | |
| 57 | |
| 58 return date_default_view->GetDateView()->GetHourTypeForTesting(); | |
| 59 } | 48 } |
| 60 | 49 |
| 61 void CreateDefaultView() { | 50 void CreateDefaultView() { |
| 62 if (ash::MaterialDesignController::IsSystemTrayMenuMaterial()) { | 51 ash::TraySystemInfo* tray_system_info = ash::Shell::GetInstance() |
| 63 ash::TraySystemInfo* tray_system_info = ash::Shell::GetInstance() | 52 ->GetPrimarySystemTray() |
| 64 ->GetPrimarySystemTray() | 53 ->GetTraySystemInfoForTesting(); |
| 65 ->GetTraySystemInfoForTesting(); | 54 tray_system_info->CreateDefaultViewForTesting( |
| 66 tray_system_info->CreateDefaultViewForTesting( | 55 ash::LoginStatus::NOT_LOGGED_IN); |
| 67 ash::LoginStatus::NOT_LOGGED_IN); | |
| 68 } else { | |
| 69 ash::TrayDate* tray_date = ash::Shell::GetInstance() | |
| 70 ->GetPrimarySystemTray() | |
| 71 ->GetTrayDateForTesting(); | |
| 72 tray_date->CreateDefaultViewForTesting(ash::LoginStatus::NOT_LOGGED_IN); | |
| 73 } | |
| 74 } | 56 } |
| 75 | 57 |
| 76 } // namespace | 58 } // namespace |
| 77 | 59 |
| 78 class SystemTrayDelegateChromeOSTest : public LoginManagerTest { | 60 class SystemTrayDelegateChromeOSTest : public LoginManagerTest { |
| 79 protected: | 61 protected: |
| 80 SystemTrayDelegateChromeOSTest() | 62 SystemTrayDelegateChromeOSTest() |
| 81 : LoginManagerTest(false /* should_launch_browser */), | 63 : LoginManagerTest(false /* should_launch_browser */), |
| 82 account_id1_(AccountId::FromUserEmail(kUser1)), | 64 account_id1_(AccountId::FromUserEmail(kUser1)), |
| 83 account_id2_(AccountId::FromUserEmail(kUser2)) {} | 65 account_id2_(AccountId::FromUserEmail(kUser2)) {} |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 EXPECT_EQ(base::k12HourClock, GetHourType()); | 105 EXPECT_EQ(base::k12HourClock, GetHourType()); |
| 124 | 106 |
| 125 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); | 107 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); |
| 126 // Allow clock setting to be sent to ash over mojo. | 108 // Allow clock setting to be sent to ash over mojo. |
| 127 content::RunAllPendingInMessageLoop(); | 109 content::RunAllPendingInMessageLoop(); |
| 128 CreateDefaultView(); | 110 CreateDefaultView(); |
| 129 EXPECT_EQ(base::k24HourClock, GetHourType()); | 111 EXPECT_EQ(base::k24HourClock, GetHourType()); |
| 130 } | 112 } |
| 131 | 113 |
| 132 } // namespace chromeos | 114 } // namespace chromeos |
| OLD | NEW |