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

Side by Side Diff: chrome/browser/autocomplete/history_contents_provider_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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/autocomplete/history_contents_provider.h" 5 #include "chrome/browser/autocomplete/history_contents_provider.h"
6 6
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/autocomplete/autocomplete_match.h" 10 #include "chrome/browser/autocomplete/autocomplete_match.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 : ui_thread_(BrowserThread::UI, &message_loop_), 49 : ui_thread_(BrowserThread::UI, &message_loop_),
50 file_thread_(BrowserThread::FILE, &message_loop_) {} 50 file_thread_(BrowserThread::FILE, &message_loop_) {}
51 51
52 void RunQuery(const AutocompleteInput& input, 52 void RunQuery(const AutocompleteInput& input,
53 bool minimal_changes) { 53 bool minimal_changes) {
54 provider_->Start(input, minimal_changes); 54 provider_->Start(input, minimal_changes);
55 55
56 // When we're waiting for asynchronous messages, we have to spin the message 56 // When we're waiting for asynchronous messages, we have to spin the message
57 // loop. This will be exited in the OnProviderUpdate function when complete. 57 // loop. This will be exited in the OnProviderUpdate function when complete.
58 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) 58 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES)
59 MessageLoop::current()->Run(); 59 base::MessageLoop::current()->Run();
60 } 60 }
61 61
62 const ACMatches& matches() const { return provider_->matches(); } 62 const ACMatches& matches() const { return provider_->matches(); }
63 TestingProfile* profile() const { return profile_.get(); } 63 TestingProfile* profile() const { return profile_.get(); }
64 HistoryContentsProvider* provider() const { return provider_.get(); } 64 HistoryContentsProvider* provider() const { return provider_.get(); }
65 65
66 protected: 66 protected:
67 virtual bool BodyOnly() { return false; } 67 virtual bool BodyOnly() { return false; }
68 68
69 private: 69 private:
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 virtual void TearDown() { 109 virtual void TearDown() {
110 provider_ = NULL; 110 provider_ = NULL;
111 profile_.reset(NULL); 111 profile_.reset(NULL);
112 } 112 }
113 113
114 // AutocompleteProviderListener: 114 // AutocompleteProviderListener:
115 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE { 115 virtual void OnProviderUpdate(bool updated_matches) OVERRIDE {
116 // We must quit the message loop (if running) to return control to the test. 116 // We must quit the message loop (if running) to return control to the test.
117 // Note, calling Quit() directly will checkfail if the loop isn't running, 117 // Note, calling Quit() directly will checkfail if the loop isn't running,
118 // so we post a task, which is safe for either case. 118 // so we post a task, which is safe for either case.
119 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 119 base::MessageLoop::current()->PostTask(FROM_HERE,
120 base::MessageLoop::QuitClosure());
120 } 121 }
121 122
122 MessageLoopForUI message_loop_; 123 base::MessageLoopForUI message_loop_;
123 content::TestBrowserThread ui_thread_; 124 content::TestBrowserThread ui_thread_;
124 content::TestBrowserThread file_thread_; 125 content::TestBrowserThread file_thread_;
125 126
126 scoped_ptr<TestingProfile> profile_; 127 scoped_ptr<TestingProfile> profile_;
127 scoped_refptr<HistoryContentsProvider> provider_; 128 scoped_refptr<HistoryContentsProvider> provider_;
128 }; 129 };
129 130
130 class HistoryContentsProviderBodyOnlyTest : public HistoryContentsProviderTest { 131 class HistoryContentsProviderBodyOnlyTest : public HistoryContentsProviderTest {
131 protected: 132 protected:
132 virtual bool BodyOnly() OVERRIDE { return true; } 133 virtual bool BodyOnly() OVERRIDE { return true; }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 281
281 // Run a query that is found on a search result page and on the main page 282 // Run a query that is found on a search result page and on the main page
282 // of the default search engine. The result should be the main page, the 283 // of the default search engine. The result should be the main page, the
283 // SRP should be culled. 284 // SRP should be culled.
284 const ACMatches& m = matches(); 285 const ACMatches& m = matches();
285 ASSERT_EQ(1U, m.size()); 286 ASSERT_EQ(1U, m.size());
286 EXPECT_EQ(test_entries[4].url, m[0].destination_url.spec()); 287 EXPECT_EQ(test_entries[4].url, m[0].destination_url.spec());
287 } 288 }
288 289
289 } // namespace 290 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698