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

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

Issue 839193002: Move ServiceAccessType into //components/keyed_service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on android Created 5 years, 11 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 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/path_service.h" 10 #include "base/path_service.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/infobars/infobar_service.h" 16 #include "chrome/browser/infobars/infobar_service.h"
17 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 17 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
18 #include "chrome/browser/password_manager/password_store_factory.h" 18 #include "chrome/browser/password_manager/password_store_factory.h"
19 #include "chrome/browser/password_manager/test_password_store_service.h" 19 #include "chrome/browser/password_manager/test_password_store_service.h"
20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/login/login_prompt.h" 22 #include "chrome/browser/ui/login/login_prompt.h"
22 #include "chrome/browser/ui/login/login_prompt_test_utils.h" 23 #include "chrome/browser/ui/login/login_prompt_test_utils.h"
23 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 24 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "chrome/common/chrome_version_info.h" 28 #include "chrome/common/chrome_version_info.h"
28 #include "chrome/test/base/in_process_browser_test.h" 29 #include "chrome/test/base/in_process_browser_test.h"
29 #include "chrome/test/base/test_switches.h" 30 #include "chrome/test/base/test_switches.h"
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 "document.getElementById('input_submit_button').click()"; 1065 "document.getElementById('input_submit_button').click()";
1065 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit)); 1066 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), fill_and_submit));
1066 observer.Wait(); 1067 observer.Wait();
1067 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 1068 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
1068 } 1069 }
1069 1070
1070 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 1071 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
1071 DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) { 1072 DontPromptWhenEnableAutomaticPasswordSavingSwitchIsSet) {
1072 password_manager::TestPasswordStore* password_store = 1073 password_manager::TestPasswordStore* password_store =
1073 static_cast<password_manager::TestPasswordStore*>( 1074 static_cast<password_manager::TestPasswordStore*>(
1074 PasswordStoreFactory::GetForProfile(browser()->profile(), 1075 PasswordStoreFactory::GetForProfile(
1075 Profile::IMPLICIT_ACCESS).get()); 1076 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
1076 1077
1077 EXPECT_TRUE(password_store->IsEmpty()); 1078 EXPECT_TRUE(password_store->IsEmpty());
1078 1079
1079 NavigateToFile("/password/password_form.html"); 1080 NavigateToFile("/password/password_form.html");
1080 1081
1081 // Add the enable-automatic-password-saving switch. 1082 // Add the enable-automatic-password-saving switch.
1082 base::CommandLine::ForCurrentProcess()->AppendSwitch( 1083 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1083 password_manager::switches::kEnableAutomaticPasswordSaving); 1084 password_manager::switches::kEnableAutomaticPasswordSaving);
1084 1085
1085 // Fill a form and submit through a <input type="submit"> button. 1086 // Fill a form and submit through a <input type="submit"> button.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 embedded_test_server()->RegisterRequestHandler( 1156 embedded_test_server()->RegisterRequestHandler(
1156 base::Bind(&HandleTestAuthRequest)); 1157 base::Bind(&HandleTestAuthRequest));
1157 1158
1158 LoginPromptBrowserTestObserver login_observer; 1159 LoginPromptBrowserTestObserver login_observer;
1159 // We need to register to all sources, because the navigation observer we are 1160 // We need to register to all sources, because the navigation observer we are
1160 // interested in is for a new tab to be opened, and thus does not exist yet. 1161 // interested in is for a new tab to be opened, and thus does not exist yet.
1161 login_observer.Register(content::NotificationService::AllSources()); 1162 login_observer.Register(content::NotificationService::AllSources());
1162 1163
1163 password_manager::TestPasswordStore* password_store = 1164 password_manager::TestPasswordStore* password_store =
1164 static_cast<password_manager::TestPasswordStore*>( 1165 static_cast<password_manager::TestPasswordStore*>(
1165 PasswordStoreFactory::GetForProfile(browser()->profile(), 1166 PasswordStoreFactory::GetForProfile(
1166 Profile::IMPLICIT_ACCESS).get()); 1167 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
1167 EXPECT_TRUE(password_store->IsEmpty()); 1168 EXPECT_TRUE(password_store->IsEmpty());
1168 1169
1169 // Navigate to a page requiring HTTP auth. Wait for the tab to get the correct 1170 // Navigate to a page requiring HTTP auth. Wait for the tab to get the correct
1170 // WebContents, but don't wait for navigation, which only finishes after 1171 // WebContents, but don't wait for navigation, which only finishes after
1171 // authentication. 1172 // authentication.
1172 ui_test_utils::NavigateToURLWithDisposition( 1173 ui_test_utils::NavigateToURLWithDisposition(
1173 browser(), 1174 browser(),
1174 embedded_test_server()->GetURL("/basic_auth"), 1175 embedded_test_server()->GetURL("/basic_auth"),
1175 NEW_FOREGROUND_TAB, 1176 NEW_FOREGROUND_TAB,
1176 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB); 1177 ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html"); 1282 observer.SetPathToWaitFor("/password/done_and_separate_login_form.html");
1282 observer.Wait(); 1283 observer.Wait();
1283 1284
1284 EXPECT_FALSE(prompt_observer->IsShowingPrompt()); 1285 EXPECT_FALSE(prompt_observer->IsShowingPrompt());
1285 } 1286 }
1286 1287
1287 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 1288 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
1288 PromptWhenPasswordFormWithoutUsernameFieldSubmitted) { 1289 PromptWhenPasswordFormWithoutUsernameFieldSubmitted) {
1289 password_manager::TestPasswordStore* password_store = 1290 password_manager::TestPasswordStore* password_store =
1290 static_cast<password_manager::TestPasswordStore*>( 1291 static_cast<password_manager::TestPasswordStore*>(
1291 PasswordStoreFactory::GetForProfile(browser()->profile(), 1292 PasswordStoreFactory::GetForProfile(
1292 Profile::IMPLICIT_ACCESS).get()); 1293 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
1293 1294
1294 EXPECT_TRUE(password_store->IsEmpty()); 1295 EXPECT_TRUE(password_store->IsEmpty());
1295 1296
1296 NavigateToFile("/password/form_with_only_password_field.html"); 1297 NavigateToFile("/password/form_with_only_password_field.html");
1297 1298
1298 NavigationObserver observer(WebContents()); 1299 NavigationObserver observer(WebContents());
1299 scoped_ptr<PromptObserver> prompt_observer( 1300 scoped_ptr<PromptObserver> prompt_observer(
1300 PromptObserver::Create(WebContents())); 1301 PromptObserver::Create(WebContents()));
1301 std::string submit = 1302 std::string submit =
1302 "document.getElementById('password').value = 'password';" 1303 "document.getElementById('password').value = 'password';"
1303 "document.getElementById('submit-button').click();"; 1304 "document.getElementById('submit-button').click();";
1304 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit)); 1305 ASSERT_TRUE(content::ExecuteScript(RenderViewHost(), submit));
1305 observer.Wait(); 1306 observer.Wait();
1306 1307
1307 EXPECT_TRUE(prompt_observer->IsShowingPrompt()); 1308 EXPECT_TRUE(prompt_observer->IsShowingPrompt());
1308 prompt_observer->Accept(); 1309 prompt_observer->Accept();
1309 1310
1310 // Spin the message loop to make sure the password store had a chance to save 1311 // Spin the message loop to make sure the password store had a chance to save
1311 // the password. 1312 // the password.
1312 base::RunLoop run_loop; 1313 base::RunLoop run_loop;
1313 run_loop.RunUntilIdle(); 1314 run_loop.RunUntilIdle();
1314 EXPECT_FALSE(password_store->IsEmpty()); 1315 EXPECT_FALSE(password_store->IsEmpty());
1315 } 1316 }
1316 1317
1317 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest, 1318 IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTest,
1318 AutofillSuggetionsForPasswordFormWithoutUsernameField) { 1319 AutofillSuggetionsForPasswordFormWithoutUsernameField) {
1319 password_manager::TestPasswordStore* password_store = 1320 password_manager::TestPasswordStore* password_store =
1320 static_cast<password_manager::TestPasswordStore*>( 1321 static_cast<password_manager::TestPasswordStore*>(
1321 PasswordStoreFactory::GetForProfile(browser()->profile(), 1322 PasswordStoreFactory::GetForProfile(
1322 Profile::IMPLICIT_ACCESS).get()); 1323 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS).get());
1323 1324
1324 EXPECT_TRUE(password_store->IsEmpty()); 1325 EXPECT_TRUE(password_store->IsEmpty());
1325 1326
1326 // Password form without username-field. 1327 // Password form without username-field.
1327 NavigateToFile("/password/form_with_only_password_field.html"); 1328 NavigateToFile("/password/form_with_only_password_field.html");
1328 1329
1329 NavigationObserver observer(WebContents()); 1330 NavigationObserver observer(WebContents());
1330 scoped_ptr<PromptObserver> prompt_observer( 1331 scoped_ptr<PromptObserver> prompt_observer(
1331 PromptObserver::Create(WebContents())); 1332 PromptObserver::Create(WebContents()));
1332 std::string submit = 1333 std::string submit =
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 RenderViewHost(), 1475 RenderViewHost(),
1475 "window.domAutomationController.send(usernameRect.left);", 1476 "window.domAutomationController.send(usernameRect.left);",
1476 &left)); 1477 &left));
1477 1478
1478 content::SimulateMouseClickAt( 1479 content::SimulateMouseClickAt(
1479 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(left + 1, 1480 WebContents(), 0, blink::WebMouseEvent::ButtonLeft, gfx::Point(left + 1,
1480 top + 1)); 1481 top + 1));
1481 // Make sure the popup would be shown. 1482 // Make sure the popup would be shown.
1482 observing_autofill_client.Wait(); 1483 observing_autofill_client.Wait();
1483 } 1484 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698