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

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

Issue 2915763003: [Password Manager] Show omnibox icon and anchored prompt once user start typing password (Closed)
Patch Set: ui tests Created 3 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 <map> 5 #include <map>
6 #include <memory> 6 #include <memory>
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 // Open the bubble again. 798 // Open the bubble again.
799 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form())); 799 local_credentials.emplace_back(new autofill::PasswordForm(test_local_form()));
800 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); 800 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
801 controller()->OnAutoSignin(std::move(local_credentials), 801 controller()->OnAutoSignin(std::move(local_credentials),
802 test_local_form().origin); 802 test_local_form().origin);
803 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState()); 803 EXPECT_EQ(password_manager::ui::AUTO_SIGNIN_STATE, controller()->GetState());
804 // Check the delegate is destroyed. Thus, the first bubble has no way to mess 804 // Check the delegate is destroyed. Thus, the first bubble has no way to mess
805 // up with the controller's state. 805 // up with the controller's state.
806 EXPECT_FALSE(proxy_delegate); 806 EXPECT_FALSE(proxy_delegate);
807 } 807 }
808
809 TEST_F(ManagePasswordsUIControllerTest, ManualFallbackForSaving_UseFallback) {
810 for (bool is_update : {false, true}) {
811 SCOPED_TRACE(testing::Message("is_update = ") << is_update);
812 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
813 CreateFormManager());
814 test_form_manager->ProvisionallySave(
815 test_local_form(),
816 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
817 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
818 controller()->OnShowManualFallbackForSaving(std::move(test_form_manager),
819 is_update);
820 ExpectIconAndControllerStateIs(
821 is_update ? password_manager::ui::PENDING_PASSWORD_UPDATE_STATE
822 : password_manager::ui::PENDING_PASSWORD_STATE);
823 EXPECT_FALSE(controller()->opened_bubble());
824
825 // A user clicks on omnibox icon, opens the bubble and press Save/Update.
826 if (is_update) {
827 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
828 controller()->UpdatePassword(autofill::PasswordForm());
829 } else {
830 controller()->SavePassword(test_local_form().username_value);
831 }
832 ExpectIconAndControllerStateIs(password_manager::ui::MANAGE_STATE);
833 testing::Mock::VerifyAndClearExpectations(controller());
834 }
835 }
836
837 TEST_F(ManagePasswordsUIControllerTest, ManualFallbackForSaving_HideFallback) {
838 for (bool is_update : {false, true}) {
839 SCOPED_TRACE(testing::Message("is_update = ") << is_update);
840 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
841 CreateFormManager());
842 test_form_manager->ProvisionallySave(
843 test_local_form(),
844 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
845 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
846 controller()->OnShowManualFallbackForSaving(std::move(test_form_manager),
847 is_update);
848 ExpectIconAndControllerStateIs(
849 is_update ? password_manager::ui::PENDING_PASSWORD_UPDATE_STATE
850 : password_manager::ui::PENDING_PASSWORD_STATE);
851 EXPECT_FALSE(controller()->opened_bubble());
852
853 // A user clears the password field. It hides the fallback.
854 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
855 controller()->OnHideManualFallbackForSaving();
856 ExpectIconAndControllerStateIs(password_manager::ui::MANAGE_STATE);
857 testing::Mock::VerifyAndClearExpectations(controller());
858 }
859 }
860
861 TEST_F(ManagePasswordsUIControllerTest,
862 ManualFallbackForSaving_GeneratedPassword) {
863 for (bool user_closed_bubble : {false, true}) {
864 SCOPED_TRACE(testing::Message("user_closed_bubble = ")
865 << user_closed_bubble);
866 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
867 CreateFormManager());
868 test_form_manager->ProvisionallySave(
869 test_local_form(),
870 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
871 test_form_manager->SetHasGeneratedPassword(true);
872 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
873 controller()->OnShowManualFallbackForSaving(std::move(test_form_manager),
874 false);
875 ExpectIconAndControllerStateIs(password_manager::ui::CONFIRMATION_STATE);
876 EXPECT_FALSE(controller()->opened_bubble());
877
878 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
879 if (user_closed_bubble) {
880 // A user opens the confirmation bubble and presses OK.
881 controller()->OnBubbleHidden();
882 } else {
883 // The user removes the generated password. It hides the fallback.
884 controller()->OnHideManualFallbackForSaving();
885 }
886 ExpectIconAndControllerStateIs(password_manager::ui::MANAGE_STATE);
887 testing::Mock::VerifyAndClearExpectations(controller());
888 }
889 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698