OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell.h" | 5 #include "ash/shell.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/chromeos/status/status_area_button.h" | 8 #include "chrome/browser/chromeos/status/status_area_button.h" |
9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
10 #include "chrome/browser/chromeos/system/runtime_environment.h" | 10 #include "chrome/browser/chromeos/system/runtime_environment.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 IN_PROC_BROWSER_TEST_F(StatusAreaHostAuraTest, TextStyle) { | 30 IN_PROC_BROWSER_TEST_F(StatusAreaHostAuraTest, TextStyle) { |
31 ChromeShellDelegate* delegate = static_cast<ChromeShellDelegate*>( | 31 ChromeShellDelegate* delegate = static_cast<ChromeShellDelegate*>( |
32 ash::Shell::GetInstance()->delegate()); | 32 ash::Shell::GetInstance()->delegate()); |
33 StatusAreaHostAura* host = delegate->status_area_host(); | 33 StatusAreaHostAura* host = delegate->status_area_host(); |
34 | 34 |
35 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
36 ASSERT_FALSE(chromeos::UserManager::Get()->IsUserLoggedIn()); | 36 ASSERT_FALSE(chromeos::UserManager::Get()->IsUserLoggedIn()); |
37 if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) { | 37 if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) { |
38 EXPECT_EQ(StatusAreaButton::GRAY_PLAIN_LIGHT, | 38 EXPECT_EQ(StatusAreaButton::GRAY_PLAIN_LIGHT, |
39 host->GetStatusAreaTextStyle()); | 39 host->GetStatusAreaTextStyle()); |
40 EXPECT_EQ(StatusAreaHostAura::GetCompactModeLoginAndLockOffset().ToString(), | |
41 ash::Shell::GetInstance()->compact_status_area_offset(). | |
42 ToString()); | |
43 } else { | 40 } else { |
44 EXPECT_EQ(StatusAreaButton::WHITE_HALOED_BOLD, | 41 EXPECT_EQ(StatusAreaButton::WHITE_HALOED_BOLD, |
45 host->GetStatusAreaTextStyle()); | 42 host->GetStatusAreaTextStyle()); |
46 EXPECT_EQ(StatusAreaHostAura::GetCompactModeBrowserOffset().ToString(), | |
47 ash::Shell::GetInstance()->compact_status_area_offset(). | |
48 ToString()); | |
49 } | 43 } |
50 | 44 |
51 // ProfileManager expects a profile dir to be set on Chrome OS. | 45 // ProfileManager expects a profile dir to be set on Chrome OS. |
52 CommandLine::ForCurrentProcess()->AppendSwitchNative( | 46 CommandLine::ForCurrentProcess()->AppendSwitchNative( |
53 switches::kLoginProfile, "StatusAreaHostAuraTest"); | 47 switches::kLoginProfile, "StatusAreaHostAuraTest"); |
54 chromeos::UserManager::Get()->UserLoggedIn("foo@example.com"); | 48 chromeos::UserManager::Get()->UserLoggedIn("foo@example.com"); |
55 ASSERT_TRUE(chromeos::UserManager::Get()->IsUserLoggedIn()); | 49 ASSERT_TRUE(chromeos::UserManager::Get()->IsUserLoggedIn()); |
56 #endif | 50 #endif |
57 | 51 |
58 Browser* browser = CreateBrowser(ProfileManager::GetDefaultProfile()); | 52 Browser* browser = CreateBrowser(ProfileManager::GetDefaultProfile()); |
59 | 53 EXPECT_EQ(StatusAreaButton::WHITE_HALOED_BOLD, |
60 if (ash::Shell::GetInstance()->IsWindowModeCompact()) { | 54 host->GetStatusAreaTextStyle()); |
61 EXPECT_EQ(StatusAreaButton::GRAY_EMBOSSED_BOLD, | |
62 host->GetStatusAreaTextStyle()); | |
63 | |
64 Browser* incognito_browser = CreateIncognitoBrowser(); | |
65 EXPECT_EQ(StatusAreaButton::WHITE_PLAIN_BOLD, | |
66 host->GetStatusAreaTextStyle()); | |
67 | |
68 incognito_browser->CloseWindow(); | |
69 EXPECT_EQ(StatusAreaButton::GRAY_EMBOSSED_BOLD, | |
70 host->GetStatusAreaTextStyle()); | |
71 } else { | |
72 EXPECT_EQ(StatusAreaButton::WHITE_HALOED_BOLD, | |
73 host->GetStatusAreaTextStyle()); | |
74 } | |
75 | |
76 EXPECT_EQ(StatusAreaHostAura::GetCompactModeBrowserOffset().ToString(), | |
77 ash::Shell::GetInstance()->compact_status_area_offset().ToString()); | |
78 | 55 |
79 #if defined(OS_CHROMEOS) | 56 #if defined(OS_CHROMEOS) |
80 // Lock the screen. | 57 // Lock the screen. |
81 chromeos::ScreenLocker::Show(); | 58 chromeos::ScreenLocker::Show(); |
82 scoped_ptr<chromeos::test::ScreenLockerTester> tester( | 59 scoped_ptr<chromeos::test::ScreenLockerTester> tester( |
83 chromeos::ScreenLocker::GetTester()); | 60 chromeos::ScreenLocker::GetTester()); |
84 tester->EmulateWindowManagerReady(); | 61 tester->EmulateWindowManagerReady(); |
85 ui_test_utils::WindowedNotificationObserver lock_state_observer( | 62 ui_test_utils::WindowedNotificationObserver lock_state_observer( |
86 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, | 63 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED, |
87 content::NotificationService::AllSources()); | 64 content::NotificationService::AllSources()); |
88 if (!tester->IsLocked()) | 65 if (!tester->IsLocked()) |
89 lock_state_observer.Wait(); | 66 lock_state_observer.Wait(); |
90 ASSERT_TRUE(tester->IsLocked()); | 67 ASSERT_TRUE(tester->IsLocked()); |
91 EXPECT_EQ(StatusAreaButton::GRAY_PLAIN_LIGHT, host->GetStatusAreaTextStyle()); | 68 EXPECT_EQ(StatusAreaButton::GRAY_PLAIN_LIGHT, host->GetStatusAreaTextStyle()); |
92 EXPECT_EQ(StatusAreaHostAura::GetCompactModeLoginAndLockOffset().ToString(), | |
93 ash::Shell::GetInstance()->compact_status_area_offset().ToString()); | |
94 | 69 |
95 chromeos::ScreenLocker::Hide(); | 70 chromeos::ScreenLocker::Hide(); |
96 ui_test_utils::RunAllPendingInMessageLoop(); | 71 ui_test_utils::RunAllPendingInMessageLoop(); |
97 ASSERT_FALSE(tester->IsLocked()); | 72 ASSERT_FALSE(tester->IsLocked()); |
98 | 73 |
99 if (ash::Shell::GetInstance()->IsWindowModeCompact()) { | 74 EXPECT_EQ(StatusAreaButton::WHITE_HALOED_BOLD, |
100 EXPECT_EQ(StatusAreaButton::GRAY_EMBOSSED_BOLD, | 75 host->GetStatusAreaTextStyle()); |
101 host->GetStatusAreaTextStyle()); | |
102 } else { | |
103 EXPECT_EQ(StatusAreaButton::WHITE_HALOED_BOLD, | |
104 host->GetStatusAreaTextStyle()); | |
105 } | |
106 EXPECT_EQ(StatusAreaHostAura::GetCompactModeBrowserOffset().ToString(), | |
107 ash::Shell::GetInstance()->compact_status_area_offset().ToString()); | |
108 #endif | 76 #endif |
109 | 77 |
110 browser->CloseWindow(); | 78 browser->CloseWindow(); |
111 } | 79 } |
OLD | NEW |