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 #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 Loading... | |
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()->OnShowManualFallback(std::move(test_form_manager), is_update); | |
vasilii
2017/07/21 12:48:19
You can also check opened_bubble()
kolos1
2017/07/24 15:33:30
Done.
| |
819 ExpectIconStateIs(is_update | |
vasilii
2017/07/21 12:48:20
Why not ExpectIconAndControllerStateIs?
kolos1
2017/07/24 15:33:30
Done.
| |
820 ? password_manager::ui::PENDING_PASSWORD_UPDATE_STATE | |
821 : password_manager::ui::PENDING_PASSWORD_STATE); | |
822 | |
823 if (is_update) { | |
824 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); | |
vasilii
2017/07/21 12:48:19
Why do we expect it only here?
kolos1
2017/07/24 15:33:30
It is strange to me too. UpdatePassword calls Upda
vasilii
2017/07/25 11:17:46
Ahh, that's my own trick. The function still shoul
kolos1
2017/07/26 13:40:57
Acknowledged.
| |
825 controller()->UpdatePassword(autofill::PasswordForm()); | |
826 } else { | |
827 controller()->SavePassword(test_local_form().username_value); | |
828 } | |
829 ExpectIconStateIs(password_manager::ui::MANAGE_STATE); | |
830 } | |
831 } | |
832 | |
833 TEST_F(ManagePasswordsUIControllerTest, ManualFallbackForSaving_HideFallback) { | |
834 for (bool is_update : {false, true}) { | |
835 SCOPED_TRACE(testing::Message("is_update = ") << is_update); | |
836 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( | |
837 CreateFormManager()); | |
838 test_form_manager->ProvisionallySave( | |
839 test_local_form(), | |
840 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); | |
841 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); | |
842 controller()->OnShowManualFallback(std::move(test_form_manager), is_update); | |
843 ExpectIconStateIs(is_update | |
844 ? password_manager::ui::PENDING_PASSWORD_UPDATE_STATE | |
845 : password_manager::ui::PENDING_PASSWORD_STATE); | |
846 | |
847 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); | |
848 controller()->OnHideManualFallback(); | |
849 ExpectIconStateIs(password_manager::ui::MANAGE_STATE); | |
850 } | |
851 } | |
852 | |
853 TEST_F(ManagePasswordsUIControllerTest, | |
854 ManualFallbackForSaving_GeneratedPassword) { | |
855 for (bool user_closed_bubble : {false, true}) { | |
856 SCOPED_TRACE(testing::Message("user_closed_bubble = ") | |
857 << user_closed_bubble); | |
858 std::unique_ptr<password_manager::PasswordFormManager> test_form_manager( | |
859 CreateFormManager()); | |
860 test_form_manager->ProvisionallySave( | |
861 test_local_form(), | |
862 password_manager::PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); | |
863 test_form_manager->SetHasGeneratedPassword(true); | |
864 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); | |
865 controller()->OnShowManualFallback(std::move(test_form_manager), false); | |
866 ExpectIconStateIs(password_manager::ui::CONFIRMATION_STATE); | |
867 | |
868 EXPECT_CALL(*controller(), OnUpdateBubbleAndIconVisibility()); | |
869 if (user_closed_bubble) | |
870 controller()->OnBubbleHidden(); | |
871 else // The user removed the generated password. | |
872 controller()->OnHideManualFallback(); | |
vasilii
2017/07/21 12:48:20
I need more info what's being tested here.
OnBubbl
kolos1
2017/07/24 15:33:29
Added to comments to all tests.
| |
873 ExpectIconStateIs(password_manager::ui::MANAGE_STATE); | |
874 } | |
875 } | |
OLD | NEW |