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

Side by Side Diff: chrome/browser/autocomplete/shortcuts_provider_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, 8 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/shortcuts_provider.h" 5 #include "chrome/browser/autocomplete/shortcuts_provider.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 // Fills test data into the provider. 148 // Fills test data into the provider.
149 void FillData(TestShortcutInfo* db, size_t db_size); 149 void FillData(TestShortcutInfo* db, size_t db_size);
150 150
151 // Runs an autocomplete query on |text| and checks to see that the returned 151 // Runs an autocomplete query on |text| and checks to see that the returned
152 // results' destination URLs match those provided. |expected_urls| does not 152 // results' destination URLs match those provided. |expected_urls| does not
153 // need to be in sorted order. 153 // need to be in sorted order.
154 void RunTest(const string16 text, 154 void RunTest(const string16 text,
155 std::vector<std::string> expected_urls, 155 std::vector<std::string> expected_urls,
156 std::string expected_top_result); 156 std::string expected_top_result);
157 157
158 MessageLoopForUI message_loop_; 158 base::MessageLoopForUI message_loop_;
159 content::TestBrowserThread ui_thread_; 159 content::TestBrowserThread ui_thread_;
160 content::TestBrowserThread file_thread_; 160 content::TestBrowserThread file_thread_;
161 161
162 TestingProfile profile_; 162 TestingProfile profile_;
163 163
164 ACMatches ac_matches_; // The resulting matches after running RunTest. 164 ACMatches ac_matches_; // The resulting matches after running RunTest.
165 165
166 scoped_refptr<ShortcutsBackend> backend_; 166 scoped_refptr<ShortcutsBackend> backend_;
167 scoped_refptr<ShortcutsProvider> provider_; 167 scoped_refptr<ShortcutsProvider> provider_;
168 }; 168 };
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 void ShortcutsProviderTest::SetShouldContain::operator()( 218 void ShortcutsProviderTest::SetShouldContain::operator()(
219 const std::string& expected) { 219 const std::string& expected) {
220 EXPECT_EQ(1U, matches_.erase(expected)); 220 EXPECT_EQ(1U, matches_.erase(expected));
221 } 221 }
222 222
223 void ShortcutsProviderTest::RunTest(const string16 text, 223 void ShortcutsProviderTest::RunTest(const string16 text,
224 std::vector<std::string> expected_urls, 224 std::vector<std::string> expected_urls,
225 std::string expected_top_result) { 225 std::string expected_top_result) {
226 std::sort(expected_urls.begin(), expected_urls.end()); 226 std::sort(expected_urls.begin(), expected_urls.end());
227 227
228 MessageLoop::current()->RunUntilIdle(); 228 base::MessageLoop::current()->RunUntilIdle();
229 AutocompleteInput input(text, string16::npos, string16(), GURL(), false, 229 AutocompleteInput input(text,
brettw 2013/04/28 04:26:27 Ditto
230 false, true, AutocompleteInput::ALL_MATCHES); 230 string16::npos,
231 string16(),
232 GURL(),
233 false,
234 false,
235 true,
236 AutocompleteInput::ALL_MATCHES);
231 provider_->Start(input, false); 237 provider_->Start(input, false);
232 EXPECT_TRUE(provider_->done()); 238 EXPECT_TRUE(provider_->done());
233 239
234 ac_matches_ = provider_->matches(); 240 ac_matches_ = provider_->matches();
235 241
236 // We should have gotten back at most AutocompleteProvider::kMaxMatches. 242 // We should have gotten back at most AutocompleteProvider::kMaxMatches.
237 EXPECT_LE(ac_matches_.size(), AutocompleteProvider::kMaxMatches); 243 EXPECT_LE(ac_matches_.size(), AutocompleteProvider::kMaxMatches);
238 244
239 // If the number of expected and actual matches aren't equal then we need 245 // If the number of expected and actual matches aren't equal then we need
240 // test no further, but let's do anyway so that we know which URLs failed. 246 // test no further, but let's do anyway so that we know which URLs failed.
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 670
665 match.destination_url = GURL(shortcuts_to_test_delete[2].url); 671 match.destination_url = GURL(shortcuts_to_test_delete[2].url);
666 match.contents = ASCIIToUTF16(shortcuts_to_test_delete[2].contents); 672 match.contents = ASCIIToUTF16(shortcuts_to_test_delete[2].contents);
667 match.description = ASCIIToUTF16(shortcuts_to_test_delete[2].description); 673 match.description = ASCIIToUTF16(shortcuts_to_test_delete[2].description);
668 674
669 provider_->DeleteMatch(match); 675 provider_->DeleteMatch(match);
670 EXPECT_EQ(original_shortcuts_count, backend_->shortcuts_map().size()); 676 EXPECT_EQ(original_shortcuts_count, backend_->shortcuts_map().size());
671 EXPECT_TRUE(backend_->shortcuts_map().end() == 677 EXPECT_TRUE(backend_->shortcuts_map().end() ==
672 backend_->shortcuts_map().find(ASCIIToUTF16("delete"))); 678 backend_->shortcuts_map().find(ASCIIToUTF16("delete")));
673 } 679 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698