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

Unified Diff: chrome/browser/safe_browsing/client_side_detection_host_unittest.cc

Issue 7119003: Create a browser feature extractor that runs after the renderer has (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add missing delete Created 9 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 side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698