Index: chrome/browser/safe_browsing/client_side_detection_host_unittest.cc |
diff --git a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc |
index 5a19583a85c819772bfe40d8be1bcf7f03d53807..b156df8ca450113ae5e568d6bc4d2f82759c81cc 100644 |
--- a/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc |
+++ b/chrome/browser/safe_browsing/client_side_detection_host_unittest.cc |
@@ -49,6 +49,11 @@ MATCHER_P(EqualsProto, other, "") { |
return other.SerializeAsString() == arg.SerializeAsString(); |
} |
+ACTION(QuitUIMessageLoop) { |
+ EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ MessageLoopForUI::current()->Quit(); |
+} |
+ |
class MockClientSideDetectionService : public ClientSideDetectionService { |
public: |
explicit MockClientSideDetectionService(const FilePath& model_path) |
@@ -98,7 +103,7 @@ class MockTestingProfile : public TestingProfile { |
}; |
// Helper function which quits the UI message loop from the IO message loop. |
-void QuitUIMessageLoop() { |
+void QuitUIMessageLoopFromIO() { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
BrowserThread::PostTask(BrowserThread::UI, |
FROM_HERE, |
@@ -113,6 +118,7 @@ class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness { |
// a nice mock because other parts of the code are calling IsOffTheRecord. |
mock_profile_ = new NiceMock<MockTestingProfile>(); |
profile_.reset(mock_profile_); |
+ profile_->CreateHistoryService(true /* delete_file */, false /* no_db */); |
TabContentsWrapperTestHarness::SetUp(); |
ui_thread_.reset(new BrowserThread(BrowserThread::UI, &message_loop_)); |
@@ -150,7 +156,7 @@ class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness { |
// we put the quit message there. |
BrowserThread::PostTask(BrowserThread::IO, |
FROM_HERE, |
- NewRunnableFunction(&QuitUIMessageLoop)); |
+ NewRunnableFunction(&QuitUIMessageLoopFromIO)); |
MessageLoop::current()->Run(); |
} |
@@ -227,8 +233,9 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteNotPhishing) { |
EXPECT_CALL(*csd_service_, |
SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
- .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb))); |
+ .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop())); |
OnDetectedPhishingSite(verdict.SerializeAsString()); |
+ MessageLoop::current()->Run(); |
EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
ASSERT_TRUE(cb); |
@@ -251,8 +258,9 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteDisabled) { |
EXPECT_CALL(*csd_service_, |
SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
- .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb))); |
+ .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop())); |
OnDetectedPhishingSite(verdict.SerializeAsString()); |
+ MessageLoop::current()->Run(); |
EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
ASSERT_TRUE(cb); |
@@ -276,8 +284,9 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteShowInterstitial) { |
EXPECT_CALL(*csd_service_, |
SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
- .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb))); |
+ .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop())); |
OnDetectedPhishingSite(verdict.SerializeAsString()); |
+ MessageLoop::current()->Run(); |
EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
ASSERT_TRUE(cb); |
@@ -328,8 +337,9 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteMultiplePings) { |
EXPECT_CALL(*csd_service_, |
SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
- .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb))); |
+ .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb), QuitUIMessageLoop())); |
OnDetectedPhishingSite(verdict.SerializeAsString()); |
+ MessageLoop::current()->Run(); |
EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
ASSERT_TRUE(cb); |
GURL other_phishing_url("http://other_phishing_url.com/bla"); |
@@ -345,8 +355,11 @@ TEST_F(ClientSideDetectionHostTest, OnDetectedPhishingSiteMultiplePings) { |
verdict.set_client_score(0.8f); |
EXPECT_CALL(*csd_service_, |
SendClientReportPhishingRequest(Pointee(EqualsProto(verdict)), _)) |
- .WillOnce(DoAll(DeleteArg<0>(), SaveArg<1>(&cb_other))); |
+ .WillOnce(DoAll(DeleteArg<0>(), |
+ SaveArg<1>(&cb_other), |
+ QuitUIMessageLoop())); |
OnDetectedPhishingSite(verdict.SerializeAsString()); |
+ MessageLoop::current()->Run(); |
EXPECT_TRUE(Mock::VerifyAndClear(csd_service_.get())); |
ASSERT_TRUE(cb_other); |