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

Side by Side Diff: chrome/browser/ui/app_list/search/history_unittest.cc

Issue 681823004: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
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"
(...skipping 15 matching lines...) Expand all
26 const size_t kMaxPrimary = 3; 26 const size_t kMaxPrimary = 3;
27 const size_t kMaxSecondary = 2; 27 const size_t kMaxSecondary = 2;
28 28
29 // HistoryDataLoadWaiter waits for give |data| to be loaded from underlying 29 // HistoryDataLoadWaiter waits for give |data| to be loaded from underlying
30 // store on the blocking pool. The waiter waits on the main message loop until 30 // store on the blocking pool. The waiter waits on the main message loop until
31 // OnHistoryDataLoadedFromStore() is invoked or the maximum allowed wait time 31 // OnHistoryDataLoadedFromStore() is invoked or the maximum allowed wait time
32 // has passed. 32 // has passed.
33 class HistoryDataLoadWaiter : public HistoryDataObserver { 33 class HistoryDataLoadWaiter : public HistoryDataObserver {
34 public: 34 public:
35 explicit HistoryDataLoadWaiter(HistoryData* data) : data_(data) {} 35 explicit HistoryDataLoadWaiter(HistoryData* data) : data_(data) {}
36 virtual ~HistoryDataLoadWaiter() {} 36 ~HistoryDataLoadWaiter() override {}
37 37
38 void Wait() { 38 void Wait() {
39 data_->AddObserver(this); 39 data_->AddObserver(this);
40 40
41 run_loop_.reset(new base::RunLoop); 41 run_loop_.reset(new base::RunLoop);
42 run_loop_->Run(); 42 run_loop_->Run();
43 43
44 data_->RemoveObserver(this); 44 data_->RemoveObserver(this);
45 } 45 }
46 46
47 private: 47 private:
48 // HistoryDataObserver overrides: 48 // HistoryDataObserver overrides:
49 virtual void OnHistoryDataLoadedFromStore() override { 49 void OnHistoryDataLoadedFromStore() override { run_loop_->Quit(); }
50 run_loop_->Quit();
51 }
52 50
53 HistoryData* data_; // Not owned. 51 HistoryData* data_; // Not owned.
54 scoped_ptr<base::RunLoop> run_loop_; 52 scoped_ptr<base::RunLoop> run_loop_;
55 53
56 DISALLOW_COPY_AND_ASSIGN(HistoryDataLoadWaiter); 54 DISALLOW_COPY_AND_ASSIGN(HistoryDataLoadWaiter);
57 }; 55 };
58 56
59 // StoreFlushWaiter waits for the given |store| to flush its data to disk. 57 // StoreFlushWaiter waits for the given |store| to flush its data to disk.
60 // The flush and disk write happens on the blocking pool. The waiter waits 58 // The flush and disk write happens on the blocking pool. The waiter waits
61 // on the main message loop until the OnFlushed() is invoked or the maximum 59 // on the main message loop until the OnFlushed() is invoked or the maximum
(...skipping 20 matching lines...) Expand all
82 scoped_ptr<base::RunLoop> run_loop_; 80 scoped_ptr<base::RunLoop> run_loop_;
83 81
84 DISALLOW_COPY_AND_ASSIGN(StoreFlushWaiter); 82 DISALLOW_COPY_AND_ASSIGN(StoreFlushWaiter);
85 }; 83 };
86 84
87 } // namespace 85 } // namespace
88 86
89 class SearchHistoryTest : public testing::Test { 87 class SearchHistoryTest : public testing::Test {
90 public: 88 public:
91 SearchHistoryTest() {} 89 SearchHistoryTest() {}
92 virtual ~SearchHistoryTest() {} 90 ~SearchHistoryTest() override {}
93 91
94 // testing::Test overrides: 92 // testing::Test overrides:
95 virtual void SetUp() override { 93 void SetUp() override {
96 worker_pool_ = new base::SequencedWorkerPool(1, "AppLauncherTest"); 94 worker_pool_ = new base::SequencedWorkerPool(1, "AppLauncherTest");
97 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 95 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
98 CreateHistory(); 96 CreateHistory();
99 } 97 }
100 virtual void TearDown() override { 98 void TearDown() override { Flush(); }
101 Flush();
102 }
103 99
104 void CreateHistory() { 100 void CreateHistory() {
105 const char kStoreDataFileName[] = "app-launcher-test"; 101 const char kStoreDataFileName[] = "app-launcher-test";
106 const base::FilePath data_file = 102 const base::FilePath data_file =
107 temp_dir_.path().AppendASCII(kStoreDataFileName); 103 temp_dir_.path().AppendASCII(kStoreDataFileName);
108 scoped_refptr<DictionaryDataStore> dictionary_data_store( 104 scoped_refptr<DictionaryDataStore> dictionary_data_store(
109 new DictionaryDataStore(data_file, worker_pool_.get())); 105 new DictionaryDataStore(data_file, worker_pool_.get()));
110 history_.reset(new History(scoped_refptr<HistoryDataStore>( 106 history_.reset(new History(scoped_refptr<HistoryDataStore>(
111 new HistoryDataStore(dictionary_data_store)))); 107 new HistoryDataStore(dictionary_data_store))));
112 108
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 289
294 // The oldest secondary is gone. 290 // The oldest secondary is gone.
295 EXPECT_EQ(UNKNOWN_RESULT, GetResultType("1")); 291 EXPECT_EQ(UNKNOWN_RESULT, GetResultType("1"));
296 292
297 // Touched oldest survived. 293 // Touched oldest survived.
298 EXPECT_EQ(PERFECT_SECONDARY, GetResultType("0")); 294 EXPECT_EQ(PERFECT_SECONDARY, GetResultType("0"));
299 } 295 }
300 296
301 } // namespace test 297 } // namespace test
302 } // namespace app_list 298 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698