OLD | NEW |
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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/message_loop/message_loop.h" | |
13 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
14 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/test/scoped_task_environment.h" |
15 #include "base/test/sequenced_worker_pool_owner.h" | 15 #include "base/test/sequenced_worker_pool_owner.h" |
16 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" |
17 #include "chrome/browser/ui/app_list/search/history_factory.h" | 17 #include "chrome/browser/ui/app_list/search/history_factory.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/app_list/search/dictionary_data_store.h" | 19 #include "ui/app_list/search/dictionary_data_store.h" |
20 #include "ui/app_list/search/history.h" | 20 #include "ui/app_list/search/history.h" |
21 #include "ui/app_list/search/history_data.h" | 21 #include "ui/app_list/search/history_data.h" |
22 #include "ui/app_list/search/history_data_observer.h" | 22 #include "ui/app_list/search/history_data_observer.h" |
23 #include "ui/app_list/search/history_data_store.h" | 23 #include "ui/app_list/search/history_data_store.h" |
24 | 24 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 HistoryDataStore* store_; // Not owned. | 83 HistoryDataStore* store_; // Not owned. |
84 std::unique_ptr<base::RunLoop> run_loop_; | 84 std::unique_ptr<base::RunLoop> run_loop_; |
85 | 85 |
86 DISALLOW_COPY_AND_ASSIGN(StoreFlushWaiter); | 86 DISALLOW_COPY_AND_ASSIGN(StoreFlushWaiter); |
87 }; | 87 }; |
88 | 88 |
89 } // namespace | 89 } // namespace |
90 | 90 |
91 class SearchHistoryTest : public testing::Test { | 91 class SearchHistoryTest : public testing::Test { |
92 public: | 92 public: |
93 SearchHistoryTest() {} | 93 SearchHistoryTest() |
| 94 : scoped_task_environment_( |
| 95 base::test::ScopedTaskEnvironment::MainThreadType::UI) {} |
94 ~SearchHistoryTest() override {} | 96 ~SearchHistoryTest() override {} |
95 | 97 |
96 // testing::Test overrides: | 98 // testing::Test overrides: |
97 void SetUp() override { | 99 void SetUp() override { |
98 worker_pool_owner_.reset( | 100 worker_pool_owner_.reset( |
99 new base::SequencedWorkerPoolOwner(2, "AppLauncherTest")); | 101 new base::SequencedWorkerPoolOwner(2, "AppLauncherTest")); |
100 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 102 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
101 CreateHistory(); | 103 CreateHistory(); |
102 } | 104 } |
103 void TearDown() override { | 105 void TearDown() override { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ? (*known_results_.get())[result_id] | 139 ? (*known_results_.get())[result_id] |
138 : UNKNOWN_RESULT; | 140 : UNKNOWN_RESULT; |
139 } | 141 } |
140 | 142 |
141 History* history() { return history_.get(); } | 143 History* history() { return history_.get(); } |
142 const HistoryData::Associations& associations() const { | 144 const HistoryData::Associations& associations() const { |
143 return history_->data_->associations(); | 145 return history_->data_->associations(); |
144 } | 146 } |
145 | 147 |
146 private: | 148 private: |
147 base::MessageLoopForUI message_loop_; | 149 base::test::ScopedTaskEnvironment scoped_task_environment_; |
148 base::ScopedTempDir temp_dir_; | 150 base::ScopedTempDir temp_dir_; |
149 std::unique_ptr<base::SequencedWorkerPoolOwner> worker_pool_owner_; | 151 std::unique_ptr<base::SequencedWorkerPoolOwner> worker_pool_owner_; |
150 | 152 |
151 std::unique_ptr<History> history_; | 153 std::unique_ptr<History> history_; |
152 std::unique_ptr<KnownResults> known_results_; | 154 std::unique_ptr<KnownResults> known_results_; |
153 | 155 |
154 DISALLOW_COPY_AND_ASSIGN(SearchHistoryTest); | 156 DISALLOW_COPY_AND_ASSIGN(SearchHistoryTest); |
155 }; | 157 }; |
156 | 158 |
157 TEST_F(SearchHistoryTest, Persistence) { | 159 TEST_F(SearchHistoryTest, Persistence) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 298 |
297 // The oldest secondary is gone. | 299 // The oldest secondary is gone. |
298 EXPECT_EQ(UNKNOWN_RESULT, GetResultType("1")); | 300 EXPECT_EQ(UNKNOWN_RESULT, GetResultType("1")); |
299 | 301 |
300 // Touched oldest survived. | 302 // Touched oldest survived. |
301 EXPECT_EQ(PERFECT_SECONDARY, GetResultType("0")); | 303 EXPECT_EQ(PERFECT_SECONDARY, GetResultType("0")); |
302 } | 304 } |
303 | 305 |
304 } // namespace test | 306 } // namespace test |
305 } // namespace app_list | 307 } // namespace app_list |
OLD | NEW |