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

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: Added browser dialog interactive test for password bubbles 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 // InProcessBrowserTest:
143 void SetUpOnMainThread() override; 144 void SetUpOnMainThread() override;
Peter Kasting 2017/04/17 19:53:36 Nit: Combine these two override blocks, since you
144 145
146 // DialogBrowserTest:
147 void ShowDialog(const std::string& name) override;
148
145 void SetupChooseCredentials( 149 void SetupChooseCredentials(
146 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, 150 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials,
147 const GURL& origin); 151 const GURL& origin);
148 152
149 content::WebContents* SetupTabWithTestController(Browser* browser); 153 content::WebContents* SetupTabWithTestController(Browser* browser);
150 154
151 TestManagePasswordsUIController* controller() const { return controller_; } 155 TestManagePasswordsUIController* controller() const { return controller_; }
152 156
153 ChromePasswordManagerClient* client() const { 157 ChromePasswordManagerClient* client() const {
154 return ChromePasswordManagerClient::FromWebContents( 158 return ChromePasswordManagerClient::FromWebContents(
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 browser()->profile()->GetPrefs()->SetBoolean( 462 browser()->profile()->GetPrefs()->SetBoolean(
459 password_manager::prefs::kCredentialsEnableAutosignin, true); 463 password_manager::prefs::kCredentialsEnableAutosignin, true);
460 464
461 // Successful login with the same form after block will prompt: 465 // Successful login with the same form after block will prompt:
462 blocked_form.reset(new autofill::PasswordForm(form)); 466 blocked_form.reset(new autofill::PasswordForm(form));
463 client()->NotifyUserCouldBeAutoSignedIn(std::move(blocked_form)); 467 client()->NotifyUserCouldBeAutoSignedIn(std::move(blocked_form));
464 client()->NotifySuccessfulLoginWithExistingPassword(form); 468 client()->NotifySuccessfulLoginWithExistingPassword(form);
465 ASSERT_TRUE(controller()->current_autosignin_prompt()); 469 ASSERT_TRUE(controller()->current_autosignin_prompt());
466 } 470 }
467 471
472 // DialogBrowserTest methods for interactive dialog invocation
473 void PasswordDialogViewTest::ShowDialog(const std::string& name) {
474 GURL origin("https://example.com");
475 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials;
476 autofill::PasswordForm form;
477 form.origin = origin;
478 form.display_name = base::ASCIIToUTF16("Peter");
479 form.username_value = base::ASCIIToUTF16("peter@pan.test");
480 form.icon_url = GURL("broken url");
481 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form));
Peter Kasting 2017/04/17 19:53:36 Nit: Having to construct on the static and then co
kylix_rd 2017/04/18 16:05:16 That makes sense. I do, however, approach it from
482 GURL icon_url("https://google.com/icon.png");
483 form.icon_url = icon_url;
484 form.display_name = base::ASCIIToUTF16("Peter Pen");
485 form.federation_origin = url::Origin(GURL("https://google.com/federation"));
486 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form));
487 SetupChooseCredentials(std::move(local_credentials), origin);
488 ASSERT_TRUE(controller()->current_account_chooser());
489 }
490
491 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest,
492 InvokeDialog_PopupAutoSigninPrompt) {
493 RunDialog();
494 }
495
468 } // namespace 496 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698