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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/bind.h" | 15 #include "base/bind.h" |
16 #include "base/callback.h" | |
16 #include "base/location.h" | 17 #include "base/location.h" |
17 #include "base/pickle.h" | 18 #include "base/pickle.h" |
18 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
19 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
21 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
22 #include "base/threading/thread_task_runner_handle.h" | 23 #include "base/threading/thread_task_runner_handle.h" |
23 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" | 24 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" |
24 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
25 #include "components/autofill/core/common/password_form.h" | 26 #include "components/autofill/core/common/password_form.h" |
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
993 } | 994 } |
994 | 995 |
995 TEST_P(NativeBackendKWalletTest, RemoveLoginsCreatedBetween) { | 996 TEST_P(NativeBackendKWalletTest, RemoveLoginsCreatedBetween) { |
996 TestRemoveLoginsBetween(CREATED); | 997 TestRemoveLoginsBetween(CREATED); |
997 } | 998 } |
998 | 999 |
999 TEST_P(NativeBackendKWalletTest, RemoveLoginsSyncedBetween) { | 1000 TEST_P(NativeBackendKWalletTest, RemoveLoginsSyncedBetween) { |
1000 TestRemoveLoginsBetween(SYNCED); | 1001 TestRemoveLoginsBetween(SYNCED); |
1001 } | 1002 } |
1002 | 1003 |
1003 TEST_P(NativeBackendKWalletTest, DisableAutoSignInForAllLogins) { | 1004 TEST_P(NativeBackendKWalletTest, DisableAutoSignInForOrigins) { |
1004 NativeBackendKWalletStub backend(42, desktop_env_); | 1005 NativeBackendKWalletStub backend(42, desktop_env_); |
1005 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); | 1006 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); |
1006 | 1007 |
1008 form_isc_.skip_zero_click = false; | |
1007 form_google_.skip_zero_click = false; | 1009 form_google_.skip_zero_click = false; |
1008 | 1010 |
1009 BrowserThread::PostTask( | 1011 BrowserThread::PostTask( |
1010 BrowserThread::DB, FROM_HERE, | 1012 BrowserThread::DB, FROM_HERE, |
1011 base::Bind(base::IgnoreResult(&NativeBackendKWallet::AddLogin), | 1013 base::Bind(base::IgnoreResult(&NativeBackendKWallet::AddLogin), |
1014 base::Unretained(&backend), form_isc_)); | |
1015 BrowserThread::PostTask( | |
1016 BrowserThread::DB, FROM_HERE, | |
1017 base::Bind(base::IgnoreResult(&NativeBackendKWallet::AddLogin), | |
1012 base::Unretained(&backend), form_google_)); | 1018 base::Unretained(&backend), form_google_)); |
1013 | 1019 |
1014 RunDBThread(); | 1020 RunDBThread(); |
1015 | 1021 |
1016 // Set the canonical forms to the updated value for the following comparison. | 1022 // Set the canonical forms to the updated value for the following comparison. |
1017 form_google_.skip_zero_click = true; | 1023 form_google_.skip_zero_click = true; |
1018 PasswordStoreChangeList expected_changes; | 1024 PasswordStoreChangeList expected_changes; |
1019 expected_changes.push_back( | 1025 expected_changes.push_back( |
1020 PasswordStoreChange(PasswordStoreChange::UPDATE, form_google_)); | 1026 PasswordStoreChange(PasswordStoreChange::UPDATE, form_google_)); |
1021 | 1027 |
1022 PasswordStoreChangeList changes; | 1028 PasswordStoreChangeList changes; |
1023 BrowserThread::PostTaskAndReplyWithResult( | 1029 BrowserThread::PostTaskAndReplyWithResult( |
1024 BrowserThread::DB, FROM_HERE, | 1030 BrowserThread::DB, FROM_HERE, |
1025 base::Bind(&NativeBackendKWallet::DisableAutoSignInForAllLogins, | 1031 base::Bind(&NativeBackendKWallet::DisableAutoSignInForOrigins, |
1026 base::Unretained(&backend), &changes), | 1032 base::Unretained(&backend), |
1033 base::Bind(&GURL::operator==, | |
1034 base::Unretained(&form_google_.origin)), | |
1035 &changes), | |
1027 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes)); | 1036 base::Bind(&CheckPasswordChangesWithResult, &expected_changes, &changes)); |
1028 RunDBThread(); | 1037 RunDBThread(); |
1029 | 1038 |
1039 ExpectationArray expected; | |
vabr (Chromium)
2016/07/08 19:22:03
nit: Would you mind moving this back after line 10
msramek
2016/07/11 13:09:17
Done.
In my opinion, it helps readability to proc
| |
1030 std::vector<const PasswordForm*> forms; | 1040 std::vector<const PasswordForm*> forms; |
1031 forms.push_back(&form_google_); | 1041 forms.push_back(&form_google_); |
1032 ExpectationArray expected; | |
1033 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); | 1042 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); |
1043 forms.clear(); | |
1044 forms.push_back(&form_isc_); | |
1045 expected.push_back(make_pair(std::string(form_isc_.signon_realm), forms)); | |
1034 CheckPasswordForms("Chrome Form Data (42)", expected); | 1046 CheckPasswordForms("Chrome Form Data (42)", expected); |
1035 } | 1047 } |
1036 | 1048 |
1037 TEST_P(NativeBackendKWalletTest, ReadDuplicateForms) { | 1049 TEST_P(NativeBackendKWalletTest, ReadDuplicateForms) { |
1038 NativeBackendKWalletStub backend(42, desktop_env_); | 1050 NativeBackendKWalletStub backend(42, desktop_env_); |
1039 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); | 1051 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); |
1040 | 1052 |
1041 // Add 2 slightly different password forms. | 1053 // Add 2 slightly different password forms. |
1042 const char unique_string[] = "unique_unique_string"; | 1054 const char unique_string[] = "unique_unique_string"; |
1043 const char unique_string_replacement[] = "uniKue_unique_string"; | 1055 const char unique_string_replacement[] = "uniKue_unique_string"; |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1396 CheckVersion6Pickle(true); | 1408 CheckVersion6Pickle(true); |
1397 } | 1409 } |
1398 | 1410 |
1399 TEST_F(NativeBackendKWalletPickleTest, CheckVersion7Pickle) { | 1411 TEST_F(NativeBackendKWalletPickleTest, CheckVersion7Pickle) { |
1400 CheckVersion7Pickle(); | 1412 CheckVersion7Pickle(); |
1401 } | 1413 } |
1402 | 1414 |
1403 TEST_F(NativeBackendKWalletPickleTest, CheckVersion8Pickle) { | 1415 TEST_F(NativeBackendKWalletPickleTest, CheckVersion8Pickle) { |
1404 CheckVersion8Pickle(); | 1416 CheckVersion8Pickle(); |
1405 } | 1417 } |
OLD | NEW |