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

Side by Side Diff: components/omnibox/browser/history_quick_provider_unittest.cc

Issue 2082333002: Remove calls to deprecated MessageLoop methods in components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 "components/omnibox/browser/history_quick_provider.h" 5 #include "components/omnibox/browser/history_quick_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <functional> 10 #include <functional>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
17 #include "base/format_macros.h" 17 #include "base/format_macros.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/message_loop/message_loop.h" 19 #include "base/message_loop/message_loop.h"
20 #include "base/run_loop.h"
20 #include "base/strings/stringprintf.h" 21 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
22 #include "base/test/sequenced_worker_pool_owner.h" 23 #include "base/test/sequenced_worker_pool_owner.h"
23 #include "components/bookmarks/browser/bookmark_model.h" 24 #include "components/bookmarks/browser/bookmark_model.h"
24 #include "components/bookmarks/test/bookmark_test_helpers.h" 25 #include "components/bookmarks/test/bookmark_test_helpers.h"
25 #include "components/bookmarks/test/test_bookmark_client.h" 26 #include "components/bookmarks/test/test_bookmark_client.h"
26 #include "components/history/core/browser/history_backend.h" 27 #include "components/history/core/browser/history_backend.h"
27 #include "components/history/core/browser/history_database.h" 28 #include "components/history/core/browser/history_database.h"
28 #include "components/history/core/browser/history_service.h" 29 #include "components/history/core/browser/history_service.h"
29 #include "components/history/core/browser/history_service_observer.h" 30 #include "components/history/core/browser/history_service_observer.h"
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 317
317 void HistoryQuickProviderTest::TearDown() { 318 void HistoryQuickProviderTest::TearDown() {
318 provider_ = NULL; 319 provider_ = NULL;
319 // The InMemoryURLIndex must be explicitly shut down or it will DCHECK() in 320 // The InMemoryURLIndex must be explicitly shut down or it will DCHECK() in
320 // its destructor. 321 // its destructor.
321 client_->GetInMemoryURLIndex()->Shutdown(); 322 client_->GetInMemoryURLIndex()->Shutdown();
322 client_->set_in_memory_url_index(nullptr); 323 client_->set_in_memory_url_index(nullptr);
323 // History index rebuild task is created from main thread during SetUp, 324 // History index rebuild task is created from main thread during SetUp,
324 // performed on DB thread and must be deleted on main thread. 325 // performed on DB thread and must be deleted on main thread.
325 // Run main loop to process delete task, to prevent leaks. 326 // Run main loop to process delete task, to prevent leaks.
326 base::MessageLoop::current()->RunUntilIdle(); 327 base::RunLoop().RunUntilIdle();
327 } 328 }
328 329
329 void HistoryQuickProviderTest::GetTestData(size_t* data_count, 330 void HistoryQuickProviderTest::GetTestData(size_t* data_count,
330 TestURLInfo** test_data) { 331 TestURLInfo** test_data) {
331 DCHECK(data_count); 332 DCHECK(data_count);
332 DCHECK(test_data); 333 DCHECK(test_data);
333 *data_count = arraysize(quick_test_db); 334 *data_count = arraysize(quick_test_db);
334 *test_data = &quick_test_db[0]; 335 *test_data = &quick_test_db[0];
335 } 336 }
336 337
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 406
406 void HistoryQuickProviderTest::RunTestWithCursor( 407 void HistoryQuickProviderTest::RunTestWithCursor(
407 const base::string16 text, 408 const base::string16 text,
408 const size_t cursor_position, 409 const size_t cursor_position,
409 bool prevent_inline_autocomplete, 410 bool prevent_inline_autocomplete,
410 std::vector<std::string> expected_urls, 411 std::vector<std::string> expected_urls,
411 bool can_inline_top_result, 412 bool can_inline_top_result,
412 base::string16 expected_fill_into_edit, 413 base::string16 expected_fill_into_edit,
413 base::string16 expected_autocompletion) { 414 base::string16 expected_autocompletion) {
414 SCOPED_TRACE(text); // Minimal hint to query being run. 415 SCOPED_TRACE(text); // Minimal hint to query being run.
415 base::MessageLoop::current()->RunUntilIdle(); 416 base::RunLoop().RunUntilIdle();
416 AutocompleteInput input(text, cursor_position, std::string(), GURL(), 417 AutocompleteInput input(text, cursor_position, std::string(), GURL(),
417 metrics::OmniboxEventProto::INVALID_SPEC, 418 metrics::OmniboxEventProto::INVALID_SPEC,
418 prevent_inline_autocomplete, false, true, true, false, 419 prevent_inline_autocomplete, false, true, true, false,
419 TestSchemeClassifier()); 420 TestSchemeClassifier());
420 provider_->Start(input, false); 421 provider_->Start(input, false);
421 EXPECT_TRUE(provider_->done()); 422 EXPECT_TRUE(provider_->done());
422 423
423 ac_matches_ = provider_->matches(); 424 ac_matches_ = provider_->matches();
424 425
425 // We should have gotten back at most AutocompleteProvider::kMaxMatches. 426 // We should have gotten back at most AutocompleteProvider::kMaxMatches.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 } 466 }
466 467
467 bool HistoryQuickProviderTest::GetURLProxy(const GURL& url) { 468 bool HistoryQuickProviderTest::GetURLProxy(const GURL& url) {
468 base::CancelableTaskTracker task_tracker; 469 base::CancelableTaskTracker task_tracker;
469 bool result = false; 470 bool result = false;
470 client_->GetHistoryService()->ScheduleDBTask( 471 client_->GetHistoryService()->ScheduleDBTask(
471 std::unique_ptr<history::HistoryDBTask>(new GetURLTask(url, &result)), 472 std::unique_ptr<history::HistoryDBTask>(new GetURLTask(url, &result)),
472 &task_tracker); 473 &task_tracker);
473 // Run the message loop until GetURLTask::DoneRunOnMainThread stops it. If 474 // Run the message loop until GetURLTask::DoneRunOnMainThread stops it. If
474 // the test hangs, DoneRunOnMainThread isn't being invoked correctly. 475 // the test hangs, DoneRunOnMainThread isn't being invoked correctly.
475 base::MessageLoop::current()->Run(); 476 base::RunLoop().Run();
476 return result; 477 return result;
477 } 478 }
478 479
479 TEST_F(HistoryQuickProviderTest, SimpleSingleMatch) { 480 TEST_F(HistoryQuickProviderTest, SimpleSingleMatch) {
480 std::vector<std::string> expected_urls; 481 std::vector<std::string> expected_urls;
481 expected_urls.push_back("http://slashdot.org/favorite_page.html"); 482 expected_urls.push_back("http://slashdot.org/favorite_page.html");
482 RunTest(ASCIIToUTF16("slashdot"), false, expected_urls, true, 483 RunTest(ASCIIToUTF16("slashdot"), false, expected_urls, true,
483 ASCIIToUTF16("slashdot.org/favorite_page.html"), 484 ASCIIToUTF16("slashdot.org/favorite_page.html"),
484 ASCIIToUTF16(".org/favorite_page.html")); 485 ASCIIToUTF16(".org/favorite_page.html"));
485 } 486 }
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 887
887 TEST_F(HQPOrderingTest, TEAMatch) { 888 TEST_F(HQPOrderingTest, TEAMatch) {
888 std::vector<std::string> expected_urls; 889 std::vector<std::string> expected_urls;
889 expected_urls.push_back("http://www.teamliquid.net/"); 890 expected_urls.push_back("http://www.teamliquid.net/");
890 expected_urls.push_back("http://www.teamliquid.net/tlpd"); 891 expected_urls.push_back("http://www.teamliquid.net/tlpd");
891 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players"); 892 expected_urls.push_back("http://www.teamliquid.net/tlpd/korean/players");
892 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true, 893 RunTest(ASCIIToUTF16("tea"), false, expected_urls, true,
893 ASCIIToUTF16("www.teamliquid.net"), 894 ASCIIToUTF16("www.teamliquid.net"),
894 ASCIIToUTF16("mliquid.net")); 895 ASCIIToUTF16("mliquid.net"));
895 } 896 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698