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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller_unittest.cc

Issue 2202373002: Ignore OnBubbleHidden() event when the password bubble is reopened. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: delete proxy Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 15 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
16 #include "chrome/browser/ui/passwords/manage_passwords_icon_view.h" 16 #include "chrome/browser/ui/passwords/manage_passwords_icon_view.h"
17 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h" 17 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller_mock.h"
18 #include "chrome/browser/ui/passwords/password_dialog_controller.h" 18 #include "chrome/browser/ui/passwords/password_dialog_controller.h"
19 #include "chrome/browser/ui/passwords/password_dialog_prompts.h" 19 #include "chrome/browser/ui/passwords/password_dialog_prompts.h"
20 #include "chrome/browser/ui/passwords/passwords_model_delegate.h"
20 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 21 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
21 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
22 #include "components/autofill/core/common/password_form.h" 23 #include "components/autofill/core/common/password_form.h"
23 #include "components/password_manager/core/browser/password_bubble_experiment.h" 24 #include "components/password_manager/core/browser/password_bubble_experiment.h"
24 #include "components/password_manager/core/browser/password_form_manager.h" 25 #include "components/password_manager/core/browser/password_form_manager.h"
25 #include "components/password_manager/core/browser/password_manager.h" 26 #include "components/password_manager/core/browser/password_manager.h"
26 #include "components/password_manager/core/browser/statistics_table.h" 27 #include "components/password_manager/core/browser/statistics_table.h"
27 #include "components/password_manager/core/browser/stub_form_saver.h" 28 #include "components/password_manager/core/browser/stub_form_saver.h"
28 #include "components/password_manager/core/browser/stub_password_manager_client. h" 29 #include "components/password_manager/core/browser/stub_password_manager_client. h"
29 #include "components/password_manager/core/browser/stub_password_manager_driver. h" 30 #include "components/password_manager/core/browser/stub_password_manager_driver. h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 set_client(client); 116 set_client(client);
116 } 117 }
117 118
118 TestManagePasswordsUIController::~TestManagePasswordsUIController() { 119 TestManagePasswordsUIController::~TestManagePasswordsUIController() {
119 } 120 }
120 121
121 void TestManagePasswordsUIController::UpdateBubbleAndIconVisibility() { 122 void TestManagePasswordsUIController::UpdateBubbleAndIconVisibility() {
122 opened_bubble_ = IsAutomaticallyOpeningBubble(); 123 opened_bubble_ = IsAutomaticallyOpeningBubble();
123 ManagePasswordsUIController::UpdateBubbleAndIconVisibility(); 124 ManagePasswordsUIController::UpdateBubbleAndIconVisibility();
124 OnUpdateBubbleAndIconVisibility(); 125 OnUpdateBubbleAndIconVisibility();
126 TestManagePasswordsIconView view;
127 UpdateIconAndBubbleState(&view);
125 if (opened_bubble_) 128 if (opened_bubble_)
126 OnBubbleShown(); 129 OnBubbleShown();
127 } 130 }
128 131
129 void TestManagePasswordsUIController::NeverSavePasswordInternal() { 132 void TestManagePasswordsUIController::NeverSavePasswordInternal() {
130 autofill::PasswordForm blacklisted; 133 autofill::PasswordForm blacklisted;
131 blacklisted.origin = this->GetOrigin(); 134 blacklisted.origin = this->GetOrigin();
132 blacklisted.signon_realm = blacklisted.origin.spec(); 135 blacklisted.signon_realm = blacklisted.origin.spec();
133 blacklisted.blacklisted_by_user = true; 136 blacklisted.blacklisted_by_user = true;
134 password_manager::PasswordStoreChange change( 137 password_manager::PasswordStoreChange change(
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 } 739 }
737 740
738 TEST_F(ManagePasswordsUIControllerTest, UpdatePendingStatePasswordAutofilled) { 741 TEST_F(ManagePasswordsUIControllerTest, UpdatePendingStatePasswordAutofilled) {
739 TestNotChangingStateOnAutofill( 742 TestNotChangingStateOnAutofill(
740 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE); 743 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE);
741 } 744 }
742 745
743 TEST_F(ManagePasswordsUIControllerTest, ConfirmationStatePasswordAutofilled) { 746 TEST_F(ManagePasswordsUIControllerTest, ConfirmationStatePasswordAutofilled) {
744 TestNotChangingStateOnAutofill(password_manager::ui::CONFIRMATION_STATE); 747 TestNotChangingStateOnAutofill(password_manager::ui::CONFIRMATION_STATE);
745 } 748 }
749
750 TEST_F(ManagePasswordsUIControllerTest, OpenBubbleTwice) {
751 // Open the autosignin bubble.
752 ScopedVector<autofill::PasswordForm> local_credentials;
sky 2016/08/12 16:59:35 ScopedVector is deprecated, use std::vector<std::u
vasilii 2016/08/12 17:26:42 We have a tracking bug for this http://crbug.com/5
753 local_credentials.push_back(new autofill::PasswordForm(test_local_form()));
754 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
755 controller()->OnAutoSignin(std::move(local_credentials),
756 test_local_form().origin);
757 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState());
758 // The delegate used by the bubble for communicating with the controller.
759 base::WeakPtr<PasswordsModelDelegate> proxy_delegate =
760 controller()->GetModelDelegateProxy();
761
762 // Open the bubble again.
763 local_credentials.push_back(new autofill::PasswordForm(test_local_form()));
764 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
765 controller()->OnAutoSignin(std::move(local_credentials),
766 test_local_form().origin);
767 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState());
768 // Check the delegate is destroyed. Thus, the first bubble has no way to mess
769 // up with the controller's state.
770 EXPECT_FALSE(proxy_delegate);
771 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698