OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // This provides a simple implementation of a URL+VisitDatabase using an | 44 // This provides a simple implementation of a URL+VisitDatabase using an |
45 // in-memory sqlite connection. The text database manager expects to be able to | 45 // in-memory sqlite connection. The text database manager expects to be able to |
46 // update the visit database to keep in sync. | 46 // update the visit database to keep in sync. |
47 class InMemDB : public URLDatabase, public VisitDatabase { | 47 class InMemDB : public URLDatabase, public VisitDatabase { |
48 public: | 48 public: |
49 InMemDB() { | 49 InMemDB() { |
50 EXPECT_TRUE(db_.OpenInMemory()); | 50 EXPECT_TRUE(db_.OpenInMemory()); |
51 CreateURLTable(false); | 51 CreateURLTable(false); |
52 InitVisitTable(); | 52 InitVisitTable(); |
53 } | 53 } |
54 ~InMemDB() { | 54 virtual ~InMemDB() { |
55 } | 55 } |
56 | 56 |
57 private: | 57 private: |
58 virtual sql::Connection& GetDB() { return db_; } | 58 virtual sql::Connection& GetDB() OVERRIDE { return db_; } |
59 | 59 |
60 sql::Connection db_; | 60 sql::Connection db_; |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(InMemDB); | 62 DISALLOW_COPY_AND_ASSIGN(InMemDB); |
63 }; | 63 }; |
64 | 64 |
65 // Adds all the pages once, and the first page once more in the next month. | 65 // Adds all the pages once, and the first page once more in the next month. |
66 // The times of all the pages will be filled into |*times|. | 66 // The times of all the pages will be filled into |*times|. |
67 void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db, | 67 void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db, |
68 std::vector<Time>* times) { | 68 std::vector<Time>* times) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 class TextDatabaseManagerTest : public testing::Test { | 151 class TextDatabaseManagerTest : public testing::Test { |
152 public: | 152 public: |
153 // Called manually by the test so it can report failure to initialize. | 153 // Called manually by the test so it can report failure to initialize. |
154 bool Init() { | 154 bool Init() { |
155 return file_util::CreateNewTempDirectory( | 155 return file_util::CreateNewTempDirectory( |
156 FILE_PATH_LITERAL("TestSearchTest"), &dir_); | 156 FILE_PATH_LITERAL("TestSearchTest"), &dir_); |
157 } | 157 } |
158 | 158 |
159 protected: | 159 protected: |
160 void SetUp() { | 160 virtual void SetUp() { |
161 } | 161 } |
162 | 162 |
163 void TearDown() { | 163 virtual void TearDown() { |
164 file_util::Delete(dir_, true); | 164 file_util::Delete(dir_, true); |
165 } | 165 } |
166 | 166 |
167 MessageLoop message_loop_; | 167 MessageLoop message_loop_; |
168 | 168 |
169 // Directory containing the databases. | 169 // Directory containing the databases. |
170 FilePath dir_; | 170 FilePath dir_; |
171 }; | 171 }; |
172 | 172 |
173 // Tests basic querying. | 173 // Tests basic querying. |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 times.push_back(Time::FromInternalValue(5)); | 589 times.push_back(Time::FromInternalValue(5)); |
590 times.push_back(Time::FromInternalValue(5)); | 590 times.push_back(Time::FromInternalValue(5)); |
591 times.push_back(Time::FromInternalValue(3)); | 591 times.push_back(Time::FromInternalValue(3)); |
592 times.push_back(Time::FromInternalValue(1)); | 592 times.push_back(Time::FromInternalValue(1)); |
593 manager.DeleteFromUncommittedForTimes(times); | 593 manager.DeleteFromUncommittedForTimes(times); |
594 | 594 |
595 EXPECT_EQ(3u, manager.GetUncommittedEntryCountForTest()); | 595 EXPECT_EQ(3u, manager.GetUncommittedEntryCountForTest()); |
596 } | 596 } |
597 | 597 |
598 } // namespace history | 598 } // namespace history |
OLD | NEW |