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

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: Address Pawel's comments 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..e159c5742e7528268e97b170e472ed5a7562d2ca 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,13 +103,16 @@ 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,
new MessageLoop::QuitTask());
}
+
Paweł Hajdan Jr. 2011/06/09 09:13:10 nit: Why so many empty lines?
noelutz 2011/06/09 19:21:39 Removed.
+
+
class ClientSideDetectionHostTest : public TabContentsWrapperTestHarness {
public:
virtual void SetUp() {
@@ -150,7 +158,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 +235,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 +260,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 +286,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 +339,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 +357,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