Chromium Code Reviews| Index: chrome/browser/profiles/off_the_record_profile_impl_unittest.cc |
| diff --git a/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc b/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc |
| index 4a568b746998b6e6b788ebf64b2ee2d1e7505e2a..3566271f8ed15a8fc6f236ac7ad4c963313477a5 100644 |
| --- a/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc |
| +++ b/chrome/browser/profiles/off_the_record_profile_impl_unittest.cc |
| @@ -18,6 +18,7 @@ |
| #include "chrome/test/base/testing_profile_manager.h" |
| #include "content/public/browser/host_zoom_map.h" |
| #include "content/public/common/page_zoom.h" |
| +#include "content/public/test/mock_resource_context.h" |
| #include "net/dns/mock_host_resolver.h" |
| using content::HostZoomMap; |
| @@ -64,6 +65,19 @@ class TestingProfileWithHostZoomMap : public TestingProfile { |
| DISALLOW_COPY_AND_ASSIGN(TestingProfileWithHostZoomMap); |
| }; |
| +base::Closure ThreadSafeQuit(base::RunLoop* run_loop) { |
| + if (content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
| + return run_loop->QuitClosure(); |
| + } else { |
| + using base::Bind; |
| + using base::IgnoreResult; |
| + return Bind(IgnoreResult(&base::MessageLoopProxy::PostTask), |
| + base::MessageLoopProxy::current(), |
| + FROM_HERE, |
| + run_loop->QuitClosure()); |
| + } |
| +} |
| + |
| } // namespace |
| // We need to have a BrowserProcess in g_browser_process variable, since |
| @@ -81,12 +95,24 @@ class OffTheRecordProfileImplTest : public BrowserWithTestWindowTest { |
| ASSERT_TRUE(profile_manager_->SetUp()); |
| testing_io_thread_state_.reset(new chrome::TestingIOThreadState()); |
| - testing_io_thread_state_->io_thread_state()->globals()->host_resolver.reset( |
| - new net::MockHostResolver()); |
| + base::RunLoop run_loop; |
|
awong
2014/08/11 22:36:33
Is it possible to use something like:
https://co
wjmaclean
2014/08/12 16:57:44
Actually, don't even need that. This is cruft from
|
| + CHECK(content::BrowserThread::PostTask( |
| + content::BrowserThread::IO, |
| + FROM_HERE, |
| + base::Bind(&OffTheRecordProfileImplTest::InitResolver, |
| + base::Unretained(this), |
| + ThreadSafeQuit(&run_loop)))); |
| + run_loop.Run(); |
| BrowserWithTestWindowTest::SetUp(); |
| } |
| + void InitResolver(const base::Closure& done) { |
| + testing_io_thread_state_->io_thread_state()->globals()->host_resolver.reset( |
| + new net::MockHostResolver()); |
| + done.Run(); |
| + } |
| + |
| virtual void TearDown() OVERRIDE { |
| BrowserWithTestWindowTest::TearDown(); |
| @@ -142,13 +168,9 @@ TEST_F(OffTheRecordProfileImplTest, GetHostZoomMap) { |
| // OnZoomLevelChanged. |
| // Prepare an off the record profile owned by the parent profile. |
| - parent_profile->SetOffTheRecordProfile( |
| - scoped_ptr<Profile>(new OffTheRecordProfileImpl(parent_profile))); |
| OffTheRecordProfileImpl* child_profile = |
| static_cast<OffTheRecordProfileImpl*>( |
| parent_profile->GetOffTheRecordProfile()); |
| - child_profile->InitIoData(); |
| - child_profile->InitHostZoomMap(); |
| // Prepare child host zoom map. |
| HostZoomMap* child_zoom_map = |