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

Side by Side Diff: chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc

Issue 2819633002: Restored Pre-Harmony Bubble title margin metrics (Closed)
Patch Set: Fixed a typo Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 7 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 10 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" 11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/browser/ui/test/test_browser_dialog.h"
12 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
13 #include "chrome/browser/ui/views/passwords/account_chooser_dialog_view.h" 14 #include "chrome/browser/ui/views/passwords/account_chooser_dialog_view.h"
14 #include "chrome/browser/ui/views/passwords/auto_signin_first_run_dialog_view.h" 15 #include "chrome/browser/ui/views/passwords/auto_signin_first_run_dialog_view.h"
15 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
17 #include "components/password_manager/core/browser/password_bubble_experiment.h" 18 #include "components/password_manager/core/browser/password_bubble_experiment.h"
18 #include "components/password_manager/core/common/password_manager_pref_names.h" 19 #include "components/password_manager/core/common/password_manager_pref_names.h"
19 #include "components/prefs/pref_service.h" 20 #include "components/prefs/pref_service.h"
20 #include "net/url_request/test_url_fetcher_factory.h" 21 #include "net/url_request/test_url_fetcher_factory.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 131 }
131 132
132 AutoSigninFirstRunPrompt* 133 AutoSigninFirstRunPrompt*
133 TestManagePasswordsUIController::CreateAutoSigninPrompt( 134 TestManagePasswordsUIController::CreateAutoSigninPrompt(
134 PasswordDialogController* controller) { 135 PasswordDialogController* controller) {
135 current_autosignin_prompt_ = 136 current_autosignin_prompt_ =
136 ManagePasswordsUIController::CreateAutoSigninPrompt(controller); 137 ManagePasswordsUIController::CreateAutoSigninPrompt(controller);
137 return current_autosignin_prompt_; 138 return current_autosignin_prompt_;
138 } 139 }
139 140
140 class PasswordDialogViewTest : public InProcessBrowserTest { 141 class PasswordDialogViewTest : public DialogBrowserTest {
141 public: 142 public:
142 // InProcessBrowserTest: 143 // DialogBrowserTest:
143 void SetUpOnMainThread() override; 144 void SetUpOnMainThread() override;
145 void ShowDialog(const std::string& name) override;
144 146
145 void SetupChooseCredentials( 147 void SetupChooseCredentials(
146 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, 148 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials,
147 const GURL& origin); 149 const GURL& origin);
148 150
149 content::WebContents* SetupTabWithTestController(Browser* browser); 151 content::WebContents* SetupTabWithTestController(Browser* browser);
150 152
151 TestManagePasswordsUIController* controller() const { return controller_; } 153 TestManagePasswordsUIController* controller() const { return controller_; }
152 154
153 ChromePasswordManagerClient* client() const { 155 ChromePasswordManagerClient* client() const {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 GURL origin("https://example.com"); 206 GURL origin("https://example.com");
205 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; 207 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials;
206 autofill::PasswordForm form; 208 autofill::PasswordForm form;
207 form.origin = origin; 209 form.origin = origin;
208 form.display_name = base::ASCIIToUTF16("Peter"); 210 form.display_name = base::ASCIIToUTF16("Peter");
209 form.username_value = base::ASCIIToUTF16("peter@pan.test"); 211 form.username_value = base::ASCIIToUTF16("peter@pan.test");
210 form.icon_url = GURL("broken url"); 212 form.icon_url = GURL("broken url");
211 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form)); 213 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form));
212 GURL icon_url("https://google.com/icon.png"); 214 GURL icon_url("https://google.com/icon.png");
213 form.icon_url = icon_url; 215 form.icon_url = icon_url;
214 form.display_name = base::ASCIIToUTF16("Peter Pen"); 216 form.display_name = base::ASCIIToUTF16("Peter Pan");
215 form.federation_origin = url::Origin(GURL("https://google.com/federation")); 217 form.federation_origin = url::Origin(GURL("https://google.com/federation"));
216 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form)); 218 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form));
217 219
218 // Prepare to capture the network request. 220 // Prepare to capture the network request.
219 TestURLFetcherCallback url_callback; 221 TestURLFetcherCallback url_callback;
220 net::FakeURLFetcherFactory factory( 222 net::FakeURLFetcherFactory factory(
221 NULL, base::Bind(&TestURLFetcherCallback::CreateURLFetcher, 223 NULL, base::Bind(&TestURLFetcherCallback::CreateURLFetcher,
222 base::Unretained(&url_callback))); 224 base::Unretained(&url_callback)));
223 factory.SetFakeResponse(icon_url, std::string(), net::HTTP_OK, 225 factory.SetFakeResponse(icon_url, std::string(), net::HTTP_OK,
224 net::URLRequestStatus::FAILED); 226 net::URLRequestStatus::FAILED);
(...skipping 15 matching lines...) Expand all
240 GURL origin("https://example.com"); 242 GURL origin("https://example.com");
241 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; 243 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials;
242 autofill::PasswordForm form; 244 autofill::PasswordForm form;
243 form.origin = origin; 245 form.origin = origin;
244 form.display_name = base::ASCIIToUTF16("Peter"); 246 form.display_name = base::ASCIIToUTF16("Peter");
245 form.username_value = base::ASCIIToUTF16("peter@pan.test"); 247 form.username_value = base::ASCIIToUTF16("peter@pan.test");
246 form.icon_url = GURL("broken url"); 248 form.icon_url = GURL("broken url");
247 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form)); 249 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form));
248 GURL icon_url("https://google.com/icon.png"); 250 GURL icon_url("https://google.com/icon.png");
249 form.icon_url = icon_url; 251 form.icon_url = icon_url;
250 form.display_name = base::ASCIIToUTF16("Peter Pen"); 252 form.display_name = base::ASCIIToUTF16("Peter Pan");
251 form.federation_origin = url::Origin(GURL("https://google.com/federation")); 253 form.federation_origin = url::Origin(GURL("https://google.com/federation"));
252 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form)); 254 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form));
253 255
254 SetupChooseCredentials(std::move(local_credentials), origin); 256 SetupChooseCredentials(std::move(local_credentials), origin);
255 ASSERT_TRUE(controller()->current_account_chooser()); 257 ASSERT_TRUE(controller()->current_account_chooser());
256 258
257 // After picking a credential, we should pass it back to the caller via the 259 // After picking a credential, we should pass it back to the caller via the
258 // callback, but we should not pop up the autosignin prompt as there were 260 // callback, but we should not pop up the autosignin prompt as there were
259 // multiple credentials available. 261 // multiple credentials available.
260 EXPECT_CALL(*this, OnChooseCredential(testing::Pointee(form))); 262 EXPECT_CALL(*this, OnChooseCredential(testing::Pointee(form)));
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 browser()->profile()->GetPrefs()->SetBoolean( 460 browser()->profile()->GetPrefs()->SetBoolean(
459 password_manager::prefs::kCredentialsEnableAutosignin, true); 461 password_manager::prefs::kCredentialsEnableAutosignin, true);
460 462
461 // Successful login with the same form after block will prompt: 463 // Successful login with the same form after block will prompt:
462 blocked_form.reset(new autofill::PasswordForm(form)); 464 blocked_form.reset(new autofill::PasswordForm(form));
463 client()->NotifyUserCouldBeAutoSignedIn(std::move(blocked_form)); 465 client()->NotifyUserCouldBeAutoSignedIn(std::move(blocked_form));
464 client()->NotifySuccessfulLoginWithExistingPassword(form); 466 client()->NotifySuccessfulLoginWithExistingPassword(form);
465 ASSERT_TRUE(controller()->current_autosignin_prompt()); 467 ASSERT_TRUE(controller()->current_autosignin_prompt());
466 } 468 }
467 469
470 // DialogBrowserTest methods for interactive dialog invocation.
471 void PasswordDialogViewTest::ShowDialog(const std::string& name) {
472 GURL origin("https://example.com");
473 EXPECT_EQ("PopupAutoSigninPrompt", name);
474 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials;
475 autofill::PasswordForm form;
476 form.origin = origin;
477 form.display_name = base::ASCIIToUTF16("Peter");
478 form.username_value = base::ASCIIToUTF16("peter@pan.test");
479 form.icon_url = GURL("broken url");
480 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form));
481 GURL icon_url("https://google.com/icon.png");
482 form.icon_url = icon_url;
483 form.display_name = base::ASCIIToUTF16("Peter Pan");
484 form.federation_origin = url::Origin(GURL("https://google.com/federation"));
485 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form));
486 SetupChooseCredentials(std::move(local_credentials), origin);
487 ASSERT_TRUE(controller()->current_account_chooser());
488 }
489
490 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest,
491 InvokeDialog_PopupAutoSigninPrompt) {
492 RunDialog();
493 }
494
468 } // namespace 495 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698