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

Side by Side Diff: chrome/browser/password_manager/password_manager_browsertest.cc

Issue 404983002: PasswordManager - SetUpOnMainThread() browsertest clean up (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <string> 5 #include <string>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_samples.h" 8 #include "base/metrics/histogram_samples.h"
9 #include "base/metrics/statistics_recorder.h" 9 #include "base/metrics/statistics_recorder.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // InProcessBrowserTest: 252 // InProcessBrowserTest:
253 virtual void SetUpOnMainThread() OVERRIDE { 253 virtual void SetUpOnMainThread() OVERRIDE {
254 // Use TestPasswordStore to remove a possible race. Normally the 254 // Use TestPasswordStore to remove a possible race. Normally the
255 // PasswordStore does its database manipulation on the DB thread, which 255 // PasswordStore does its database manipulation on the DB thread, which
256 // creates a possible race during navigation. Specifically the 256 // creates a possible race during navigation. Specifically the
257 // PasswordManager will ignore any forms in a page if the load from the 257 // PasswordManager will ignore any forms in a page if the load from the
258 // PasswordStore has not completed. 258 // PasswordStore has not completed.
259 PasswordStoreFactory::GetInstance()->SetTestingFactory( 259 PasswordStoreFactory::GetInstance()->SetTestingFactory(
260 browser()->profile(), TestPasswordStoreService::Build); 260 browser()->profile(), TestPasswordStoreService::Build);
261 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 261 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
262 ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch(
263 password_manager::switches::kEnableAutomaticPasswordSaving));
262 } 264 }
263 265
264 virtual void CleanUpOnMainThread() OVERRIDE { 266 virtual void CleanUpOnMainThread() OVERRIDE {
265 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); 267 ASSERT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete());
266 InProcessBrowserTest::CleanUpOnMainThread(); 268 InProcessBrowserTest::CleanUpOnMainThread();
267 } 269 }
268 270
269 protected: 271 protected:
270 content::WebContents* WebContents() { 272 content::WebContents* WebContents() {
271 return browser()->tab_strip_model()->GetActiveWebContents(); 273 return browser()->tab_strip_model()->GetActiveWebContents();
272 } 274 }
273 275
274 content::RenderViewHost* RenderViewHost() { 276 content::RenderViewHost* RenderViewHost() {
275 return WebContents()->GetRenderViewHost(); 277 return WebContents()->GetRenderViewHost();
276 } 278 }
277 279
278 // Wrapper around ui_test_utils::NavigateToURL that waits until 280 // Wrapper around ui_test_utils::NavigateToURL that waits until
279 // DidFinishLoad() fires. Normally this function returns after 281 // DidFinishLoad() fires. Normally this function returns after
280 // DidStopLoading(), which caused flakiness as the NavigationObserver 282 // DidStopLoading(), which caused flakiness as the NavigationObserver
281 // would sometimes see the DidFinishLoad event from a previous navigation and 283 // would sometimes see the DidFinishLoad event from a previous navigation and
282 // return immediately. 284 // return immediately.
283 void NavigateToFile(const std::string& path) { 285 void NavigateToFile(const std::string& path) {
284 if (!embedded_test_server()->Started())
285 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
286
287 ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch(
288 password_manager::switches::kEnableAutomaticPasswordSaving));
289 NavigationObserver observer(WebContents()); 286 NavigationObserver observer(WebContents());
290 GURL url = embedded_test_server()->GetURL(path); 287 GURL url = embedded_test_server()->GetURL(path);
291 ui_test_utils::NavigateToURL(browser(), url); 288 ui_test_utils::NavigateToURL(browser(), url);
292 observer.Wait(); 289 observer.Wait();
293 } 290 }
294 291
295 // Waits until the "value" attribute of the HTML element with |element_id| is 292 // Waits until the "value" attribute of the HTML element with |element_id| is
296 // equal to |expected_value|. If the current value is not as expected, this 293 // equal to |expected_value|. If the current value is not as expected, this
297 // waits until the "change" event is fired for the element. This also 294 // waits until the "change" event is fired for the element. This also
298 // guarantees that once the real value matches the expected, the JavaScript 295 // guarantees that once the real value matches the expected, the JavaScript
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 std::string submit = 1113 std::string submit =
1117 "document.getElementById('username').value = 'overwrite_me';" 1114 "document.getElementById('username').value = 'overwrite_me';"
1118 "document.getElementById('password').value = 'random';" 1115 "document.getElementById('password').value = 'random';"
1119 "document.getElementById('non-form-button').click();"; 1116 "document.getElementById('non-form-button').click();";
1120 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); 1117 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
1121 observer.Wait(); 1118 observer.Wait();
1122 1119
1123 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 1120 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
1124 } 1121 }
1125 1122
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698