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 "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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" |
10 #include "base/path_service.h" | 11 #include "base/path_service.h" |
11 #include "base/scoped_temp_dir.h" | |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/password_manager/password_store_consumer.h" | 15 #include "chrome/browser/password_manager/password_store_consumer.h" |
16 #include "chrome/browser/password_manager/password_store_mac.h" | 16 #include "chrome/browser/password_manager/password_store_mac.h" |
17 #include "chrome/browser/password_manager/password_store_mac_internal.h" | 17 #include "chrome/browser/password_manager/password_store_mac_internal.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
20 #include "crypto/mock_apple_keychain.h" | 20 #include "crypto/mock_apple_keychain.h" |
21 | 21 |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 MessageLoop::current()->Run(); | 919 MessageLoop::current()->Run(); |
920 } | 920 } |
921 | 921 |
922 protected: | 922 protected: |
923 MessageLoopForUI message_loop_; | 923 MessageLoopForUI message_loop_; |
924 content::TestBrowserThread ui_thread_; | 924 content::TestBrowserThread ui_thread_; |
925 | 925 |
926 MockAppleKeychain* keychain_; // Owned by store_. | 926 MockAppleKeychain* keychain_; // Owned by store_. |
927 LoginDatabase* login_db_; // Owned by store_. | 927 LoginDatabase* login_db_; // Owned by store_. |
928 scoped_refptr<PasswordStoreMac> store_; | 928 scoped_refptr<PasswordStoreMac> store_; |
929 ScopedTempDir db_dir_; | 929 base::ScopedTempDir db_dir_; |
930 }; | 930 }; |
931 | 931 |
932 TEST_F(PasswordStoreMacTest, TestStoreUpdate) { | 932 TEST_F(PasswordStoreMacTest, TestStoreUpdate) { |
933 // Insert a password into both the database and the keychain. | 933 // Insert a password into both the database and the keychain. |
934 // This is done manually, rather than through store_->AddLogin, because the | 934 // This is done manually, rather than through store_->AddLogin, because the |
935 // Mock Keychain isn't smart enough to be able to support update generically, | 935 // Mock Keychain isn't smart enough to be able to support update generically, |
936 // so some.domain.com triggers special handling to test it that make inserting | 936 // so some.domain.com triggers special handling to test it that make inserting |
937 // fail. | 937 // fail. |
938 PasswordFormData joint_data = { | 938 PasswordFormData joint_data = { |
939 PasswordForm::SCHEME_HTML, "http://some.domain.com/", | 939 PasswordForm::SCHEME_HTML, "http://some.domain.com/", |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 EXPECT_EQ(0U, matching_items.size()) << "iteration " << i; | 1019 EXPECT_EQ(0U, matching_items.size()) << "iteration " << i; |
1020 } | 1020 } |
1021 STLDeleteElements(&matching_items); | 1021 STLDeleteElements(&matching_items); |
1022 | 1022 |
1023 login_db_->GetLogins(*query_form, &matching_items); | 1023 login_db_->GetLogins(*query_form, &matching_items); |
1024 EXPECT_EQ(updates[i].password ? 1U : 0U, matching_items.size()) | 1024 EXPECT_EQ(updates[i].password ? 1U : 0U, matching_items.size()) |
1025 << "iteration " << i; | 1025 << "iteration " << i; |
1026 STLDeleteElements(&matching_items); | 1026 STLDeleteElements(&matching_items); |
1027 } | 1027 } |
1028 } | 1028 } |
OLD | NEW |