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 "chrome/browser/autocomplete/history_contents_provider.h" | 5 #include "chrome/browser/autocomplete/history_contents_provider.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 : ui_thread_(BrowserThread::UI, &message_loop_), | 50 : ui_thread_(BrowserThread::UI, &message_loop_), |
51 file_thread_(BrowserThread::FILE, &message_loop_) {} | 51 file_thread_(BrowserThread::FILE, &message_loop_) {} |
52 | 52 |
53 void RunQuery(const AutocompleteInput& input, | 53 void RunQuery(const AutocompleteInput& input, |
54 bool minimal_changes) { | 54 bool minimal_changes) { |
55 provider_->Start(input, minimal_changes); | 55 provider_->Start(input, minimal_changes); |
56 | 56 |
57 // When we're waiting for asynchronous messages, we have to spin the message | 57 // When we're waiting for asynchronous messages, we have to spin the message |
58 // loop. This will be exited in the OnProviderUpdate function when complete. | 58 // loop. This will be exited in the OnProviderUpdate function when complete. |
59 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) | 59 if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) |
60 MessageLoop::current()->Run(); | 60 base::MessageLoop::current()->Run(); |
61 } | 61 } |
62 | 62 |
63 const ACMatches& matches() const { return provider_->matches(); } | 63 const ACMatches& matches() const { return provider_->matches(); } |
64 TestingProfile* profile() const { return profile_.get(); } | 64 TestingProfile* profile() const { return profile_.get(); } |
65 HistoryContentsProvider* provider() const { return provider_.get(); } | 65 HistoryContentsProvider* provider() const { return provider_.get(); } |
66 | 66 |
67 protected: | 67 protected: |
68 virtual bool BodyOnly() { return false; } | 68 virtual bool BodyOnly() { return false; } |
69 | 69 |
70 private: | 70 private: |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |