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

Side by Side Diff: chrome/browser/chromeos/login/login_browsertest.cc

Issue 2420123002: Remove dependency from SignInBrowsertest on tracing events watching (Closed)
Patch Set: Created 4 years, 2 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 (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/common/system/tray/system_tray.h" 5 #include "ash/common/system/tray/system_tray.h"
6 #include "ash/shell.h" 6 #include "ash/shell.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/run_loop.h"
9 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
11 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
12 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/chromeos/login/login_manager_test.h" 14 #include "chrome/browser/chromeos/login/login_manager_test.h"
14 #include "chrome/browser/chromeos/login/login_wizard.h" 15 #include "chrome/browser/chromeos/login/login_wizard.h"
15 #include "chrome/browser/chromeos/login/startup_utils.h" 16 #include "chrome/browser/chromeos/login/startup_utils.h"
16 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" 17 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
17 #include "chrome/browser/chromeos/login/wizard_controller.h" 18 #include "chrome/browser/chromeos/login/wizard_controller.h"
18 #include "chrome/browser/chromeos/settings/cros_settings.h" 19 #include "chrome/browser/chromeos/settings/cros_settings.h"
19 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/profiles/profiles_state.h" 21 #include "chrome/browser/profiles/profiles_state.h"
21 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
22 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
23 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
24 #include "chrome/test/base/in_process_browser_test.h" 26 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chrome/test/base/interactive_test_utils.h" 27 #include "chrome/test/base/interactive_test_utils.h"
26 #include "chrome/test/base/tracing.h"
27 #include "chromeos/chromeos_switches.h" 28 #include "chromeos/chromeos_switches.h"
28 #include "chromeos/login/user_names.h" 29 #include "chromeos/login/user_names.h"
29 #include "chromeos/settings/cros_settings_names.h" 30 #include "chromeos/settings/cros_settings_names.h"
30 #include "components/signin/core/account_id/account_id.h" 31 #include "components/signin/core/account_id/account_id.h"
31 #include "content/public/test/browser_test_utils.h" 32 #include "content/public/test/browser_test_utils.h"
32 #include "content/public/test/test_utils.h" 33 #include "content/public/test/test_utils.h"
33 #include "extensions/browser/extension_system.h" 34 #include "extensions/browser/extension_system.h"
34 #include "testing/gmock/include/gmock/gmock.h" 35 #include "testing/gmock/include/gmock/gmock.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
36 37
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 80 }
80 81
81 void TearDownOnMainThread() override { 82 void TearDownOnMainThread() override {
82 // Close the login manager, which otherwise holds a KeepAlive that is not 83 // Close the login manager, which otherwise holds a KeepAlive that is not
83 // cleared in time by the end of the test. 84 // cleared in time by the end of the test.
84 LoginDisplayHost::default_host()->Finalize(); 85 LoginDisplayHost::default_host()->Finalize();
85 } 86 }
86 87
87 void SetUpOnMainThread() override { 88 void SetUpOnMainThread() override {
88 LoginDisplayHostImpl::DisableRestrictiveProxyCheckForTest(); 89 LoginDisplayHostImpl::DisableRestrictiveProxyCheckForTest();
90 run_loop_.reset(new base::RunLoop());
91 SigninScreenHandler::SetCallbackOnUiShownForTesting(
92 base::Bind(&LoginSigninTest::OnLoginUiShown, base::Unretained(this)));
93 }
89 94
90 ASSERT_TRUE(tracing::BeginTracingWithWatch( 95 void OnLoginUiShown() {
91 "ui", "ui", "ShowLoginWebUI", 1)); 96 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
97 run_loop_->QuitClosure().Run();
92 } 98 }
99
100 std::unique_ptr<base::RunLoop> run_loop_;
93 }; 101 };
94 102
95 class LoginTest : public LoginManagerTest { 103 class LoginTest : public LoginManagerTest {
96 public: 104 public:
97 LoginTest() : LoginManagerTest(true) {} 105 LoginTest() : LoginManagerTest(true) {}
98 ~LoginTest() override {} 106 ~LoginTest() override {}
99 107
100 void StartGaiaAuthOffline() { 108 void StartGaiaAuthOffline() {
101 content::DOMMessageQueue message_queue; 109 content::DOMMessageQueue message_queue;
102 const std::string js = "(function() {" 110 const std::string js = "(function() {"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible()); 246 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible());
239 247
240 base::ThreadTaskRunnerHandle::Get()->DeleteSoon( 248 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
241 FROM_HERE, LoginDisplayHost::default_host()); 249 FROM_HERE, LoginDisplayHost::default_host());
242 250
243 TestSystemTrayIsVisible(); 251 TestSystemTrayIsVisible();
244 } 252 }
245 253
246 // Verifies that the webui for login comes up successfully. 254 // Verifies that the webui for login comes up successfully.
247 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) { 255 IN_PROC_BROWSER_TEST_F(LoginSigninTest, WebUIVisible) {
248 base::TimeDelta no_timeout; 256 run_loop_->Run();
249 EXPECT_TRUE(tracing::WaitForWatchEvent(no_timeout));
250 std::string json_events;
251 ASSERT_TRUE(tracing::EndTracing(&json_events));
252 } 257 }
253 258
254 259
255 IN_PROC_BROWSER_TEST_F(LoginTest, PRE_GaiaAuthOffline) { 260 IN_PROC_BROWSER_TEST_F(LoginTest, PRE_GaiaAuthOffline) {
256 RegisterUser(kTestUser); 261 RegisterUser(kTestUser);
257 StartupUtils::MarkOobeCompleted(); 262 StartupUtils::MarkOobeCompleted();
258 CrosSettings::Get()->SetBoolean(kAccountsPrefShowUserNamesOnSignIn, false); 263 CrosSettings::Get()->SetBoolean(kAccountsPrefShowUserNamesOnSignIn, false);
259 } 264 }
260 265
261 IN_PROC_BROWSER_TEST_F(LoginTest, GaiaAuthOffline) { 266 IN_PROC_BROWSER_TEST_F(LoginTest, GaiaAuthOffline) {
262 PrepareOfflineLogin(); 267 PrepareOfflineLogin();
263 content::WindowedNotificationObserver session_start_waiter( 268 content::WindowedNotificationObserver session_start_waiter(
264 chrome::NOTIFICATION_SESSION_STARTED, 269 chrome::NOTIFICATION_SESSION_STARTED,
265 content::NotificationService::AllSources()); 270 content::NotificationService::AllSources());
266 SubmitGaiaAuthOfflineForm(kTestUser, kPassword); 271 SubmitGaiaAuthOfflineForm(kTestUser, kPassword);
267 session_start_waiter.Wait(); 272 session_start_waiter.Wait();
268 273
269 TestSystemTrayIsVisible(); 274 TestSystemTrayIsVisible();
270 } 275 }
271 276
272 } // namespace chromeos 277 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698