OLD | NEW |
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 #import "ios/chrome/browser/passwords/password_generation_agent.h" | 5 #import "ios/chrome/browser/passwords/password_generation_agent.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 // password field in the account creation form. | 428 // password field in the account creation form. |
429 TEST_F(PasswordGenerationAgentTest, | 429 TEST_F(PasswordGenerationAgentTest, |
430 ShouldStartGenerationWhenPasswordFieldFocused) { | 430 ShouldStartGenerationWhenPasswordFieldFocused) { |
431 LoadAccountCreationForm(); | 431 LoadAccountCreationForm(); |
432 id mock = [OCMockObject partialMockForObject:accessory_controller()]; | 432 id mock = [OCMockObject partialMockForObject:accessory_controller()]; |
433 [[mock expect] showCustomInputAccessoryView:[OCMArg any]]; | 433 [[mock expect] showCustomInputAccessoryView:[OCMArg any]]; |
434 SimulateFormActivity(kAccountCreationFormName, kAccountCreationFieldName, | 434 SimulateFormActivity(kAccountCreationFormName, kAccountCreationFieldName, |
435 @"focus"); | 435 @"focus"); |
436 | 436 |
437 EXPECT_OCMOCK_VERIFY(mock); | 437 EXPECT_OCMOCK_VERIFY(mock); |
438 [mock stop]; | 438 [mock stopMocking]; |
439 } | 439 } |
440 | 440 |
441 // Tests that requesting password generation shows the alert UI. | 441 // Tests that requesting password generation shows the alert UI. |
442 TEST_F(PasswordGenerationAgentTest, ShouldShowAlertWhenGenerationRequested) { | 442 TEST_F(PasswordGenerationAgentTest, ShouldShowAlertWhenGenerationRequested) { |
443 LoadAccountCreationForm(); | 443 LoadAccountCreationForm(); |
444 id mock = [OCMockObject partialMockForObject:accessory_controller()]; | 444 id mock = [OCMockObject partialMockForObject:accessory_controller()]; |
445 [[mock expect] showCustomInputAccessoryView:[OCMArg any]]; | 445 [[mock expect] showCustomInputAccessoryView:[OCMArg any]]; |
446 SimulateFormActivity(kAccountCreationFormName, kAccountCreationFieldName, | 446 SimulateFormActivity(kAccountCreationFormName, kAccountCreationFieldName, |
447 @"focus"); | 447 @"focus"); |
448 EXPECT_EQ(NO, mock_ui_delegate().UIShown); | 448 EXPECT_EQ(NO, mock_ui_delegate().UIShown); |
449 | 449 |
450 [agent() generatePassword]; | 450 [agent() generatePassword]; |
451 EXPECT_EQ(YES, mock_ui_delegate().UIShown); | 451 EXPECT_EQ(YES, mock_ui_delegate().UIShown); |
452 | 452 |
453 EXPECT_OCMOCK_VERIFY(mock); | 453 EXPECT_OCMOCK_VERIFY(mock); |
454 [mock stop]; | 454 [mock stopMocking]; |
455 } | 455 } |
456 | 456 |
457 // Tests that the password generation UI is hidden when the user changes focus | 457 // Tests that the password generation UI is hidden when the user changes focus |
458 // from the password field. | 458 // from the password field. |
459 TEST_F(PasswordGenerationAgentTest, | 459 TEST_F(PasswordGenerationAgentTest, |
460 ShouldStopGenerationWhenDifferentFieldFocused) { | 460 ShouldStopGenerationWhenDifferentFieldFocused) { |
461 LoadAccountCreationForm(); | 461 LoadAccountCreationForm(); |
462 id mock = [OCMockObject partialMockForObject:accessory_controller()]; | 462 id mock = [OCMockObject partialMockForObject:accessory_controller()]; |
463 [[mock expect] showCustomInputAccessoryView:[OCMArg any]]; | 463 [[mock expect] showCustomInputAccessoryView:[OCMArg any]]; |
464 SimulateFormActivity(kAccountCreationFormName, kAccountCreationFieldName, | 464 SimulateFormActivity(kAccountCreationFormName, kAccountCreationFieldName, |
465 @"focus"); | 465 @"focus"); |
466 | 466 |
467 [[mock expect] restoreDefaultInputAccessoryView]; | 467 [[mock expect] restoreDefaultInputAccessoryView]; |
468 SimulateFormActivity(kAccountCreationFormName, kEmailFieldName, @"focus"); | 468 SimulateFormActivity(kAccountCreationFormName, kEmailFieldName, @"focus"); |
469 | 469 |
470 EXPECT_OCMOCK_VERIFY(mock); | 470 EXPECT_OCMOCK_VERIFY(mock); |
471 [mock stop]; | 471 [mock stopMocking]; |
472 } | 472 } |
473 | 473 |
474 // Tests that the password field is filled when the user accepts a generated | 474 // Tests that the password field is filled when the user accepts a generated |
475 // password. | 475 // password. |
476 TEST_F(PasswordGenerationAgentTest, | 476 TEST_F(PasswordGenerationAgentTest, |
477 ShouldFillPasswordFieldAndDismissAlertWhenUserAcceptsGeneratedPassword) { | 477 ShouldFillPasswordFieldAndDismissAlertWhenUserAcceptsGeneratedPassword) { |
478 LoadAccountCreationForm(); | 478 LoadAccountCreationForm(); |
479 // Focus the password field to start generation. | 479 // Focus the password field to start generation. |
480 SimulateFormActivity(kAccountCreationFormName, kAccountCreationFieldName, | 480 SimulateFormActivity(kAccountCreationFormName, kAccountCreationFieldName, |
481 @"focus"); | 481 @"focus"); |
(...skipping 30 matching lines...) Expand all Loading... |
512 [agent() showSavedPasswords:nil]; | 512 [agent() showSavedPasswords:nil]; |
513 EXPECT_EQ(NO, mock_ui_delegate().UIShown); | 513 EXPECT_EQ(NO, mock_ui_delegate().UIShown); |
514 | 514 |
515 GenericChromeCommand* command = base::mac::ObjCCast<GenericChromeCommand>( | 515 GenericChromeCommand* command = base::mac::ObjCCast<GenericChromeCommand>( |
516 g_chrome_execute_command_sender); | 516 g_chrome_execute_command_sender); |
517 EXPECT_TRUE(command); | 517 EXPECT_TRUE(command); |
518 EXPECT_EQ(IDC_SHOW_SAVE_PASSWORDS_SETTINGS, command.tag); | 518 EXPECT_EQ(IDC_SHOW_SAVE_PASSWORDS_SETTINGS, command.tag); |
519 } | 519 } |
520 | 520 |
521 } // namespace | 521 } // namespace |
OLD | NEW |