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

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

Issue 13895008: Fix the data race of OobeTest.NewUser browser test and enable it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/login/screen_gaia_signin.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/path_service.h" 6 #include "base/path_service.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/chromeos/cros/cros_in_process_browser_test.h" 10 #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
(...skipping 22 matching lines...) Expand all
33 using namespace google_apis; 33 using namespace google_apis;
34 using namespace google_apis::test_server; 34 using namespace google_apis::test_server;
35 35
36 namespace { 36 namespace {
37 37
38 // Used to add an observer to NotificationService after it's created. 38 // Used to add an observer to NotificationService after it's created.
39 class TestBrowserMainExtraParts 39 class TestBrowserMainExtraParts
40 : public ChromeBrowserMainExtraParts, 40 : public ChromeBrowserMainExtraParts,
41 public content::NotificationObserver { 41 public content::NotificationObserver {
42 public: 42 public:
43 TestBrowserMainExtraParts() {} 43 TestBrowserMainExtraParts()
44 : webui_visible_(false),
45 browsing_data_removed_(false),
46 signin_screen_shown_(false) {}
44 virtual ~TestBrowserMainExtraParts() {} 47 virtual ~TestBrowserMainExtraParts() {}
45 48
46 // ChromeBrowserMainExtraParts implementation. 49 // ChromeBrowserMainExtraParts implementation.
47 virtual void PreEarlyInitialization() OVERRIDE { 50 virtual void PreEarlyInitialization() OVERRIDE {
48 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE, 51 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE,
49 content::NotificationService::AllSources()); 52 content::NotificationService::AllSources());
50 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, 53 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED,
51 content::NotificationService::AllSources()); 54 content::NotificationService::AllSources());
55 registrar_.Add(this, chrome::NOTIFICATION_BROWSING_DATA_REMOVED,
56 content::NotificationService::AllSources());
52 } 57 }
53 58
54 void set_quit_task(const base::Closure& quit_task) { quit_task_ = quit_task; } 59 void set_quit_task(const base::Closure& quit_task) { quit_task_ = quit_task; }
55 void set_gaia_url(const std::string& url) { gaia_url_ = url; } 60 void set_gaia_url(const std::string& url) { gaia_url_ = url; }
56 61
57 private: 62 private:
58 // Overridden from content::NotificationObserver: 63 // Overridden from content::NotificationObserver:
59 virtual void Observe(int type, 64 virtual void Observe(int type,
60 const content::NotificationSource& source, 65 const content::NotificationSource& source,
61 const content::NotificationDetails& details) OVERRIDE { 66 const content::NotificationDetails& details) OVERRIDE {
62 if (type == chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE) { 67 if (type == chrome::NOTIFICATION_LOGIN_WEBUI_VISIBLE) {
63 LOG(INFO) << "NOTIFICATION_LOGIN_WEBUI_VISIBLE"; 68 LOG(INFO) << "NOTIFICATION_LOGIN_WEBUI_VISIBLE";
64 chromeos::ExistingUserController* controller = 69 webui_visible_ = true;
65 chromeos::ExistingUserController::current_controller(); 70 if (browsing_data_removed_ && !signin_screen_shown_) {
66 CHECK(controller); 71 signin_screen_shown_ = true;
67 chromeos::WebUILoginDisplay* webui_login_display = 72 ShowSigninScreen();
68 static_cast<chromeos::WebUILoginDisplay*>( 73 }
69 controller->login_display()); 74 } else if (type == chrome::NOTIFICATION_BROWSING_DATA_REMOVED) {
70 CHECK(webui_login_display); 75 LOG(INFO) << "chrome::NOTIFICATION_BROWSING_DATA_REMOVED";
71 webui_login_display->SetGaiaOriginForTesting(gaia_url_); 76 browsing_data_removed_ = true;
72 webui_login_display->ShowSigninScreenForCreds("username", "password"); 77 if (webui_visible_ && !signin_screen_shown_) {
73 // TODO(glotov): mock GAIA server (test_server_) should support 78 signin_screen_shown_ = true;
74 // username/password configuration. 79 ShowSigninScreen();
80 }
75 } else if (type == chrome::NOTIFICATION_SESSION_STARTED) { 81 } else if (type == chrome::NOTIFICATION_SESSION_STARTED) {
76 LOG(INFO) << "chrome::NOTIFICATION_SESSION_STARTED"; 82 LOG(INFO) << "chrome::NOTIFICATION_SESSION_STARTED";
77 quit_task_.Run(); 83 quit_task_.Run();
78 } else { 84 } else {
79 NOTREACHED(); 85 NOTREACHED();
80 } 86 }
81 } 87 }
82 88
89 void ShowSigninScreen() {
90 chromeos::ExistingUserController* controller =
91 chromeos::ExistingUserController::current_controller();
92 CHECK(controller);
93 chromeos::WebUILoginDisplay* webui_login_display =
94 static_cast<chromeos::WebUILoginDisplay*>(
95 controller->login_display());
96 CHECK(webui_login_display);
97 webui_login_display->SetGaiaOriginForTesting(gaia_url_);
98 webui_login_display->ShowSigninScreenForCreds("username", "password");
99 // TODO(glotov): mock GAIA server (test_server_) should support
100 // username/password configuration.
101 }
102
103 bool webui_visible_, browsing_data_removed_, signin_screen_shown_;
83 content::NotificationRegistrar registrar_; 104 content::NotificationRegistrar registrar_;
84 base::Closure quit_task_; 105 base::Closure quit_task_;
85 std::string gaia_url_; 106 std::string gaia_url_;
86 107
87 DISALLOW_COPY_AND_ASSIGN(TestBrowserMainExtraParts); 108 DISALLOW_COPY_AND_ASSIGN(TestBrowserMainExtraParts);
88 }; 109 };
89 110
90 class TestContentBrowserClient : public chrome::ChromeContentBrowserClient { 111 class TestContentBrowserClient : public chrome::ChromeContentBrowserClient {
91 public: 112 public:
92 TestContentBrowserClient() {} 113 TestContentBrowserClient() {}
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 return http_response.Pass(); 201 return http_response.Pass();
181 } 202 }
182 203
183 scoped_ptr<TestContentBrowserClient> content_browser_client_; 204 scoped_ptr<TestContentBrowserClient> content_browser_client_;
184 content::ContentBrowserClient* original_content_browser_client_; 205 content::ContentBrowserClient* original_content_browser_client_;
185 std::string service_login_response_; 206 std::string service_login_response_;
186 HttpServer* test_server_; // cant use scoped_ptr because destructor 207 HttpServer* test_server_; // cant use scoped_ptr because destructor
187 // needs UI thread. 208 // needs UI thread.
188 }; 209 };
189 210
211 // Temporally disabled because of a race: crbug.com/178009
Nikita (slow) 2013/04/19 07:34:07 Is this still disabled?
kjellander_chromium 2013/04/19 07:38:59 Confusing. I guess this CL needs a rebase and then
glotov 2013/04/19 09:21:12 Done.
190 IN_PROC_BROWSER_TEST_F(OobeTest, NewUser) { 212 IN_PROC_BROWSER_TEST_F(OobeTest, NewUser) {
191 chromeos::WizardController::SkipPostLoginScreensForTesting(); 213 chromeos::WizardController::SkipPostLoginScreensForTesting();
192 chromeos::WizardController* wizard_controller = 214 chromeos::WizardController* wizard_controller =
193 chromeos::WizardController::default_controller(); 215 chromeos::WizardController::default_controller();
194 CHECK(wizard_controller); 216 CHECK(wizard_controller);
195 wizard_controller->SkipToLoginForTesting(); 217 wizard_controller->SkipToLoginForTesting();
196 218
197 scoped_refptr<content::MessageLoopRunner> runner = 219 scoped_refptr<content::MessageLoopRunner> runner =
198 new content::MessageLoopRunner; 220 new content::MessageLoopRunner;
199 content_browser_client_->browser_main_extra_parts_->set_quit_task( 221 content_browser_client_->browser_main_extra_parts_->set_quit_task(
200 runner->QuitClosure()); 222 runner->QuitClosure());
201 runner->Run(); 223 runner->Run();
202 } 224 }
203 225
204 } 226 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/login/screen_gaia_signin.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698