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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 EXPECT_EQ(expected.origin, actual.origin); | 229 EXPECT_EQ(expected.origin, actual.origin); |
230 EXPECT_EQ(expected.password_value, actual.password_value); | 230 EXPECT_EQ(expected.password_value, actual.password_value); |
231 EXPECT_EQ(expected.action, actual.action); | 231 EXPECT_EQ(expected.action, actual.action); |
232 EXPECT_EQ(expected.username_element, actual.username_element); | 232 EXPECT_EQ(expected.username_element, actual.username_element); |
233 EXPECT_EQ(expected.username_value, actual.username_value); | 233 EXPECT_EQ(expected.username_value, actual.username_value); |
234 EXPECT_EQ(expected.password_element, actual.password_element); | 234 EXPECT_EQ(expected.password_element, actual.password_element); |
235 EXPECT_EQ(expected.submit_element, actual.submit_element); | 235 EXPECT_EQ(expected.submit_element, actual.submit_element); |
236 EXPECT_EQ(expected.signon_realm, actual.signon_realm); | 236 EXPECT_EQ(expected.signon_realm, actual.signon_realm); |
237 EXPECT_EQ(expected.ssl_valid, actual.ssl_valid); | 237 EXPECT_EQ(expected.ssl_valid, actual.ssl_valid); |
238 EXPECT_EQ(expected.preferred, actual.preferred); | 238 EXPECT_EQ(expected.preferred, actual.preferred); |
239 // We don't check the date created. It varies due to bug in the | 239 EXPECT_EQ(expected.date_created, actual.date_created); |
240 // serialization. Integer seconds are saved instead of microseconds. | |
241 EXPECT_EQ(expected.blacklisted_by_user, actual.blacklisted_by_user); | 240 EXPECT_EQ(expected.blacklisted_by_user, actual.blacklisted_by_user); |
242 EXPECT_EQ(expected.type, actual.type); | 241 EXPECT_EQ(expected.type, actual.type); |
243 EXPECT_EQ(expected.times_used, actual.times_used); | 242 EXPECT_EQ(expected.times_used, actual.times_used); |
244 EXPECT_EQ(expected.scheme, actual.scheme); | 243 EXPECT_EQ(expected.scheme, actual.scheme); |
245 EXPECT_EQ(expected.date_synced, actual.date_synced); | 244 EXPECT_EQ(expected.date_synced, actual.date_synced); |
246 EXPECT_EQ(expected.display_name, actual.display_name); | 245 EXPECT_EQ(expected.display_name, actual.display_name); |
247 EXPECT_EQ(expected.avatar_url, actual.avatar_url); | 246 EXPECT_EQ(expected.avatar_url, actual.avatar_url); |
248 EXPECT_EQ(expected.federation_url, actual.federation_url); | 247 EXPECT_EQ(expected.federation_url, actual.federation_url); |
249 EXPECT_EQ(expected.is_zero_click, actual.is_zero_click); | 248 EXPECT_EQ(expected.is_zero_click, actual.is_zero_click); |
250 } | 249 } |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 EXPECT_FALSE(CheckCredentialAvailability( | 520 EXPECT_FALSE(CheckCredentialAvailability( |
522 other_auth_, GURL("http://first.example.com"), scheme, nullptr)); | 521 other_auth_, GURL("http://first.example.com"), scheme, nullptr)); |
523 // Do match non-HTML forms from the same origin. | 522 // Do match non-HTML forms from the same origin. |
524 EXPECT_TRUE(CheckCredentialAvailability( | 523 EXPECT_TRUE(CheckCredentialAvailability( |
525 other_auth_, GURL("http://www.example.com/"), scheme, nullptr)); | 524 other_auth_, GURL("http://www.example.com/"), scheme, nullptr)); |
526 } | 525 } |
527 | 526 |
528 void CheckRemoveLoginsBetween(RemoveBetweenMethod date_to_test) { | 527 void CheckRemoveLoginsBetween(RemoveBetweenMethod date_to_test) { |
529 NativeBackendLibsecret backend(42); | 528 NativeBackendLibsecret backend(42); |
530 | 529 |
| 530 base::Time now = base::Time::Now(); |
| 531 base::Time next_day = now + base::TimeDelta::FromDays(1); |
531 form_google_.date_synced = base::Time(); | 532 form_google_.date_synced = base::Time(); |
532 form_isc_.date_synced = base::Time(); | 533 form_isc_.date_synced = base::Time(); |
533 form_google_.date_created = base::Time(); | 534 form_google_.date_created = now; |
534 form_isc_.date_created = base::Time(); | 535 form_isc_.date_created = now; |
535 base::Time now = base::Time::Now(); | |
536 base::Time next_day = now + base::TimeDelta::FromDays(1); | |
537 if (date_to_test == CREATED) { | 536 if (date_to_test == CREATED) { |
538 // http://crbug.com/374132. Remove the next line once it's fixed. | |
539 next_day = base::Time::FromTimeT(next_day.ToTimeT()); | |
540 form_google_.date_created = now; | 537 form_google_.date_created = now; |
541 form_isc_.date_created = next_day; | 538 form_isc_.date_created = next_day; |
542 } else { | 539 } else { |
543 form_google_.date_synced = now; | 540 form_google_.date_synced = now; |
544 form_isc_.date_synced = next_day; | 541 form_isc_.date_synced = next_day; |
545 } | 542 } |
546 | 543 |
547 backend.AddLogin(form_google_); | 544 backend.AddLogin(form_google_); |
548 backend.AddLogin(form_isc_); | 545 backend.AddLogin(form_isc_); |
549 | 546 |
(...skipping 16 matching lines...) Expand all Loading... |
566 CheckMockSecretItem(global_mock_libsecret_items[0], form_isc_, | 563 CheckMockSecretItem(global_mock_libsecret_items[0], form_isc_, |
567 "chrome-42"); | 564 "chrome-42"); |
568 | 565 |
569 // Remove form_isc_. | 566 // Remove form_isc_. |
570 expected_changes.clear(); | 567 expected_changes.clear(); |
571 expected_changes.push_back( | 568 expected_changes.push_back( |
572 PasswordStoreChange(PasswordStoreChange::REMOVE, form_isc_)); | 569 PasswordStoreChange(PasswordStoreChange::REMOVE, form_isc_)); |
573 | 570 |
574 result = base::Bind(method, base::Unretained(&backend), next_day, | 571 result = base::Bind(method, base::Unretained(&backend), next_day, |
575 base::Time(), &changes).Run(); | 572 base::Time(), &changes).Run(); |
| 573 |
576 CheckPasswordChangesWithResult(&expected_changes, &changes, result); | 574 CheckPasswordChangesWithResult(&expected_changes, &changes, result); |
577 | 575 |
578 EXPECT_EQ(0u, global_mock_libsecret_items.size()); | 576 EXPECT_EQ(0u, global_mock_libsecret_items.size()); |
579 } | 577 } |
580 | 578 |
581 base::MessageLoopForUI message_loop_; | 579 base::MessageLoopForUI message_loop_; |
582 | 580 |
583 // Provide some test forms to avoid having to set them up in each test. | 581 // Provide some test forms to avoid having to set them up in each test. |
584 PasswordForm form_google_; | 582 PasswordForm form_google_; |
585 PasswordForm form_facebook_; | 583 PasswordForm form_facebook_; |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 | 834 |
837 ScopedVector<autofill::PasswordForm> form_list; | 835 ScopedVector<autofill::PasswordForm> form_list; |
838 backend.GetAutofillableLogins(&form_list); | 836 backend.GetAutofillableLogins(&form_list); |
839 | 837 |
840 EXPECT_EQ(1u, form_list.size()); | 838 EXPECT_EQ(1u, form_list.size()); |
841 EXPECT_EQ(GURL(""), form_list[0]->avatar_url); | 839 EXPECT_EQ(GURL(""), form_list[0]->avatar_url); |
842 EXPECT_FALSE(form_list[0]->ssl_valid); | 840 EXPECT_FALSE(form_list[0]->ssl_valid); |
843 } | 841 } |
844 | 842 |
845 // TODO(mdm): add more basic tests here at some point. | 843 // TODO(mdm): add more basic tests here at some point. |
OLD | NEW |