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

Side by Side Diff: chrome/browser/ui/views/passwords/password_dialog_view_browsertest.cc

Issue 1730893002: Revert of Remove DialogDelegate::OnClosed() which is redundant with (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 6 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 9 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/browser/ui/views/frame/browser_view.h"
12 #include "chrome/browser/ui/views/passwords/account_chooser_dialog_view.h" 11 #include "chrome/browser/ui/views/passwords/account_chooser_dialog_view.h"
13 #include "chrome/browser/ui/views/passwords/auto_signin_first_run_dialog_view.h" 12 #include "chrome/browser/ui/views/passwords/auto_signin_first_run_dialog_view.h"
14 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 14 #include "chrome/test/base/ui_test_utils.h"
16 #include "components/password_manager/core/browser/password_bubble_experiment.h" 15 #include "components/password_manager/core/browser/password_bubble_experiment.h"
17 #include "components/password_manager/core/common/password_manager_pref_names.h" 16 #include "components/password_manager/core/common/password_manager_pref_names.h"
18 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
19 #include "net/url_request/test_url_fetcher_factory.h" 18 #include "net/url_request/test_url_fetcher_factory.h"
20 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
21 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 193
195 SetupChooseCredentials(std::move(local_credentials), 194 SetupChooseCredentials(std::move(local_credentials),
196 ScopedVector<autofill::PasswordForm>(), origin); 195 ScopedVector<autofill::PasswordForm>(), origin);
197 ASSERT_TRUE(controller()->current_account_chooser()); 196 ASSERT_TRUE(controller()->current_account_chooser());
198 AccountChooserDialogView* dialog = controller()->current_account_chooser(); 197 AccountChooserDialogView* dialog = controller()->current_account_chooser();
199 EXPECT_CALL(*this, 198 EXPECT_CALL(*this,
200 OnChooseCredential(Field( 199 OnChooseCredential(Field(
201 &password_manager::CredentialInfo::type, 200 &password_manager::CredentialInfo::type,
202 password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY))); 201 password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY)));
203 EXPECT_CALL(*controller(), OnDialogClosed()); 202 EXPECT_CALL(*controller(), OnDialogClosed());
204 dialog->GetWidget()->Close(); 203 EXPECT_TRUE(dialog->Close());
205 204
206 EXPECT_FALSE(controller()->current_autosignin_prompt()); 205 EXPECT_FALSE(controller()->current_autosignin_prompt());
207 } 206 }
208 207
209 IN_PROC_BROWSER_TEST_F( 208 IN_PROC_BROWSER_TEST_F(
210 PasswordDialogViewTest, 209 PasswordDialogViewTest,
211 PopupAccountChooserWithMultipleCredentialsReturnNonEmpty) { 210 PopupAccountChooserWithMultipleCredentialsReturnNonEmpty) {
212 GURL origin("https://example.com"); 211 GURL origin("https://example.com");
213 ScopedVector<autofill::PasswordForm> local_credentials; 212 ScopedVector<autofill::PasswordForm> local_credentials;
214 autofill::PasswordForm form; 213 autofill::PasswordForm form;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 SetupChooseCredentials(std::move(local_credentials), 254 SetupChooseCredentials(std::move(local_credentials),
256 ScopedVector<autofill::PasswordForm>(), origin); 255 ScopedVector<autofill::PasswordForm>(), origin);
257 256
258 EXPECT_TRUE(controller()->current_account_chooser()); 257 EXPECT_TRUE(controller()->current_account_chooser());
259 AccountChooserDialogView* dialog = controller()->current_account_chooser(); 258 AccountChooserDialogView* dialog = controller()->current_account_chooser();
260 EXPECT_CALL(*this, 259 EXPECT_CALL(*this,
261 OnChooseCredential(Field( 260 OnChooseCredential(Field(
262 &password_manager::CredentialInfo::type, 261 &password_manager::CredentialInfo::type,
263 password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY))); 262 password_manager::CredentialType::CREDENTIAL_TYPE_EMPTY)));
264 EXPECT_CALL(*controller(), OnDialogClosed()); 263 EXPECT_CALL(*controller(), OnDialogClosed());
265 dialog->GetWidget()->Close(); 264 EXPECT_TRUE(dialog->Close());
266 EXPECT_FALSE(controller()->current_autosignin_prompt()); 265 EXPECT_FALSE(controller()->current_autosignin_prompt());
267 } 266 }
268 267
269 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, 268 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest,
270 PopupAccountChooserWithSingleCredentialReturnNonEmpty) { 269 PopupAccountChooserWithSingleCredentialReturnNonEmpty) {
271 GURL origin("https://example.com"); 270 GURL origin("https://example.com");
272 ScopedVector<autofill::PasswordForm> local_credentials; 271 ScopedVector<autofill::PasswordForm> local_credentials;
273 autofill::PasswordForm form; 272 autofill::PasswordForm form;
274 form.origin = origin; 273 form.origin = origin;
275 form.display_name = base::ASCIIToUTF16("Peter"); 274 form.display_name = base::ASCIIToUTF16("Peter");
(...skipping 10 matching lines...) Expand all
286 EXPECT_CALL(*this, 285 EXPECT_CALL(*this,
287 OnChooseCredential(Field( 286 OnChooseCredential(Field(
288 &password_manager::CredentialInfo::type, 287 &password_manager::CredentialInfo::type,
289 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD))); 288 password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD)));
290 EXPECT_TRUE( 289 EXPECT_TRUE(
291 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( 290 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience(
292 browser()->profile()->GetPrefs())); 291 browser()->profile()->GetPrefs()));
293 controller()->ChooseCredential( 292 controller()->ChooseCredential(
294 form, password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD); 293 form, password_manager::CredentialType::CREDENTIAL_TYPE_PASSWORD);
295 294
295 EXPECT_CALL(*controller(), OnDialogClosed());
296 EXPECT_TRUE(controller()->current_autosignin_prompt()); 296 EXPECT_TRUE(controller()->current_autosignin_prompt());
297 } 297 }
298 298
299 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, 299 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest,
300 PopupAccountChooserWithDisabledAutoSignin) { 300 PopupAccountChooserWithDisabledAutoSignin) {
301 EXPECT_TRUE( 301 EXPECT_TRUE(
302 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( 302 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience(
303 browser()->profile()->GetPrefs())); 303 browser()->profile()->GetPrefs()));
304 GURL origin("https://example.com"); 304 GURL origin("https://example.com");
305 ScopedVector<autofill::PasswordForm> local_credentials; 305 ScopedVector<autofill::PasswordForm> local_credentials;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 370
371 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, PopupAutoSigninPrompt) { 371 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, PopupAutoSigninPrompt) {
372 EXPECT_TRUE( 372 EXPECT_TRUE(
373 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( 373 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience(
374 browser()->profile()->GetPrefs())); 374 browser()->profile()->GetPrefs()));
375 controller()->OnPromptEnableAutoSignin(); 375 controller()->OnPromptEnableAutoSignin();
376 ASSERT_TRUE(controller()->current_autosignin_prompt()); 376 ASSERT_TRUE(controller()->current_autosignin_prompt());
377 EXPECT_EQ(password_manager::ui::INACTIVE_STATE, controller()->GetState()); 377 EXPECT_EQ(password_manager::ui::INACTIVE_STATE, controller()->GetState());
378 AutoSigninFirstRunDialogView* dialog = 378 AutoSigninFirstRunDialogView* dialog =
379 controller()->current_autosignin_prompt(); 379 controller()->current_autosignin_prompt();
380 // This is the way how ESC is processed. It's important to reproduce it
381 // because of double AutoSigninFirstRunDialogView::OnClosed call due to a bug
382 // http://crbug.com/583330.
380 ui::Accelerator esc(ui::VKEY_ESCAPE, 0); 383 ui::Accelerator esc(ui::VKEY_ESCAPE, 0);
381 EXPECT_CALL(*controller(), OnDialogClosed()); 384 EXPECT_CALL(*controller(), OnDialogClosed());
382 EXPECT_TRUE(dialog->GetWidget()->client_view()->AcceleratorPressed(esc)); 385 EXPECT_TRUE(dialog->GetWidget()->client_view()->AcceleratorPressed(esc));
383 content::RunAllPendingInMessageLoop();
384 testing::Mock::VerifyAndClearExpectations(controller()); 386 testing::Mock::VerifyAndClearExpectations(controller());
385 EXPECT_TRUE( 387 EXPECT_TRUE(
386 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( 388 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience(
387 browser()->profile()->GetPrefs())); 389 browser()->profile()->GetPrefs()));
388 } 390 }
389 391
390 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest, 392 IN_PROC_BROWSER_TEST_F(PasswordDialogViewTest,
391 PopupAutoSigninPromptAfterBlockedZeroclick) { 393 PopupAutoSigninPromptAfterBlockedZeroclick) {
392 EXPECT_TRUE( 394 EXPECT_TRUE(
393 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( 395 password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience(
(...skipping 30 matching lines...) Expand all
424 client()->NotifyUserAutoSigninBlockedOnFirstRun(std::move(blocked_form)); 426 client()->NotifyUserAutoSigninBlockedOnFirstRun(std::move(blocked_form));
425 client()->NotifySuccessfulLoginWithExistingPassword(form); 427 client()->NotifySuccessfulLoginWithExistingPassword(form);
426 ASSERT_FALSE(controller()->current_autosignin_prompt()); 428 ASSERT_FALSE(controller()->current_autosignin_prompt());
427 browser()->profile()->GetPrefs()->SetBoolean( 429 browser()->profile()->GetPrefs()->SetBoolean(
428 password_manager::prefs::kCredentialsEnableAutosignin, true); 430 password_manager::prefs::kCredentialsEnableAutosignin, true);
429 431
430 // Successful login with the same form after block will prompt: 432 // Successful login with the same form after block will prompt:
431 blocked_form.reset(new autofill::PasswordForm(form)); 433 blocked_form.reset(new autofill::PasswordForm(form));
432 client()->NotifyUserAutoSigninBlockedOnFirstRun(std::move(blocked_form)); 434 client()->NotifyUserAutoSigninBlockedOnFirstRun(std::move(blocked_form));
433 client()->NotifySuccessfulLoginWithExistingPassword(form); 435 client()->NotifySuccessfulLoginWithExistingPassword(form);
436 EXPECT_CALL(*controller(), OnDialogClosed());
434 ASSERT_TRUE(controller()->current_autosignin_prompt()); 437 ASSERT_TRUE(controller()->current_autosignin_prompt());
435 } 438 }
436 439
437 } // namespace 440 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698