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 #include <stddef.h> | 6 #include <stddef.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 EXPECT_TRUE(item_value) << " in attribute " << attribute; | 367 EXPECT_TRUE(item_value) << " in attribute " << attribute; |
368 if (item_value) { | 368 if (item_value) { |
369 EXPECT_EQ(value, static_cast<char*>(item_value)); | 369 EXPECT_EQ(value, static_cast<char*>(item_value)); |
370 } | 370 } |
371 } | 371 } |
372 | 372 |
373 void CheckMockSecretItem(const MockSecretItem* item, | 373 void CheckMockSecretItem(const MockSecretItem* item, |
374 const PasswordForm& form, | 374 const PasswordForm& form, |
375 const std::string& app_string) { | 375 const std::string& app_string) { |
376 EXPECT_EQ(UTF16ToUTF8(form.password_value), item->value->password); | 376 EXPECT_EQ(UTF16ToUTF8(form.password_value), item->value->password); |
377 EXPECT_EQ(22u, g_hash_table_size(item->attributes)); | 377 EXPECT_EQ(21u, g_hash_table_size(item->attributes)); |
378 CheckStringAttribute(item, "origin_url", form.origin.spec()); | 378 CheckStringAttribute(item, "origin_url", form.origin.spec()); |
379 CheckStringAttribute(item, "action_url", form.action.spec()); | 379 CheckStringAttribute(item, "action_url", form.action.spec()); |
380 CheckStringAttribute(item, "username_element", | 380 CheckStringAttribute(item, "username_element", |
381 UTF16ToUTF8(form.username_element)); | 381 UTF16ToUTF8(form.username_element)); |
382 CheckStringAttribute(item, "username_value", | 382 CheckStringAttribute(item, "username_value", |
383 UTF16ToUTF8(form.username_value)); | 383 UTF16ToUTF8(form.username_value)); |
384 CheckStringAttribute(item, "password_element", | 384 CheckStringAttribute(item, "password_element", |
385 UTF16ToUTF8(form.password_element)); | 385 UTF16ToUTF8(form.password_element)); |
386 CheckStringAttribute(item, "submit_element", | 386 CheckStringAttribute(item, "submit_element", |
387 UTF16ToUTF8(form.submit_element)); | 387 UTF16ToUTF8(form.submit_element)); |
388 CheckStringAttribute(item, "signon_realm", form.signon_realm); | 388 CheckStringAttribute(item, "signon_realm", form.signon_realm); |
389 CheckUint32Attribute(item, "ssl_valid", form.ssl_valid); | |
390 CheckUint32Attribute(item, "preferred", form.preferred); | 389 CheckUint32Attribute(item, "preferred", form.preferred); |
391 // We don't check the date created. It varies. | 390 // We don't check the date created. It varies. |
392 CheckUint32Attribute(item, "blacklisted_by_user", form.blacklisted_by_user); | 391 CheckUint32Attribute(item, "blacklisted_by_user", form.blacklisted_by_user); |
393 CheckUint32Attribute(item, "type", form.type); | 392 CheckUint32Attribute(item, "type", form.type); |
394 CheckUint32Attribute(item, "times_used", form.times_used); | 393 CheckUint32Attribute(item, "times_used", form.times_used); |
395 CheckUint32Attribute(item, "scheme", form.scheme); | 394 CheckUint32Attribute(item, "scheme", form.scheme); |
396 CheckStringAttribute( | 395 CheckStringAttribute( |
397 item, "date_synced", | 396 item, "date_synced", |
398 base::Int64ToString(form.date_synced.ToInternalValue())); | 397 base::Int64ToString(form.date_synced.ToInternalValue())); |
399 CheckStringAttribute(item, "display_name", UTF16ToUTF8(form.display_name)); | 398 CheckStringAttribute(item, "display_name", UTF16ToUTF8(form.display_name)); |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 TEST_F(NativeBackendLibsecretTest, SomeKeyringAttributesAreMissing) { | 926 TEST_F(NativeBackendLibsecretTest, SomeKeyringAttributesAreMissing) { |
928 // Absent attributes should be filled with default values. | 927 // Absent attributes should be filled with default values. |
929 NativeBackendLibsecret backend(42); | 928 NativeBackendLibsecret backend(42); |
930 | 929 |
931 VerifiedAdd(&backend, form_google_); | 930 VerifiedAdd(&backend, form_google_); |
932 | 931 |
933 EXPECT_EQ(1u, global_mock_libsecret_items->size()); | 932 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
934 // Remove a string attribute. | 933 // Remove a string attribute. |
935 (*global_mock_libsecret_items)[0]->RemoveAttribute("avatar_url"); | 934 (*global_mock_libsecret_items)[0]->RemoveAttribute("avatar_url"); |
936 // Remove an integer attribute. | 935 // Remove an integer attribute. |
937 (*global_mock_libsecret_items)[0]->RemoveAttribute("ssl_valid"); | 936 (*global_mock_libsecret_items)[0]->RemoveAttribute("times_used"); |
938 | 937 |
939 ScopedVector<autofill::PasswordForm> form_list; | 938 ScopedVector<autofill::PasswordForm> form_list; |
940 EXPECT_TRUE(backend.GetAutofillableLogins(&form_list)); | 939 EXPECT_TRUE(backend.GetAutofillableLogins(&form_list)); |
941 | 940 |
942 EXPECT_EQ(1u, form_list.size()); | 941 EXPECT_EQ(1u, form_list.size()); |
943 EXPECT_EQ(GURL(""), form_list[0]->icon_url); | 942 EXPECT_EQ(GURL(""), form_list[0]->icon_url); |
944 EXPECT_FALSE(form_list[0]->ssl_valid); | 943 EXPECT_EQ(0, form_list[0]->times_used); |
945 } | 944 } |
946 | 945 |
947 TEST_F(NativeBackendLibsecretTest, ReadDuplicateForms) { | 946 TEST_F(NativeBackendLibsecretTest, ReadDuplicateForms) { |
948 NativeBackendLibsecret backend(42); | 947 NativeBackendLibsecret backend(42); |
949 | 948 |
950 // Add 2 slightly different password forms. | 949 // Add 2 slightly different password forms. |
951 const char unique_string[] = "unique_unique_string"; | 950 const char unique_string[] = "unique_unique_string"; |
952 const char unique_string_replacement[] = "uniKue_unique_string"; | 951 const char unique_string_replacement[] = "uniKue_unique_string"; |
953 form_google_.origin = | 952 form_google_.origin = |
954 GURL(std::string("http://www.google.com/") + unique_string); | 953 GURL(std::string("http://www.google.com/") + unique_string); |
(...skipping 21 matching lines...) Expand all Loading... |
976 EXPECT_EQ(form_google_, *form_list[0]); | 975 EXPECT_EQ(form_google_, *form_list[0]); |
977 | 976 |
978 EXPECT_EQ(1u, global_mock_libsecret_items->size()); | 977 EXPECT_EQ(1u, global_mock_libsecret_items->size()); |
979 if (!global_mock_libsecret_items->empty()) { | 978 if (!global_mock_libsecret_items->empty()) { |
980 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, | 979 CheckMockSecretItem((*global_mock_libsecret_items)[0], form_google_, |
981 "chrome-42"); | 980 "chrome-42"); |
982 } | 981 } |
983 } | 982 } |
984 | 983 |
985 // TODO(mdm): add more basic tests here at some point. | 984 // TODO(mdm): add more basic tests here at some point. |
OLD | NEW |