Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 const base::string16 kNewPassword(UTF8ToUTF16("new_b")); | 549 const base::string16 kNewPassword(UTF8ToUTF16("new_b")); |
| 550 EXPECT_NE(kOldPassword, kNewPassword); | 550 EXPECT_NE(kOldPassword, kNewPassword); |
| 551 new_facebook.password_value = kNewPassword; | 551 new_facebook.password_value = kNewPassword; |
| 552 switch (update_type) { | 552 switch (update_type) { |
| 553 case UPDATE_BY_UPDATELOGIN: | 553 case UPDATE_BY_UPDATELOGIN: |
| 554 BrowserThread::PostTask( | 554 BrowserThread::PostTask( |
| 555 BrowserThread::DB, | 555 BrowserThread::DB, |
| 556 FROM_HERE, | 556 FROM_HERE, |
| 557 base::Bind(base::IgnoreResult(&NativeBackendGnome::UpdateLogin), | 557 base::Bind(base::IgnoreResult(&NativeBackendGnome::UpdateLogin), |
| 558 base::Unretained(&backend), | 558 base::Unretained(&backend), |
| 559 new_facebook)); | 559 new_facebook, |
| 560 base::Owned(new PasswordStoreChangeList))); | |
| 560 break; | 561 break; |
| 561 case UPDATE_BY_ADDLOGIN: | 562 case UPDATE_BY_ADDLOGIN: |
| 562 BrowserThread::PostTask( | 563 BrowserThread::PostTask( |
| 563 BrowserThread::DB, | 564 BrowserThread::DB, |
| 564 FROM_HERE, | 565 FROM_HERE, |
| 565 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), | 566 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), |
| 566 base::Unretained(&backend), | 567 base::Unretained(&backend), |
| 567 new_facebook)); | 568 new_facebook)); |
| 568 break; | 569 break; |
| 569 } | 570 } |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 TEST_F(NativeBackendGnomeTest, PSLUpdatingStrictUpdateLogin) { | 726 TEST_F(NativeBackendGnomeTest, PSLUpdatingStrictUpdateLogin) { |
| 726 CheckPSLUpdate(UPDATE_BY_UPDATELOGIN); | 727 CheckPSLUpdate(UPDATE_BY_UPDATELOGIN); |
| 727 } | 728 } |
| 728 | 729 |
| 729 TEST_F(NativeBackendGnomeTest, PSLUpdatingStrictAddLogin) { | 730 TEST_F(NativeBackendGnomeTest, PSLUpdatingStrictAddLogin) { |
| 730 // TODO(vabr): if AddLogin becomes no longer valid for existing logins, then | 731 // TODO(vabr): if AddLogin becomes no longer valid for existing logins, then |
| 731 // just delete this test. | 732 // just delete this test. |
| 732 CheckPSLUpdate(UPDATE_BY_ADDLOGIN); | 733 CheckPSLUpdate(UPDATE_BY_ADDLOGIN); |
| 733 } | 734 } |
| 734 | 735 |
| 735 TEST_F(NativeBackendGnomeTest, BasicUpdateLogin) { | 736 TEST_F(NativeBackendGnomeTest, BasicUpdateLogin) { |
|
Garrett Casto
2014/05/21 19:14:20
Would you mind adding a test that calling UpdateLo
vasilii
2014/05/22 11:38:14
Done.
| |
| 736 NativeBackendGnome backend(42); | 737 NativeBackendGnome backend(42); |
| 737 backend.Init(); | 738 backend.Init(); |
| 738 | 739 |
| 739 // First add google login. | 740 // First add google login. |
| 740 BrowserThread::PostTask( | 741 BrowserThread::PostTask( |
| 741 BrowserThread::DB, FROM_HERE, | 742 BrowserThread::DB, FROM_HERE, |
| 742 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), | 743 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), |
| 743 base::Unretained(&backend), form_google_)); | 744 base::Unretained(&backend), form_google_)); |
| 744 | 745 |
| 745 RunBothThreads(); | 746 RunBothThreads(); |
| 746 | 747 |
| 747 PasswordForm new_form_google(form_google_); | 748 PasswordForm new_form_google(form_google_); |
| 748 new_form_google.times_used = 1; | 749 new_form_google.times_used = 1; |
| 749 new_form_google.action = GURL("http://www.google.com/different/login"); | 750 new_form_google.action = GURL("http://www.google.com/different/login"); |
| 750 | 751 |
| 751 EXPECT_EQ(1u, mock_keyring_items.size()); | 752 EXPECT_EQ(1u, mock_keyring_items.size()); |
| 752 if (mock_keyring_items.size() > 0) | 753 if (mock_keyring_items.size() > 0) |
| 753 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); | 754 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); |
| 754 | 755 |
| 755 // Update login | 756 // Update login |
| 757 PasswordStoreChangeList changes; | |
| 756 BrowserThread::PostTask( | 758 BrowserThread::PostTask( |
| 757 BrowserThread::DB, FROM_HERE, | 759 BrowserThread::DB, FROM_HERE, |
| 758 base::Bind(base::IgnoreResult(&NativeBackendGnome::UpdateLogin), | 760 base::Bind(base::IgnoreResult(&NativeBackendGnome::UpdateLogin), |
| 759 base::Unretained(&backend), new_form_google)); | 761 base::Unretained(&backend), |
| 762 new_form_google, | |
| 763 base::Unretained(&changes))); | |
| 760 | 764 |
| 761 RunBothThreads(); | 765 RunBothThreads(); |
| 762 | 766 |
| 767 ASSERT_EQ(1u, changes.size()); | |
| 768 EXPECT_EQ(PasswordStoreChange::UPDATE, changes.front().type()); | |
| 769 EXPECT_EQ(new_form_google, changes.front().form()); | |
| 763 EXPECT_EQ(1u, mock_keyring_items.size()); | 770 EXPECT_EQ(1u, mock_keyring_items.size()); |
| 764 if (mock_keyring_items.size() > 0) | 771 if (mock_keyring_items.size() > 0) |
| 765 CheckMockKeyringItem(&mock_keyring_items[0], new_form_google, "chrome-42"); | 772 CheckMockKeyringItem(&mock_keyring_items[0], new_form_google, "chrome-42"); |
| 766 } | 773 } |
| 767 | 774 |
| 768 TEST_F(NativeBackendGnomeTest, BasicRemoveLogin) { | 775 TEST_F(NativeBackendGnomeTest, BasicRemoveLogin) { |
| 769 NativeBackendGnome backend(42); | 776 NativeBackendGnome backend(42); |
| 770 backend.Init(); | 777 backend.Init(); |
| 771 | 778 |
| 772 BrowserThread::PostTask( | 779 BrowserThread::PostTask( |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 891 // Quick check that we got two results back. | 898 // Quick check that we got two results back. |
| 892 EXPECT_EQ(2u, form_list.size()); | 899 EXPECT_EQ(2u, form_list.size()); |
| 893 STLDeleteElements(&form_list); | 900 STLDeleteElements(&form_list); |
| 894 | 901 |
| 895 EXPECT_EQ(1u, mock_keyring_items.size()); | 902 EXPECT_EQ(1u, mock_keyring_items.size()); |
| 896 if (mock_keyring_items.size() > 0) | 903 if (mock_keyring_items.size() > 0) |
| 897 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); | 904 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); |
| 898 } | 905 } |
| 899 | 906 |
| 900 // TODO(mdm): add more basic tests here at some point. | 907 // TODO(mdm): add more basic tests here at some point. |
| OLD | NEW |