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

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

Issue 276583003: Password bubble: Deal correctly with blacklist state changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/passwords/manage_passwords_ui_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/metrics/histogram_samples.h" 5 #include "base/metrics/histogram_samples.h"
6 #include "base/prefs/pref_service.h" 6 #include "base/prefs/pref_service.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/test/statistics_delta_reader.h" 8 #include "base/test/statistics_delta_reader.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h"
10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" 10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // it's being masked by the stub implementation of 95 // it's being masked by the stub implementation of
96 // ManagePasswordsUIControllerMock::PendingCredentials. 96 // ManagePasswordsUIControllerMock::PendingCredentials.
97 EXPECT_EQ(GURL::EmptyGURL(), controller()->origin()); 97 EXPECT_EQ(GURL::EmptyGURL(), controller()->origin());
98 98
99 ManagePasswordsIconMock mock; 99 ManagePasswordsIconMock mock;
100 controller()->UpdateIconAndBubbleState(&mock); 100 controller()->UpdateIconAndBubbleState(&mock);
101 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, mock.state()); 101 EXPECT_EQ(password_manager::ui::PENDING_PASSWORD_STATE, mock.state());
102 } 102 }
103 103
104 TEST_F(ManagePasswordsUIControllerTest, BlacklistBlockedAutofill) { 104 TEST_F(ManagePasswordsUIControllerTest, BlacklistBlockedAutofill) {
105 test_form().blacklisted_by_user = true;
105 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); 106 base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
106 autofill::PasswordFormMap map; 107 autofill::PasswordFormMap map;
107 map[kTestUsername] = &test_form(); 108 map[kTestUsername] = &test_form();
108 controller()->OnBlacklistBlockedAutofill(map); 109 controller()->OnBlacklistBlockedAutofill(map);
109 110
110 EXPECT_EQ(password_manager::ui::BLACKLIST_STATE, controller()->state()); 111 EXPECT_EQ(password_manager::ui::BLACKLIST_STATE, controller()->state());
111 EXPECT_FALSE(controller()->PasswordPendingUserDecision()); 112 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
112 EXPECT_EQ(test_form().origin, controller()->origin()); 113 EXPECT_EQ(test_form().origin, controller()->origin());
113 114
114 ManagePasswordsIconMock mock; 115 ManagePasswordsIconMock mock;
115 controller()->UpdateIconAndBubbleState(&mock); 116 controller()->UpdateIconAndBubbleState(&mock);
116 EXPECT_EQ(password_manager::ui::BLACKLIST_STATE, mock.state()); 117 EXPECT_EQ(password_manager::ui::BLACKLIST_STATE, mock.state());
117 } 118 }
118 119
119 TEST_F(ManagePasswordsUIControllerTest, ClickedUnblacklist) { 120 TEST_F(ManagePasswordsUIControllerTest, ClickedUnblacklist) {
120 base::string16 kTestUsername = base::ASCIIToUTF16("test_username"); 121 base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
121 autofill::PasswordFormMap map; 122 autofill::PasswordFormMap map;
122 map[kTestUsername] = &test_form(); 123 map[kTestUsername] = &test_form();
123 controller()->OnBlacklistBlockedAutofill(map); 124 controller()->OnBlacklistBlockedAutofill(map);
124 controller()->UnblacklistSite(); 125 controller()->UnblacklistSite();
125 126
126 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->state()); 127 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->state());
127 EXPECT_FALSE(controller()->PasswordPendingUserDecision()); 128 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
128 EXPECT_EQ(test_form().origin, controller()->origin()); 129 EXPECT_EQ(test_form().origin, controller()->origin());
129 130
130 ManagePasswordsIconMock mock; 131 ManagePasswordsIconMock mock;
131 controller()->UpdateIconAndBubbleState(&mock); 132 controller()->UpdateIconAndBubbleState(&mock);
132 EXPECT_EQ(password_manager::ui::MANAGE_STATE, mock.state()); 133 EXPECT_EQ(password_manager::ui::MANAGE_STATE, mock.state());
133 } 134 }
135
136 TEST_F(ManagePasswordsUIControllerTest, UnblacklistedElsewhere) {
137 test_form().blacklisted_by_user = true;
138 base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
139 autofill::PasswordFormMap map;
140 map[kTestUsername] = &test_form();
141 controller()->OnBlacklistBlockedAutofill(map);
142
143 password_manager::PasswordStoreChange change(
144 password_manager::PasswordStoreChange::REMOVE, test_form());
145 password_manager::PasswordStoreChangeList list(1, change);
146 controller()->OnLoginsChanged(list);
147
148 EXPECT_EQ(password_manager::ui::MANAGE_STATE, controller()->state());
149 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
150 EXPECT_EQ(test_form().origin, controller()->origin());
151
152 ManagePasswordsIconMock mock;
153 controller()->UpdateIconAndBubbleState(&mock);
154 EXPECT_EQ(password_manager::ui::MANAGE_STATE, mock.state());
155 }
156
157 TEST_F(ManagePasswordsUIControllerTest, BlacklistedElsewhere) {
158 base::string16 kTestUsername = base::ASCIIToUTF16("test_username");
159 autofill::PasswordFormMap map;
160 map[kTestUsername] = &test_form();
161 controller()->OnPasswordAutofilled(map);
162
163 test_form().blacklisted_by_user = true;
164 password_manager::PasswordStoreChange change(
165 password_manager::PasswordStoreChange::ADD, test_form());
166 password_manager::PasswordStoreChangeList list(1, change);
167 controller()->OnLoginsChanged(list);
168
169 EXPECT_EQ(password_manager::ui::BLACKLIST_STATE, controller()->state());
170 EXPECT_FALSE(controller()->PasswordPendingUserDecision());
171 EXPECT_EQ(test_form().origin, controller()->origin());
172
173 ManagePasswordsIconMock mock;
174 controller()->UpdateIconAndBubbleState(&mock);
175 EXPECT_EQ(password_manager::ui::BLACKLIST_STATE, mock.state());
176 }
177
OLDNEW
« no previous file with comments | « chrome/browser/ui/passwords/manage_passwords_ui_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698