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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" | 13 #include "chrome/browser/predictors/autocomplete_action_predictor_table.h" |
14 #include "chrome/browser/predictors/predictor_database.h" | 14 #include "chrome/browser/predictors/predictor_database.h" |
15 #include "chrome/browser/predictors/predictor_database_factory.h" | 15 #include "chrome/browser/predictors/predictor_database_factory.h" |
16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
17 #include "content/public/test/test_browser_thread.h" | 17 #include "content/public/test/test_browser_thread.h" |
| 18 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "sql/statement.h" | 19 #include "sql/statement.h" |
19 | 20 |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 | 22 |
22 using base::Time; | 23 using base::Time; |
23 using base::TimeDelta; | 24 using base::TimeDelta; |
24 using content::BrowserThread; | 25 using content::BrowserThread; |
25 using predictors::AutocompleteActionPredictorTable; | 26 using predictors::AutocompleteActionPredictorTable; |
26 | 27 |
27 namespace predictors { | 28 namespace predictors { |
(...skipping 20 matching lines...) Expand all Loading... |
48 // Test functions that can be run against this text fixture or | 49 // Test functions that can be run against this text fixture or |
49 // AutocompleteActionPredictorTableReopenTest that inherits from this. | 50 // AutocompleteActionPredictorTableReopenTest that inherits from this. |
50 void TestGetRow(); | 51 void TestGetRow(); |
51 void TestAddAndUpdateRows(); | 52 void TestAddAndUpdateRows(); |
52 void TestDeleteRows(); | 53 void TestDeleteRows(); |
53 void TestDeleteAllRows(); | 54 void TestDeleteAllRows(); |
54 | 55 |
55 AutocompleteActionPredictorTable::Rows test_db_; | 56 AutocompleteActionPredictorTable::Rows test_db_; |
56 | 57 |
57 private: | 58 private: |
58 base::MessageLoop loop_; | 59 content::TestBrowserThreadBundle thread_bundle_; |
59 TestingProfile profile_; | 60 TestingProfile profile_; |
60 std::unique_ptr<PredictorDatabase> db_; | 61 std::unique_ptr<PredictorDatabase> db_; |
61 content::TestBrowserThread db_thread_; | |
62 }; | 62 }; |
63 | 63 |
64 class AutocompleteActionPredictorTableReopenTest | 64 class AutocompleteActionPredictorTableReopenTest |
65 : public AutocompleteActionPredictorTableTest { | 65 : public AutocompleteActionPredictorTableTest { |
66 public: | 66 public: |
67 void SetUp() override { | 67 void SetUp() override { |
68 // By calling SetUp twice, we make sure that the table already exists for | 68 // By calling SetUp twice, we make sure that the table already exists for |
69 // this fixture. | 69 // this fixture. |
70 AutocompleteActionPredictorTableTest::SetUp(); | 70 AutocompleteActionPredictorTableTest::SetUp(); |
71 AutocompleteActionPredictorTableTest::TearDown(); | 71 AutocompleteActionPredictorTableTest::TearDown(); |
72 AutocompleteActionPredictorTableTest::SetUp(); | 72 AutocompleteActionPredictorTableTest::SetUp(); |
73 } | 73 } |
74 }; | 74 }; |
75 | 75 |
76 AutocompleteActionPredictorTableTest::AutocompleteActionPredictorTableTest() | 76 AutocompleteActionPredictorTableTest::AutocompleteActionPredictorTableTest() {} |
77 : db_thread_(BrowserThread::DB, &loop_) { | |
78 } | |
79 | 77 |
80 AutocompleteActionPredictorTableTest::~AutocompleteActionPredictorTableTest() { | 78 AutocompleteActionPredictorTableTest::~AutocompleteActionPredictorTableTest() { |
81 } | 79 } |
82 | 80 |
83 void AutocompleteActionPredictorTableTest::SetUp() { | 81 void AutocompleteActionPredictorTableTest::SetUp() { |
84 db_.reset(new PredictorDatabase(&profile_)); | 82 db_.reset(new PredictorDatabase(&profile_)); |
85 base::RunLoop().RunUntilIdle(); | 83 base::RunLoop().RunUntilIdle(); |
86 | 84 |
87 test_db_.push_back(AutocompleteActionPredictorTable::Row( | 85 test_db_.push_back(AutocompleteActionPredictorTable::Row( |
88 "BD85DBA2-8C29-49F9-84AE-48E1E90880DF", | 86 "BD85DBA2-8C29-49F9-84AE-48E1E90880DF", |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 231 |
234 TEST_F(AutocompleteActionPredictorTableReopenTest, DeleteRows) { | 232 TEST_F(AutocompleteActionPredictorTableReopenTest, DeleteRows) { |
235 TestDeleteRows(); | 233 TestDeleteRows(); |
236 } | 234 } |
237 | 235 |
238 TEST_F(AutocompleteActionPredictorTableReopenTest, DeleteAllRows) { | 236 TEST_F(AutocompleteActionPredictorTableReopenTest, DeleteAllRows) { |
239 TestDeleteAllRows(); | 237 TestDeleteAllRows(); |
240 } | 238 } |
241 | 239 |
242 } // namespace predictors | 240 } // namespace predictors |
OLD | NEW |