OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <stdarg.h> | 5 #include <stdarg.h> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 | 790 |
791 actual_changes = backend.AddLogin(form_google_); | 791 actual_changes = backend.AddLogin(form_google_); |
792 CheckPasswordChanges(expected_changes, actual_changes); | 792 CheckPasswordChanges(expected_changes, actual_changes); |
793 | 793 |
794 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 794 EXPECT_EQ(1u, global_mock_libsecret_items.size()); |
795 if (global_mock_libsecret_items.size() > 0) | 795 if (global_mock_libsecret_items.size() > 0) |
796 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | 796 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, |
797 "chrome-42"); | 797 "chrome-42"); |
798 } | 798 } |
799 | 799 |
800 TEST_F(NativeBackendLibsecretTest, ListLoginsAppends) { | |
801 NativeBackendLibsecret backend(42); | |
802 | |
803 backend.AddLogin(form_google_); | |
804 | |
805 // Send the same request twice with the same list both times. | |
806 ScopedVector<autofill::PasswordForm> form_list; | |
807 backend.GetAutofillableLogins(&form_list); | |
808 backend.GetAutofillableLogins(&form_list); | |
809 | |
810 // Quick check that we got two results back. | |
811 EXPECT_EQ(2u, form_list.size()); | |
812 form_list.clear(); | |
813 | |
814 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | |
815 if (global_mock_libsecret_items.size() > 0) | |
816 CheckMockSecretItem(global_mock_libsecret_items[0], form_google_, | |
817 "chrome-42"); | |
818 } | |
819 | |
820 TEST_F(NativeBackendLibsecretTest, AndroidCredentials) { | 800 TEST_F(NativeBackendLibsecretTest, AndroidCredentials) { |
821 NativeBackendLibsecret backend(42); | 801 NativeBackendLibsecret backend(42); |
822 backend.Init(); | 802 backend.Init(); |
823 | 803 |
824 PasswordForm observed_android_form; | 804 PasswordForm observed_android_form; |
825 observed_android_form.scheme = PasswordForm::SCHEME_HTML; | 805 observed_android_form.scheme = PasswordForm::SCHEME_HTML; |
826 observed_android_form.signon_realm = | 806 observed_android_form.signon_realm = |
827 "android://7x7IDboo8u9YKraUsbmVkuf1-@net.rateflix.app/"; | 807 "android://7x7IDboo8u9YKraUsbmVkuf1-@net.rateflix.app/"; |
828 PasswordForm saved_android_form = observed_android_form; | 808 PasswordForm saved_android_form = observed_android_form; |
829 saved_android_form.username_value = base::UTF8ToUTF16("randomusername"); | 809 saved_android_form.username_value = base::UTF8ToUTF16("randomusername"); |
830 saved_android_form.password_value = base::UTF8ToUTF16("password"); | 810 saved_android_form.password_value = base::UTF8ToUTF16("password"); |
831 saved_android_form.date_created = base::Time::Now(); | 811 saved_android_form.date_created = base::Time::Now(); |
832 | 812 |
833 backend.AddLogin(saved_android_form); | 813 backend.AddLogin(saved_android_form); |
834 | 814 |
835 ScopedVector<autofill::PasswordForm> form_list; | 815 ScopedVector<autofill::PasswordForm> form_list; |
836 backend.GetAutofillableLogins(&form_list); | 816 backend.GetAutofillableLogins(&form_list); |
837 | 817 |
838 EXPECT_EQ(1u, form_list.size()); | 818 EXPECT_EQ(1u, form_list.size()); |
839 EXPECT_EQ(saved_android_form, *form_list[0]); | 819 EXPECT_EQ(saved_android_form, *form_list[0]); |
840 } | 820 } |
841 | 821 |
842 | |
843 TEST_F(NativeBackendLibsecretTest, RemoveLoginsCreatedBetween) { | 822 TEST_F(NativeBackendLibsecretTest, RemoveLoginsCreatedBetween) { |
844 CheckRemoveLoginsBetween(CREATED); | 823 CheckRemoveLoginsBetween(CREATED); |
845 } | 824 } |
846 | 825 |
847 TEST_F(NativeBackendLibsecretTest, RemoveLoginsSyncedBetween) { | 826 TEST_F(NativeBackendLibsecretTest, RemoveLoginsSyncedBetween) { |
848 CheckRemoveLoginsBetween(SYNCED); | 827 CheckRemoveLoginsBetween(SYNCED); |
849 } | 828 } |
850 | 829 |
851 TEST_F(NativeBackendLibsecretTest, SomeKeyringAttributesAreMissing) { | 830 TEST_F(NativeBackendLibsecretTest, SomeKeyringAttributesAreMissing) { |
852 // Absent attributes should be filled with default values. | 831 // Absent attributes should be filled with default values. |
853 NativeBackendLibsecret backend(42); | 832 NativeBackendLibsecret backend(42); |
854 | 833 |
855 backend.AddLogin(form_google_); | 834 backend.AddLogin(form_google_); |
856 | 835 |
857 EXPECT_EQ(1u, global_mock_libsecret_items.size()); | 836 EXPECT_EQ(1u, global_mock_libsecret_items.size()); |
858 // Remove a string attribute. | 837 // Remove a string attribute. |
859 global_mock_libsecret_items[0]->RemoveAttribute("avatar_url"); | 838 global_mock_libsecret_items[0]->RemoveAttribute("avatar_url"); |
860 // Remove an integer attribute. | 839 // Remove an integer attribute. |
861 global_mock_libsecret_items[0]->RemoveAttribute("ssl_valid"); | 840 global_mock_libsecret_items[0]->RemoveAttribute("ssl_valid"); |
862 | 841 |
863 ScopedVector<autofill::PasswordForm> form_list; | 842 ScopedVector<autofill::PasswordForm> form_list; |
864 backend.GetAutofillableLogins(&form_list); | 843 backend.GetAutofillableLogins(&form_list); |
865 | 844 |
866 EXPECT_EQ(1u, form_list.size()); | 845 EXPECT_EQ(1u, form_list.size()); |
867 EXPECT_EQ(GURL(""), form_list[0]->avatar_url); | 846 EXPECT_EQ(GURL(""), form_list[0]->avatar_url); |
868 EXPECT_FALSE(form_list[0]->ssl_valid); | 847 EXPECT_FALSE(form_list[0]->ssl_valid); |
869 } | 848 } |
870 | 849 |
871 // TODO(mdm): add more basic tests here at some point. | 850 // TODO(mdm): add more basic tests here at some point. |
OLD | NEW |