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

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

Issue 23477015: [sync] Significantly speed up password model association on mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Further reduce keychain reads Created 7 years, 3 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 "testing/gmock/include/gmock/gmock.h" 5 #include "testing/gmock/include/gmock/gmock.h"
6 #include "testing/gtest/include/gtest/gtest.h" 6 #include "testing/gtest/include/gtest/gtest.h"
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 "http://a.server.com/", L"abc", L"123", false, 273 "http://a.server.com/", L"abc", L"123", false,
274 1601, 1, 1, 0, 0, 0 }, 274 1601, 1, 1, 0, 0, 0 },
275 }; 275 };
276 276
277 for (unsigned int i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) { 277 for (unsigned int i = 0; i < ARRAYSIZE_UNSAFE(expected); ++i) {
278 // Create our fake KeychainItemRef; see MockAppleKeychain docs. 278 // Create our fake KeychainItemRef; see MockAppleKeychain docs.
279 SecKeychainItemRef keychain_item = 279 SecKeychainItemRef keychain_item =
280 reinterpret_cast<SecKeychainItemRef>(i + 1); 280 reinterpret_cast<SecKeychainItemRef>(i + 1);
281 PasswordForm form; 281 PasswordForm form;
282 bool parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem( 282 bool parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem(
283 *keychain_, keychain_item, &form); 283 *keychain_, keychain_item, &form, true);
284 284
285 EXPECT_TRUE(parsed) << "In iteration " << i; 285 EXPECT_TRUE(parsed) << "In iteration " << i;
286 286
287 EXPECT_EQ(expected[i].scheme, form.scheme) << "In iteration " << i; 287 EXPECT_EQ(expected[i].scheme, form.scheme) << "In iteration " << i;
288 EXPECT_EQ(GURL(expected[i].origin), form.origin) << "In iteration " << i; 288 EXPECT_EQ(GURL(expected[i].origin), form.origin) << "In iteration " << i;
289 EXPECT_EQ(expected[i].ssl_valid, form.ssl_valid) << "In iteration " << i; 289 EXPECT_EQ(expected[i].ssl_valid, form.ssl_valid) << "In iteration " << i;
290 EXPECT_EQ(std::string(expected[i].signon_realm), form.signon_realm) 290 EXPECT_EQ(std::string(expected[i].signon_realm), form.signon_realm)
291 << "In iteration " << i; 291 << "In iteration " << i;
292 if (expected[i].username) { 292 if (expected[i].username) {
293 EXPECT_EQ(WideToUTF16(expected[i].username), form.username_value) 293 EXPECT_EQ(WideToUTF16(expected[i].username), form.username_value)
(...skipping 18 matching lines...) Expand all
312 << "In iteration " << i; 312 << "In iteration " << i;
313 EXPECT_EQ(expected[i].creation_second, exploded_time.second) 313 EXPECT_EQ(expected[i].creation_second, exploded_time.second)
314 << "In iteration " << i; 314 << "In iteration " << i;
315 } 315 }
316 316
317 { 317 {
318 // Use an invalid ref, to make sure errors are reported. 318 // Use an invalid ref, to make sure errors are reported.
319 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(99); 319 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(99);
320 PasswordForm form; 320 PasswordForm form;
321 bool parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem( 321 bool parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem(
322 *keychain_, keychain_item, &form); 322 *keychain_, keychain_item, &form, true);
323 EXPECT_FALSE(parsed); 323 EXPECT_FALSE(parsed);
324 } 324 }
325 } 325 }
326 326
327 TEST_F(PasswordStoreMacInternalsTest, TestKeychainSearch) { 327 TEST_F(PasswordStoreMacInternalsTest, TestKeychainSearch) {
328 struct TestDataAndExpectation { 328 struct TestDataAndExpectation {
329 const PasswordFormData data; 329 const PasswordFormData data;
330 const size_t expected_fill_matches; 330 const size_t expected_fill_matches;
331 const size_t expected_merge_matches; 331 const size_t expected_merge_matches;
332 }; 332 };
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 "http://some.domain.com/insecure.html", NULL, 551 "http://some.domain.com/insecure.html", NULL,
552 NULL, NULL, NULL, L"joe_user", L"updated_password", false, false, 0 552 NULL, NULL, NULL, L"joe_user", L"updated_password", false, false, 0
553 }; 553 };
554 scoped_ptr<PasswordForm> update_form(CreatePasswordFormFromData(data)); 554 scoped_ptr<PasswordForm> update_form(CreatePasswordFormFromData(data));
555 MacKeychainPasswordFormAdapter keychain_adapter(keychain_); 555 MacKeychainPasswordFormAdapter keychain_adapter(keychain_);
556 EXPECT_TRUE(keychain_adapter.AddPassword(*update_form)); 556 EXPECT_TRUE(keychain_adapter.AddPassword(*update_form));
557 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(2); 557 SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(2);
558 PasswordForm stored_form; 558 PasswordForm stored_form;
559 internal_keychain_helpers::FillPasswordFormFromKeychainItem(*keychain_, 559 internal_keychain_helpers::FillPasswordFormFromKeychainItem(*keychain_,
560 keychain_item, 560 keychain_item,
561 &stored_form); 561 &stored_form,
562 true);
562 EXPECT_EQ(update_form->password_value, stored_form.password_value); 563 EXPECT_EQ(update_form->password_value, stored_form.password_value);
563 } 564 }
564 } 565 }
565 566
566 TEST_F(PasswordStoreMacInternalsTest, TestKeychainRemove) { 567 TEST_F(PasswordStoreMacInternalsTest, TestKeychainRemove) {
567 struct TestDataAndExpectation { 568 struct TestDataAndExpectation {
568 PasswordFormData data; 569 PasswordFormData data;
569 bool should_succeed; 570 bool should_succeed;
570 }; 571 };
571 TestDataAndExpectation test_data[] = { 572 TestDataAndExpectation test_data[] = {
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 EXPECT_EQ(0U, matching_items.size()) << "iteration " << i; 1022 EXPECT_EQ(0U, matching_items.size()) << "iteration " << i;
1022 } 1023 }
1023 STLDeleteElements(&matching_items); 1024 STLDeleteElements(&matching_items);
1024 1025
1025 login_db_->GetLogins(*query_form, &matching_items); 1026 login_db_->GetLogins(*query_form, &matching_items);
1026 EXPECT_EQ(updates[i].password ? 1U : 0U, matching_items.size()) 1027 EXPECT_EQ(updates[i].password ? 1U : 0U, matching_items.size())
1027 << "iteration " << i; 1028 << "iteration " << i;
1028 STLDeleteElements(&matching_items); 1029 STLDeleteElements(&matching_items);
1029 } 1030 }
1030 } 1031 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698