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

Side by Side Diff: chrome/browser/predictors/autocomplete_action_predictor_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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 "chrome/browser/predictors/autocomplete_action_predictor.h" 5 #include "chrome/browser/predictors/autocomplete_action_predictor.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 AutocompleteActionPredictor::ACTION_NONE } 75 AutocompleteActionPredictor::ACTION_NONE }
76 }; 76 };
77 77
78 } // end namespace 78 } // end namespace
79 79
80 namespace predictors { 80 namespace predictors {
81 81
82 class AutocompleteActionPredictorTest : public testing::Test { 82 class AutocompleteActionPredictorTest : public testing::Test {
83 public: 83 public:
84 AutocompleteActionPredictorTest() 84 AutocompleteActionPredictorTest()
85 : loop_(MessageLoop::TYPE_DEFAULT), 85 : loop_(base::MessageLoop::TYPE_DEFAULT),
86 ui_thread_(BrowserThread::UI, &loop_), 86 ui_thread_(BrowserThread::UI, &loop_),
87 db_thread_(BrowserThread::DB, &loop_), 87 db_thread_(BrowserThread::DB, &loop_),
88 file_thread_(BrowserThread::FILE, &loop_), 88 file_thread_(BrowserThread::FILE, &loop_),
89 profile_(new TestingProfile()), 89 profile_(new TestingProfile()),
90 predictor_(new AutocompleteActionPredictor(profile_.get())) { 90 predictor_(new AutocompleteActionPredictor(profile_.get())) {}
91 }
92 91
93 virtual ~AutocompleteActionPredictorTest() { 92 virtual ~AutocompleteActionPredictorTest() {
94 predictor_.reset(NULL); 93 predictor_.reset(NULL);
95 profile_.reset(NULL); 94 profile_.reset(NULL);
96 loop_.RunUntilIdle(); 95 loop_.RunUntilIdle();
97 } 96 }
98 97
99 virtual void SetUp() { 98 virtual void SetUp() {
100 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 99 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
101 switches::kPrerenderFromOmnibox, 100 switches::kPrerenderFromOmnibox,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 AutocompleteActionPredictor* predictor() { return predictor_.get(); } 206 AutocompleteActionPredictor* predictor() { return predictor_.get(); }
208 207
209 DBCacheMap* db_cache() { return &predictor_->db_cache_; } 208 DBCacheMap* db_cache() { return &predictor_->db_cache_; }
210 DBIdCacheMap* db_id_cache() { return &predictor_->db_id_cache_; } 209 DBIdCacheMap* db_id_cache() { return &predictor_->db_id_cache_; }
211 210
212 static int maximum_days_to_keep_entry() { 211 static int maximum_days_to_keep_entry() {
213 return AutocompleteActionPredictor::kMaximumDaysToKeepEntry; 212 return AutocompleteActionPredictor::kMaximumDaysToKeepEntry;
214 } 213 }
215 214
216 private: 215 private:
217 MessageLoop loop_; 216 base::MessageLoop loop_;
218 content::TestBrowserThread ui_thread_; 217 content::TestBrowserThread ui_thread_;
219 content::TestBrowserThread db_thread_; 218 content::TestBrowserThread db_thread_;
220 content::TestBrowserThread file_thread_; 219 content::TestBrowserThread file_thread_;
221 scoped_ptr<TestingProfile> profile_; 220 scoped_ptr<TestingProfile> profile_;
222 scoped_ptr<AutocompleteActionPredictor> predictor_; 221 scoped_ptr<AutocompleteActionPredictor> predictor_;
223 }; 222 };
224 223
225 224
226 TEST_F(AutocompleteActionPredictorTest, AddRow) { 225 TEST_F(AutocompleteActionPredictorTest, AddRow) {
227 // Add a test entry to the predictor. 226 // Add a test entry to the predictor.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 AutocompleteActionPredictor::ACTION_PRERENDER) ? 374 AutocompleteActionPredictor::ACTION_PRERENDER) ?
376 AutocompleteActionPredictor::ACTION_PRECONNECT : 375 AutocompleteActionPredictor::ACTION_PRECONNECT :
377 test_url_db[i].expected_action; 376 test_url_db[i].expected_action;
378 EXPECT_EQ(expected_action, 377 EXPECT_EQ(expected_action,
379 predictor()->RecommendAction(test_url_db[i].user_text, match)) 378 predictor()->RecommendAction(test_url_db[i].user_text, match))
380 << "Unexpected action for " << match.destination_url; 379 << "Unexpected action for " << match.destination_url;
381 } 380 }
382 } 381 }
383 382
384 } // namespace predictors 383 } // namespace predictors
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698