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

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: Changes addressed to vasilii@ comments Created 3 years, 5 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 }
vasilii 2017/07/25 11:17:47 How about clearing the expectations on controller(
kolos1 2017/07/26 13:40:57 Done.
834 }
835
836 TEST_F(ManagePasswordsUIControllerTest, ManualFallbackForSaving_HideFallback) {
837 for (bool is_update : {false, true}) {
838 SCOPED_TRACE(testing::Message("is_update = ") << is_update);
839 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
840 CreateFormManager());
841 test_form_manager->ProvisionallySave(
842 test_local_form(),
843 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
844 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
845 controller()->OnShowManualFallbackForSaving(std::move(test_form_manager),
846 is_update);
847 ExpectIconAndControllerStateIs(
848 is_update ? password_manager::ui::PENDING_PASSWORD_UPDATE_STATE
849 : password_manager::ui::PENDING_PASSWORD_STATE);
850 EXPECT_FALSE(controller()->opened_bubble());
851
852 // A user clears the password field. It hides the fallback.
853 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
854 controller()->OnHideManualFallbackForSaving();
855 ExpectIconAndControllerStateIs(password_manager::ui::MANAGE_STATE);
856 }
857 }
858
859 TEST_F(ManagePasswordsUIControllerTest,
860 ManualFallbackForSaving_GeneratedPassword) {
861 for (bool user_closed_bubble : {false, true}) {
862 SCOPED_TRACE(testing::Message("user_closed_bubble = ")
863 << user_closed_bubble);
864 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager(
865 CreateFormManager());
866 test_form_manager->ProvisionallySave(
867 test_local_form(),
868 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
869 test_form_manager->SetHasGeneratedPassword(true);
870 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
871 controller()->OnShowManualFallbackForSaving(std::move(test_form_manager),
872 false);
873 ExpectIconAndControllerStateIs(password_manager::ui::CONFIRMATION_STATE);
874 EXPECT_FALSE(controller()->opened_bubble());
875
876 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility());
877 if (user_closed_bubble) {
878 // A user opens the confirmation bubble and presses OK.
879 controller()->OnBubbleHidden();
880 } else {
881 // The user removes the generated password. It hides the fallback.
882 controller()->OnHideManualFallbackForSaving();
883 }
884 ExpectIconAndControllerStateIs(password_manager::ui::MANAGE_STATE);
885 }
886 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698