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

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos_browsertest_chromeos.cc

Issue 2931643002: chromeos: Introduce ash::SystemTrayTestApi (Closed)
Patch Set: review 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 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/shell.h" 9 #include "ash/shell.h"
10 #include "ash/system/date/date_view.h" 10 #include "ash/system/date/date_view.h"
11 #include "ash/system/date/system_info_default_view.h" 11 #include "ash/system/date/system_info_default_view.h"
12 #include "ash/system/date/tray_system_info.h" 12 #include "ash/system/date/tray_system_info.h"
13 #include "ash/system/tray/system_tray.h" 13 #include "ash/system/tray/system_tray.h"
14 #include "ash/system/tray/system_tray_test_api.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "chrome/browser/chromeos/login/login_manager_test.h" 16 #include "chrome/browser/chromeos/login/login_manager_test.h"
16 #include "chrome/browser/chromeos/login/session/user_session_manager.h" 17 #include "chrome/browser/chromeos/login/session/user_session_manager.h"
17 #include "chrome/browser/chromeos/login/startup_utils.h" 18 #include "chrome/browser/chromeos/login/startup_utils.h"
18 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" 19 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
19 #include "chrome/browser/chromeos/profiles/profile_helper.h" 20 #include "chrome/browser/chromeos/profiles/profile_helper.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
22 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
23 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
24 #include "components/user_manager/user_manager.h" 25 #include "components/user_manager/user_manager.h"
25 #include "content/public/test/test_utils.h" 26 #include "content/public/test/test_utils.h"
26 27
27 namespace chromeos { 28 namespace chromeos {
28 29
29 namespace { 30 namespace {
30 31
31 // Because policy is not needed this test it is better to use e-mails that 32 // Because policy is not needed this test it is better to use e-mails that
32 // are definitely not enterprise. This lets us to avoid faking of policy fetch 33 // are definitely not enterprise. This lets us to avoid faking of policy fetch
33 // procedure. 34 // procedure.
34 const char kUser1[] = "user1@gmail.com"; 35 const char kUser1[] = "user1@gmail.com";
35 const char kUser2[] = "user2@gmail.com"; 36 const char kUser2[] = "user2@gmail.com";
36 37
38 ash::TraySystemInfo* GetTraySystemInfo() {
39 return ash::SystemTrayTestApi(ash::Shell::Get()->GetPrimarySystemTray())
40 .tray_system_info();
41 }
42
37 base::HourClockType GetHourType() { 43 base::HourClockType GetHourType() {
38 const ash::TraySystemInfo* tray_system_info =
39 ash::Shell::Get()->GetPrimarySystemTray()->GetTraySystemInfoForTesting();
40 const ash::SystemInfoDefaultView* system_info_default_view = 44 const ash::SystemInfoDefaultView* system_info_default_view =
41 tray_system_info->GetDefaultViewForTesting(); 45 GetTraySystemInfo()->GetDefaultViewForTesting();
42
43 return system_info_default_view->GetDateView()->GetHourTypeForTesting(); 46 return system_info_default_view->GetDateView()->GetHourTypeForTesting();
44 } 47 }
45 48
46 void CreateDefaultView() { 49 void CreateDefaultView() {
47 ash::TraySystemInfo* tray_system_info = 50 GetTraySystemInfo()->CreateDefaultViewForTesting(
48 ash::Shell::Get()->GetPrimarySystemTray()->GetTraySystemInfoForTesting();
49 tray_system_info->CreateDefaultViewForTesting(
50 ash::LoginStatus::NOT_LOGGED_IN); 51 ash::LoginStatus::NOT_LOGGED_IN);
51 } 52 }
52 53
53 } // namespace 54 } // namespace
54 55
55 class SystemTrayDelegateChromeOSTest : public LoginManagerTest { 56 class SystemTrayDelegateChromeOSTest : public LoginManagerTest {
56 protected: 57 protected:
57 SystemTrayDelegateChromeOSTest() 58 SystemTrayDelegateChromeOSTest()
58 : LoginManagerTest(false /* should_launch_browser */), 59 : LoginManagerTest(false /* should_launch_browser */),
59 account_id1_(AccountId::FromUserEmail(kUser1)), 60 account_id1_(AccountId::FromUserEmail(kUser1)),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 EXPECT_EQ(base::k12HourClock, GetHourType()); 101 EXPECT_EQ(base::k12HourClock, GetHourType());
101 102
102 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_); 103 user_manager::UserManager::Get()->SwitchActiveUser(account_id1_);
103 // Allow clock setting to be sent to ash over mojo. 104 // Allow clock setting to be sent to ash over mojo.
104 content::RunAllPendingInMessageLoop(); 105 content::RunAllPendingInMessageLoop();
105 CreateDefaultView(); 106 CreateDefaultView();
106 EXPECT_EQ(base::k24HourClock, GetHourType()); 107 EXPECT_EQ(base::k24HourClock, GetHourType());
107 } 108 }
108 109
109 } // namespace chromeos 110 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698