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 "chrome/browser/chrome_browser_main.h" | 7 #include "chrome/browser/chrome_browser_main.h" |
8 #include "chrome/browser/chrome_browser_main_extra_parts.h" | 8 #include "chrome/browser/chrome_browser_main_extra_parts.h" |
9 #include "chrome/browser/chrome_content_browser_client.h" | 9 #include "chrome/browser/chrome_content_browser_client.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "extensions/browser/extension_system.h" | 27 #include "extensions/browser/extension_system.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
30 | 30 |
31 using ::testing::_; | 31 using ::testing::_; |
32 using ::testing::AnyNumber; | 32 using ::testing::AnyNumber; |
33 using ::testing::Return; | 33 using ::testing::Return; |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 class LoginUserTest : public InProcessBrowserTest, | 37 class LoginUserTest : public InProcessBrowserTest { |
38 public testing::WithParamInterface<bool> { | |
39 protected: | 38 protected: |
40 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 39 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
41 command_line->AppendSwitchASCII( | 40 command_line->AppendSwitchASCII( |
42 chromeos::switches::kLoginUser, "TestUser@gmail.com"); | 41 chromeos::switches::kLoginUser, "TestUser@gmail.com"); |
43 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 42 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
44 if (GetParam()) | |
45 command_line->AppendSwitch(::switches::kMultiProfiles); | |
46 } | 43 } |
47 }; | 44 }; |
48 | 45 |
49 class LoginGuestTest : public InProcessBrowserTest, | 46 class LoginGuestTest : public InProcessBrowserTest { |
50 public testing::WithParamInterface<bool> { | |
51 protected: | 47 protected: |
52 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 48 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
53 command_line->AppendSwitch(chromeos::switches::kGuestSession); | 49 command_line->AppendSwitch(chromeos::switches::kGuestSession); |
54 command_line->AppendSwitch(::switches::kIncognito); | 50 command_line->AppendSwitch(::switches::kIncognito); |
55 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); | 51 command_line->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user"); |
56 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, | 52 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, |
57 chromeos::UserManager::kGuestUserName); | 53 chromeos::UserManager::kGuestUserName); |
58 if (GetParam()) | |
59 command_line->AppendSwitch(::switches::kMultiProfiles); | |
60 } | 54 } |
61 }; | 55 }; |
62 | 56 |
63 class LoginCursorTest : public InProcessBrowserTest { | 57 class LoginCursorTest : public InProcessBrowserTest { |
64 protected: | 58 protected: |
65 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 59 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
66 command_line->AppendSwitch(chromeos::switches::kLoginManager); | 60 command_line->AppendSwitch(chromeos::switches::kLoginManager); |
67 } | 61 } |
68 }; | 62 }; |
69 | 63 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 content::SetBrowserClientForTesting(original_content_browser_client_); | 130 content::SetBrowserClientForTesting(original_content_browser_client_); |
137 } | 131 } |
138 | 132 |
139 scoped_ptr<TestContentBrowserClient> content_browser_client_; | 133 scoped_ptr<TestContentBrowserClient> content_browser_client_; |
140 content::ContentBrowserClient* original_content_browser_client_; | 134 content::ContentBrowserClient* original_content_browser_client_; |
141 }; | 135 }; |
142 | 136 |
143 // After a chrome crash, the session manager will restart chrome with | 137 // After a chrome crash, the session manager will restart chrome with |
144 // the -login-user flag indicating that the user is already logged in. | 138 // the -login-user flag indicating that the user is already logged in. |
145 // This profile should NOT be an OTR profile. | 139 // This profile should NOT be an OTR profile. |
146 IN_PROC_BROWSER_TEST_P(LoginUserTest, UserPassed) { | 140 IN_PROC_BROWSER_TEST_F(LoginUserTest, UserPassed) { |
147 Profile* profile = browser()->profile(); | 141 Profile* profile = browser()->profile(); |
148 std::string profile_base_path("user"); | 142 EXPECT_EQ("user", profile->GetPath().BaseName().value()); |
149 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kMultiProfiles)) | |
150 profile_base_path.insert(0, chrome::kProfileDirPrefix); | |
151 EXPECT_EQ(profile_base_path, profile->GetPath().BaseName().value()); | |
152 EXPECT_FALSE(profile->IsOffTheRecord()); | 143 EXPECT_FALSE(profile->IsOffTheRecord()); |
153 } | 144 } |
154 | 145 |
155 // Verifies the cursor is not hidden at startup when user is logged in. | 146 // Verifies the cursor is not hidden at startup when user is logged in. |
156 IN_PROC_BROWSER_TEST_P(LoginUserTest, CursorShown) { | 147 IN_PROC_BROWSER_TEST_F(LoginUserTest, CursorShown) { |
157 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 148 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
158 } | 149 } |
159 | 150 |
160 // After a guest login, we should get the OTR default profile. | 151 // After a guest login, we should get the OTR default profile. |
161 IN_PROC_BROWSER_TEST_P(LoginGuestTest, GuestIsOTR) { | 152 IN_PROC_BROWSER_TEST_F(LoginGuestTest, GuestIsOTR) { |
162 Profile* profile = browser()->profile(); | 153 Profile* profile = browser()->profile(); |
163 EXPECT_TRUE(profile->IsOffTheRecord()); | 154 EXPECT_TRUE(profile->IsOffTheRecord()); |
164 // Ensure there's extension service for this profile. | 155 // Ensure there's extension service for this profile. |
165 EXPECT_TRUE(extensions::ExtensionSystem::Get(profile)->extension_service()); | 156 EXPECT_TRUE(extensions::ExtensionSystem::Get(profile)->extension_service()); |
166 } | 157 } |
167 | 158 |
168 // Verifies the cursor is not hidden at startup when running guest session. | 159 // Verifies the cursor is not hidden at startup when running guest session. |
169 IN_PROC_BROWSER_TEST_P(LoginGuestTest, CursorShown) { | 160 IN_PROC_BROWSER_TEST_F(LoginGuestTest, CursorShown) { |
170 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 161 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
171 } | 162 } |
172 | 163 |
173 // Verifies the cursor is hidden at startup on login screen. | 164 // Verifies the cursor is hidden at startup on login screen. |
174 IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { | 165 IN_PROC_BROWSER_TEST_F(LoginCursorTest, CursorHidden) { |
175 // Login screen needs to be shown explicitly when running test. | 166 // Login screen needs to be shown explicitly when running test. |
176 chromeos::ShowLoginWizard(chromeos::WizardController::kLoginScreenName); | 167 chromeos::ShowLoginWizard(chromeos::WizardController::kLoginScreenName); |
177 | 168 |
178 // Cursor should be hidden at startup | 169 // Cursor should be hidden at startup |
179 EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 170 EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
180 | 171 |
181 // Cursor should be shown after cursor is moved. | 172 // Cursor should be shown after cursor is moved. |
182 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); | 173 EXPECT_TRUE(ui_test_utils::SendMouseMoveSync(gfx::Point())); |
183 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); | 174 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); |
184 | 175 |
185 base::MessageLoop::current()->DeleteSoon( | 176 base::MessageLoop::current()->DeleteSoon( |
186 FROM_HERE, chromeos::LoginDisplayHostImpl::default_host()); | 177 FROM_HERE, chromeos::LoginDisplayHostImpl::default_host()); |
187 } | 178 } |
188 | 179 |
189 // Verifies that the webui for login comes up successfully. | 180 // Verifies that the webui for login comes up successfully. |
190 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { | 181 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { |
191 scoped_refptr<content::MessageLoopRunner> runner = | 182 scoped_refptr<content::MessageLoopRunner> runner = |
192 new content::MessageLoopRunner; | 183 new content::MessageLoopRunner; |
193 content_browser_client_->browser_main_extra_parts_->set_quit_task( | 184 content_browser_client_->browser_main_extra_parts_->set_quit_task( |
194 runner->QuitClosure()); | 185 runner->QuitClosure()); |
195 runner->Run(); | 186 runner->Run(); |
196 } | 187 } |
197 | 188 |
198 INSTANTIATE_TEST_CASE_P(LoginUserTestInstantiation, | |
199 LoginUserTest, | |
200 testing::Bool()); | |
201 | |
202 INSTANTIATE_TEST_CASE_P(LoginGuestTestInstantiation, | |
203 LoginGuestTest, | |
204 testing::Bool()); | |
205 | |
206 } // namespace | 189 } // namespace |
OLD | NEW |