Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: chrome/browser/password_manager/password_store_x_unittest.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/password_manager/password_store_x.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6
7 #include <string> 8 #include <string>
9 #include <utility>
8 10
9 #include "base/bind.h" 11 #include "base/bind.h"
10 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
11 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
13 #include "base/prefs/pref_service.h" 15 #include "base/prefs/pref_service.h"
14 #include "base/run_loop.h" 16 #include "base/run_loop.h"
15 #include "base/stl_util.h" 17 #include "base/stl_util.h"
16 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
17 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
18 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
19 #include "base/thread_task_runner_handle.h" 21 #include "base/thread_task_runner_handle.h"
20 #include "base/time/time.h" 22 #include "base/time/time.h"
21 #include "chrome/browser/password_manager/password_store_x.h"
22 #include "chrome/test/base/testing_browser_process.h" 23 #include "chrome/test/base/testing_browser_process.h"
23 #include "components/password_manager/core/browser/password_manager_test_utils.h " 24 #include "components/password_manager/core/browser/password_manager_test_utils.h "
24 #include "components/password_manager/core/browser/password_store_change.h" 25 #include "components/password_manager/core/browser/password_store_change.h"
25 #include "components/password_manager/core/browser/password_store_consumer.h" 26 #include "components/password_manager/core/browser/password_store_consumer.h"
26 #include "components/password_manager/core/common/password_manager_pref_names.h" 27 #include "components/password_manager/core/common/password_manager_pref_names.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/test/test_browser_thread_bundle.h" 29 #include "content/public/test/test_browser_thread_bundle.h"
29 #include "testing/gmock/include/gmock/gmock.h" 30 #include "testing/gmock/include/gmock/gmock.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 32
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 ScopedVector<autofill::PasswordForm> forms; 87 ScopedVector<autofill::PasswordForm> forms;
87 PasswordForm trash; 88 PasswordForm trash;
88 trash.username_element = base::ASCIIToUTF16("trash u. element"); 89 trash.username_element = base::ASCIIToUTF16("trash u. element");
89 trash.username_value = base::ASCIIToUTF16("trash u. value"); 90 trash.username_value = base::ASCIIToUTF16("trash u. value");
90 trash.password_element = base::ASCIIToUTF16("trash p. element"); 91 trash.password_element = base::ASCIIToUTF16("trash p. element");
91 trash.password_value = base::ASCIIToUTF16("trash p. value"); 92 trash.password_value = base::ASCIIToUTF16("trash p. value");
92 for (size_t i = 0; i < 3; ++i) { 93 for (size_t i = 0; i < 3; ++i) {
93 trash.origin = GURL(base::StringPrintf("http://trash%zu.com", i)); 94 trash.origin = GURL(base::StringPrintf("http://trash%zu.com", i));
94 forms.push_back(new PasswordForm(trash)); 95 forms.push_back(new PasswordForm(trash));
95 } 96 }
96 return forms.Pass(); 97 return forms;
97 } 98 }
98 99
99 bool GetLogins(const PasswordForm& form, 100 bool GetLogins(const PasswordForm& form,
100 ScopedVector<autofill::PasswordForm>* forms) override { 101 ScopedVector<autofill::PasswordForm>* forms) override {
101 *forms = CreateTrashForms(); 102 *forms = CreateTrashForms();
102 return false; 103 return false;
103 } 104 }
104 105
105 bool GetAutofillableLogins( 106 bool GetAutofillableLogins(
106 ScopedVector<autofill::PasswordForm>* forms) override { 107 ScopedVector<autofill::PasswordForm>* forms) override {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 origin.c_str(), 245 origin.c_str(),
245 action.c_str(), 246 action.c_str(),
246 L"submit_element", 247 L"submit_element",
247 L"username_element", 248 L"username_element",
248 L"password_element", 249 L"password_element",
249 autofillable ? L"username_value" : nullptr, 250 autofillable ? L"username_value" : nullptr,
250 autofillable ? L"password_value" : nullptr, 251 autofillable ? L"password_value" : nullptr,
251 autofillable, 252 autofillable,
252 false, 253 false,
253 static_cast<double>(i + 1)}; 254 static_cast<double>(i + 1)};
254 forms->push_back(CreatePasswordFormFromDataForTesting(data).Pass()); 255 forms->push_back(CreatePasswordFormFromDataForTesting(data));
255 } 256 }
256 } 257 }
257 258
258 PasswordStoreChangeList AddChangeForForm(const PasswordForm& form) { 259 PasswordStoreChangeList AddChangeForForm(const PasswordForm& form) {
259 return PasswordStoreChangeList( 260 return PasswordStoreChangeList(
260 1, PasswordStoreChange(PasswordStoreChange::ADD, form)); 261 1, PasswordStoreChange(PasswordStoreChange::ADD, form));
261 } 262 }
262 263
263 } // anonymous namespace 264 } // anonymous namespace
264 265
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 299
299 ACTION(STLDeleteElements0) { 300 ACTION(STLDeleteElements0) {
300 STLDeleteContainerPointers(arg0.begin(), arg0.end()); 301 STLDeleteContainerPointers(arg0.begin(), arg0.end());
301 } 302 }
302 303
303 TEST_P(PasswordStoreXTest, Notifications) { 304 TEST_P(PasswordStoreXTest, Notifications) {
304 scoped_ptr<password_manager::LoginDatabase> login_db( 305 scoped_ptr<password_manager::LoginDatabase> login_db(
305 new password_manager::LoginDatabase(test_login_db_file_path())); 306 new password_manager::LoginDatabase(test_login_db_file_path()));
306 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( 307 scoped_refptr<PasswordStoreX> store(new PasswordStoreX(
307 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), 308 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
308 login_db.Pass(), GetBackend())); 309 std::move(login_db), GetBackend()));
309 store->Init(syncer::SyncableService::StartSyncFlare()); 310 store->Init(syncer::SyncableService::StartSyncFlare());
310 311
311 password_manager::PasswordFormData form_data = { 312 password_manager::PasswordFormData form_data = {
312 PasswordForm::SCHEME_HTML, "http://bar.example.com", 313 PasswordForm::SCHEME_HTML, "http://bar.example.com",
313 "http://bar.example.com/origin", "http://bar.example.com/action", 314 "http://bar.example.com/origin", "http://bar.example.com/action",
314 L"submit_element", L"username_element", 315 L"submit_element", L"username_element",
315 L"password_element", L"username_value", 316 L"password_element", L"username_value",
316 L"password_value", true, 317 L"password_value", true,
317 false, 1}; 318 false, 1};
318 scoped_ptr<PasswordForm> form = 319 scoped_ptr<PasswordForm> form =
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 400
400 // Get the new size of the login DB file. We expect it to be larger. 401 // Get the new size of the login DB file. We expect it to be larger.
401 base::File::Info db_file_full_info; 402 base::File::Info db_file_full_info;
402 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); 403 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info));
403 EXPECT_GT(db_file_full_info.size, db_file_start_info.size); 404 EXPECT_GT(db_file_full_info.size, db_file_start_info.size);
404 405
405 // Initializing the PasswordStore shouldn't trigger a native migration (yet). 406 // Initializing the PasswordStore shouldn't trigger a native migration (yet).
406 login_db.reset(new password_manager::LoginDatabase(login_db_file)); 407 login_db.reset(new password_manager::LoginDatabase(login_db_file));
407 scoped_refptr<PasswordStoreX> store(new PasswordStoreX( 408 scoped_refptr<PasswordStoreX> store(new PasswordStoreX(
408 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(), 409 base::ThreadTaskRunnerHandle::Get(), base::ThreadTaskRunnerHandle::Get(),
409 login_db.Pass(), GetBackend())); 410 std::move(login_db), GetBackend()));
410 store->Init(syncer::SyncableService::StartSyncFlare()); 411 store->Init(syncer::SyncableService::StartSyncFlare());
411 412
412 MockPasswordStoreConsumer consumer; 413 MockPasswordStoreConsumer consumer;
413 414
414 // The autofillable forms should have been migrated to the native backend. 415 // The autofillable forms should have been migrated to the native backend.
415 EXPECT_CALL( 416 EXPECT_CALL(
416 consumer, 417 consumer,
417 OnGetPasswordStoreResultsConstRef( 418 OnGetPasswordStoreResultsConstRef(
418 UnorderedPasswordFormElementsAre(expected_autofillable.get()))); 419 UnorderedPasswordFormElementsAre(expected_autofillable.get())));
419 420
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 478
478 INSTANTIATE_TEST_CASE_P(NoBackend, 479 INSTANTIATE_TEST_CASE_P(NoBackend,
479 PasswordStoreXTest, 480 PasswordStoreXTest,
480 testing::Values(NO_BACKEND)); 481 testing::Values(NO_BACKEND));
481 INSTANTIATE_TEST_CASE_P(FailingBackend, 482 INSTANTIATE_TEST_CASE_P(FailingBackend,
482 PasswordStoreXTest, 483 PasswordStoreXTest,
483 testing::Values(FAILING_BACKEND)); 484 testing::Values(FAILING_BACKEND));
484 INSTANTIATE_TEST_CASE_P(WorkingBackend, 485 INSTANTIATE_TEST_CASE_P(WorkingBackend,
485 PasswordStoreXTest, 486 PasswordStoreXTest,
486 testing::Values(WORKING_BACKEND)); 487 testing::Values(WORKING_BACKEND));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698