Chromium Code Reviews| 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. | |
| 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 Pen"); | |
|
vabr (Chromium)
2017/04/19 15:07:29
typo? Pen -> Pan :)
(If this is intentional, that'
kylix_rd
2017/04/19 15:29:01
Maybe? It was copied from some of the existing cod
| |
| 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 |
| OLD | NEW |