| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
| 9 #include "chrome/browser/keychain_mock_mac.h" | 9 #include "chrome/browser/keychain_mock_mac.h" |
| 10 #include "chrome/browser/password_manager/password_store_mac.h" | 10 #include "chrome/browser/password_manager/password_store_mac.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 unsigned int capacity = arraysize(test_data) + 1; | 59 unsigned int capacity = arraysize(test_data) + 1; |
| 60 keychain_ = new MockKeychain(capacity); | 60 keychain_ = new MockKeychain(capacity); |
| 61 | 61 |
| 62 for (unsigned int i = 0; i < arraysize(test_data); ++i) { | 62 for (unsigned int i = 0; i < arraysize(test_data); ++i) { |
| 63 keychain_->AddTestItem(test_data[i]); | 63 keychain_->AddTestItem(test_data[i]); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 virtual void TearDown() { | 67 virtual void TearDown() { |
| 68 ExpectCreatesAndFreesBalanced(); | 68 ExpectCreatesAndFreesBalanced(); |
| 69 ExpectCreatorCodesSet(); |
| 69 delete keychain_; | 70 delete keychain_; |
| 70 } | 71 } |
| 71 | 72 |
| 72 protected: | 73 protected: |
| 73 // Causes a test failure unless everything returned from keychain_'s | 74 // Causes a test failure unless everything returned from keychain_'s |
| 74 // ItemCopyAttributesAndData, SearchCreateFromAttributes, and SearchCopyNext | 75 // ItemCopyAttributesAndData, SearchCreateFromAttributes, and SearchCopyNext |
| 75 // was correctly freed. | 76 // was correctly freed. |
| 76 void ExpectCreatesAndFreesBalanced() { | 77 void ExpectCreatesAndFreesBalanced() { |
| 77 EXPECT_EQ(0, keychain_->UnfreedSearchCount()); | 78 EXPECT_EQ(0, keychain_->UnfreedSearchCount()); |
| 78 EXPECT_EQ(0, keychain_->UnfreedKeychainItemCount()); | 79 EXPECT_EQ(0, keychain_->UnfreedKeychainItemCount()); |
| 79 EXPECT_EQ(0, keychain_->UnfreedAttributeDataCount()); | 80 EXPECT_EQ(0, keychain_->UnfreedAttributeDataCount()); |
| 80 } | 81 } |
| 81 | 82 |
| 83 // Causes a test failure unless any Keychain items added during the test have |
| 84 // their creator code set. |
| 85 void ExpectCreatorCodesSet() { |
| 86 EXPECT_TRUE(keychain_->CreatorCodesSetForAddedItems()); |
| 87 } |
| 88 |
| 82 MockKeychain* keychain_; | 89 MockKeychain* keychain_; |
| 83 }; | 90 }; |
| 84 | 91 |
| 85 #pragma mark - | 92 #pragma mark - |
| 86 | 93 |
| 87 // Struct used for creation of PasswordForms from static arrays of data. | 94 // Struct used for creation of PasswordForms from static arrays of data. |
| 88 struct PasswordFormData { | 95 struct PasswordFormData { |
| 89 const PasswordForm::Scheme scheme; | 96 const PasswordForm::Scheme scheme; |
| 90 const char* signon_realm; | 97 const char* signon_realm; |
| 91 const char* origin; | 98 const char* origin; |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 test_case); | 734 test_case); |
| 728 CHECK_FORMS(database_forms, test_data[DATABASE_OUTPUT][test_case], | 735 CHECK_FORMS(database_forms, test_data[DATABASE_OUTPUT][test_case], |
| 729 test_case); | 736 test_case); |
| 730 CHECK_FORMS(merged_forms, test_data[MERGE_OUTPUT][test_case], test_case); | 737 CHECK_FORMS(merged_forms, test_data[MERGE_OUTPUT][test_case], test_case); |
| 731 | 738 |
| 732 STLDeleteElements(&keychain_forms); | 739 STLDeleteElements(&keychain_forms); |
| 733 STLDeleteElements(&database_forms); | 740 STLDeleteElements(&database_forms); |
| 734 STLDeleteElements(&merged_forms); | 741 STLDeleteElements(&merged_forms); |
| 735 } | 742 } |
| 736 } | 743 } |
| OLD | NEW |