| Index: components/visitedlink/test/visitedlink_unittest.cc
|
| diff --git a/components/visitedlink/test/visitedlink_unittest.cc b/components/visitedlink/test/visitedlink_unittest.cc
|
| index b53f8a9fabccaee94b822450e9848e10b72803b9..1d38989b80f18cc9095cea0eff80ca9951e90e39 100644
|
| --- a/components/visitedlink/test/visitedlink_unittest.cc
|
| +++ b/components/visitedlink/test/visitedlink_unittest.cc
|
| @@ -10,6 +10,7 @@
|
| #include "base/message_loop.h"
|
| #include "base/path_service.h"
|
| #include "base/process_util.h"
|
| +#include "base/run_loop.h"
|
| #include "base/shared_memory.h"
|
| #include "base/string_util.h"
|
| #include "base/time.h"
|
| @@ -22,7 +23,7 @@
|
| #include "content/public/browser/notification_types.h"
|
| #include "content/public/test/mock_render_process_host.h"
|
| #include "content/public/test/test_browser_context.h"
|
| -#include "content/public/test/test_browser_thread.h"
|
| +#include "content/public/test/test_browser_thread_bundle.h"
|
| #include "content/public/test/test_renderer_host.h"
|
| #include "googleurl/src/gurl.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| @@ -135,9 +136,6 @@ class TrackingVisitedLinkEventListener : public VisitedLinkMaster::Listener {
|
|
|
| class VisitedLinkTest : public testing::Test {
|
| protected:
|
| - VisitedLinkTest()
|
| - : ui_thread_(BrowserThread::UI, &message_loop_),
|
| - file_thread_(BrowserThread::FILE, &message_loop_) {}
|
| // Initializes the visited link objects. Pass in the size that you want a
|
| // freshly created table to be. 0 means use the default.
|
| //
|
| @@ -222,16 +220,13 @@ class VisitedLinkTest : public testing::Test {
|
|
|
| base::ScopedTempDir temp_dir_;
|
|
|
| - base::MessageLoop message_loop_;
|
| - content::TestBrowserThread ui_thread_;
|
| - content::TestBrowserThread file_thread_;
|
| -
|
| // Filenames for the services;
|
| base::FilePath history_dir_;
|
| base::FilePath visited_file_;
|
|
|
| scoped_ptr<VisitedLinkMaster> master_;
|
| TestVisitedLinkDelegate delegate_;
|
| + content::TestBrowserThreadBundle thread_bundle_;
|
| };
|
|
|
| // This test creates and reads some databases to make sure the data is
|
| @@ -438,8 +433,9 @@ TEST_F(VisitedLinkTest, Rebuild) {
|
| // complete before we set the task because the rebuild completion message
|
| // is posted to the message loop; until we Run() it, rebuild can not
|
| // complete.
|
| - master_->set_rebuild_complete_task(base::MessageLoop::QuitClosure());
|
| - base::MessageLoop::current()->Run();
|
| + base::RunLoop run_loop;
|
| + master_->set_rebuild_complete_task(run_loop.QuitClosure());
|
| + run_loop.Run();
|
|
|
| // Test that all URLs were written to the database properly.
|
| Reload();
|
| @@ -458,8 +454,9 @@ TEST_F(VisitedLinkTest, BigImport) {
|
| master_->AddURL(TestURL(i));
|
|
|
| // Wait for the rebuild to complete.
|
| - master_->set_rebuild_complete_task(base::MessageLoop::QuitClosure());
|
| - base::MessageLoop::current()->Run();
|
| + base::RunLoop run_loop;
|
| + master_->set_rebuild_complete_task(run_loop.QuitClosure());
|
| + run_loop.Run();
|
|
|
| // Ensure that the right number of URLs are present
|
| int used_count = master_->GetUsedCount();
|
| @@ -592,10 +589,6 @@ class VisitedLinkRenderProcessHostFactory
|
|
|
| class VisitedLinkEventsTest : public content::RenderViewHostTestHarness {
|
| public:
|
| - VisitedLinkEventsTest()
|
| - : ui_thread_(BrowserThread::UI, &message_loop_),
|
| - file_thread_(BrowserThread::FILE, &message_loop_) {}
|
| - virtual ~VisitedLinkEventsTest() {}
|
| virtual void SetUp() {
|
| browser_context_.reset(new VisitCountingContext());
|
| master_.reset(new VisitedLinkMaster(context(), &delegate_, true));
|
| @@ -614,11 +607,14 @@ class VisitedLinkEventsTest : public content::RenderViewHostTestHarness {
|
|
|
| void WaitForCoalescense() {
|
| // Let the timer fire.
|
| - base::MessageLoop::current()->PostDelayedTask(
|
| + //
|
| + // TODO(ajwong): This is horrid! What is the right synchronization method?
|
| + base::RunLoop run_loop;
|
| + MessageLoop::current()->PostDelayedTask(
|
| FROM_HERE,
|
| - base::MessageLoop::QuitClosure(),
|
| + run_loop.QuitClosure(),
|
| base::TimeDelta::FromMilliseconds(110));
|
| - base::MessageLoop::current()->Run();
|
| + run_loop.Run();
|
| }
|
|
|
| protected:
|
| @@ -627,10 +623,6 @@ class VisitedLinkEventsTest : public content::RenderViewHostTestHarness {
|
| private:
|
| TestVisitedLinkDelegate delegate_;
|
| scoped_ptr<VisitedLinkMaster> master_;
|
| - content::TestBrowserThread ui_thread_;
|
| - content::TestBrowserThread file_thread_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(VisitedLinkEventsTest);
|
| };
|
|
|
| TEST_F(VisitedLinkEventsTest, Coalescense) {
|
|
|