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

Side by Side Diff: components/autofill/core/browser/webdata/autofill_table_unittest.cc

Issue 2010463002: Mocker for OSCrypt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated doc Created 4 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 6
7 #include <map>
8 #include <set>
9 #include <string>
7 #include <tuple> 10 #include <tuple>
8 #include <utility> 11 #include <utility>
9 #include <vector> 12 #include <vector>
10 13
11 #include "base/command_line.h" 14 #include "base/command_line.h"
12 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
14 #include "base/guid.h" 17 #include "base/guid.h"
15 #include "base/macros.h" 18 #include "base/macros.h"
16 #include "base/memory/scoped_vector.h" 19 #include "base/memory/scoped_vector.h"
17 #include "base/stl_util.h" 20 #include "base/stl_util.h"
18 #include "base/strings/string_number_conversions.h" 21 #include "base/strings/string_number_conversions.h"
19 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
21 #include "base/time/time.h" 24 #include "base/time/time.h"
22 #include "build/build_config.h" 25 #include "build/build_config.h"
23 #include "components/autofill/core/browser/autofill_profile.h" 26 #include "components/autofill/core/browser/autofill_profile.h"
24 #include "components/autofill/core/browser/autofill_test_utils.h" 27 #include "components/autofill/core/browser/autofill_test_utils.h"
25 #include "components/autofill/core/browser/autofill_type.h" 28 #include "components/autofill/core/browser/autofill_type.h"
26 #include "components/autofill/core/browser/credit_card.h" 29 #include "components/autofill/core/browser/credit_card.h"
27 #include "components/autofill/core/browser/webdata/autofill_change.h" 30 #include "components/autofill/core/browser/webdata/autofill_change.h"
28 #include "components/autofill/core/browser/webdata/autofill_entry.h" 31 #include "components/autofill/core/browser/webdata/autofill_entry.h"
29 #include "components/autofill/core/browser/webdata/autofill_table.h" 32 #include "components/autofill/core/browser/webdata/autofill_table.h"
30 #include "components/autofill/core/common/autofill_constants.h" 33 #include "components/autofill/core/common/autofill_constants.h"
31 #include "components/autofill/core/common/autofill_switches.h" 34 #include "components/autofill/core/common/autofill_switches.h"
32 #include "components/autofill/core/common/autofill_util.h" 35 #include "components/autofill/core/common/autofill_util.h"
33 #include "components/autofill/core/common/form_field_data.h" 36 #include "components/autofill/core/common/form_field_data.h"
34 #include "components/os_crypt/os_crypt.h" 37 #include "components/os_crypt/os_crypt_mocker.h"
35 #include "components/webdata/common/web_database.h" 38 #include "components/webdata/common/web_database.h"
36 #include "sql/statement.h" 39 #include "sql/statement.h"
37 #include "testing/gtest/include/gtest/gtest.h" 40 #include "testing/gtest/include/gtest/gtest.h"
38 41
39 using base::ASCIIToUTF16; 42 using base::ASCIIToUTF16;
40 using base::Time; 43 using base::Time;
41 using base::TimeDelta; 44 using base::TimeDelta;
42 45
43 namespace autofill { 46 namespace autofill {
44 47
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 119
117 } // namespace 120 } // namespace
118 121
119 class AutofillTableTest : public testing::Test { 122 class AutofillTableTest : public testing::Test {
120 public: 123 public:
121 AutofillTableTest() {} 124 AutofillTableTest() {}
122 ~AutofillTableTest() override {} 125 ~AutofillTableTest() override {}
123 126
124 protected: 127 protected:
125 void SetUp() override { 128 void SetUp() override {
126 #if defined(OS_MACOSX) 129 OSCryptMocker::SetUpWithSingleton();
127 OSCrypt::UseMockKeychain(true);
128 #endif
129 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 130 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
130 file_ = temp_dir_.path().AppendASCII("TestWebDatabase"); 131 file_ = temp_dir_.path().AppendASCII("TestWebDatabase");
131 132
132 table_.reset(new AutofillTable); 133 table_.reset(new AutofillTable);
133 db_.reset(new WebDatabase); 134 db_.reset(new WebDatabase);
134 db_->AddTable(table_.get()); 135 db_->AddTable(table_.get());
135 ASSERT_EQ(sql::INIT_OK, db_->Init(file_)); 136 ASSERT_EQ(sql::INIT_OK, db_->Init(file_));
136 } 137 }
137 138
139 void TearDown() override { OSCryptMocker::TearDown(); }
140
138 base::FilePath file_; 141 base::FilePath file_;
139 base::ScopedTempDir temp_dir_; 142 base::ScopedTempDir temp_dir_;
140 std::unique_ptr<AutofillTable> table_; 143 std::unique_ptr<AutofillTable> table_;
141 std::unique_ptr<WebDatabase> db_; 144 std::unique_ptr<WebDatabase> db_;
142 145
143 private: 146 private:
144 DISALLOW_COPY_AND_ASSIGN(AutofillTableTest); 147 DISALLOW_COPY_AND_ASSIGN(AutofillTableTest);
145 }; 148 };
146 149
147 TEST_F(AutofillTableTest, Autofill) { 150 TEST_F(AutofillTableTest, Autofill) {
(...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after
1991 for (size_t j = 0; j < kTestCases[i].expected_suggestion_count; ++j) { 1994 for (size_t j = 0; j < kTestCases[i].expected_suggestion_count; ++j) {
1992 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_suggestion[j]), v[j]); 1995 EXPECT_EQ(ASCIIToUTF16(kTestCases[i].expected_suggestion[j]), v[j]);
1993 } 1996 }
1994 1997
1995 changes.clear(); 1998 changes.clear();
1996 table_->RemoveFormElementsAddedBetween(t1, Time(), &changes); 1999 table_->RemoveFormElementsAddedBetween(t1, Time(), &changes);
1997 } 2000 }
1998 } 2001 }
1999 2002
2000 } // namespace autofill 2003 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/personal_data_manager_unittest.cc ('k') | components/components_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698