OLD | NEW |
---|---|
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 Loading... | |
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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | |
tapted
2017/04/19 00:25:03
nit: full stop at end
kylix_rd
2017/04/19 14:55:37
Done.
| |
471 void PasswordDialogViewTest::ShowDialog(const std::string& name) { | |
472 GURL origin("https://example.com"); | |
tapted
2017/04/19 00:25:03
EXPECT_EQ("PopupAutoSigninPrompt", name); ?
kylix_rd
2017/04/19 14:55:37
Done.
| |
473 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; | |
474 autofill::PasswordForm form; | |
475 form.origin = origin; | |
476 form.display_name = base::ASCIIToUTF16("Peter"); | |
477 form.username_value = base::ASCIIToUTF16("peter@pan.test"); | |
478 form.icon_url = GURL("broken url"); | |
479 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form)); | |
480 GURL icon_url("https://google.com/icon.png"); | |
481 form.icon_url = icon_url; | |
482 form.display_name = base::ASCIIToUTF16("Peter Pen"); | |
483 form.federation_origin = url::Origin(GURL("https://google.com/federation")); | |
484 local_credentials.push_back(base::MakeUnique<autofill::PasswordForm>(form)); | |
485 SetupChooseCredentials(std::move(local_credentials), origin); | |
486 ASSERT_TRUE(controller()->current_account_chooser()); | |
tapted
2017/04/19 00:25:03
optional: EXPECT_TRUE? (I tend to avoid `ASSERT_FO
kylix_rd
2017/04/19 14:55:37
I was following the existing pattern among all the
| |
487 } | |
488 | |
489 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, | |
490 InvokeDialog_PopupAutoSigninPrompt) { | |
491 RunDialog(); | |
492 } | |
493 | |
468 } // namespace | 494 } // namespace |
OLD | NEW |