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

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

Issue 7583007: Add "enabled" state to the ClientSideDetectionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 9 years, 4 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
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
index 871ae6960b9da294af10483c059a8c2c7f4d976a..ea5743ae908ac74d34d571869ec2ce966dc870ca 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/safe_browsing/client_side_detection_service.h"
#include "chrome/browser/safe_browsing/safe_browsing_database.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/safe_browsing/safe_browsing_util.h"
@@ -315,7 +316,7 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest {
}
virtual void SetUp() {
- // InProcessBrowserTest::SetUp() intantiates SafebrowsingService and
+ // InProcessBrowserTest::SetUp() instantiates SafebrowsingService and
// RegisterFactory has to be called before SafeBrowsingService is created.
SafeBrowsingDatabase::RegisterFactory(&db_factory_);
SafeBrowsingProtocolManager::RegisterFactory(&pm_factory_);
@@ -397,6 +398,15 @@ class SafeBrowsingServiceTest : public InProcessBrowserTest {
sb_service->download_hashcheck_timeout_ms_ = ms;
}
+ void CreateCSDService() {
+ safe_browsing::ClientSideDetectionService* csd_service =
+ safe_browsing::ClientSideDetectionService::Create(NULL);
+ SafeBrowsingService* sb_service =
+ g_browser_process->safe_browsing_service();
+ sb_service->csd_service_.reset(csd_service);
+ sb_service->RefreshState();
+ }
+
protected:
StrictMock<MockObserver> observer_;
@@ -698,14 +708,22 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, CheckDownloadHashTimedOut) {
}
IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, StartAndStop) {
+ CreateCSDService();
SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service();
+ safe_browsing::ClientSideDetectionService* csd_service =
+ sb_service->safe_browsing_detection_service();
PrefService* pref_service = browser()->profile()->GetPrefs();
+ ASSERT_TRUE(sb_service != NULL);
+ ASSERT_TRUE(csd_service != NULL);
+ ASSERT_TRUE(pref_service != NULL);
+
EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled));
// SBS might still be starting, make sure this doesn't flake.
WaitForIOThread();
EXPECT_TRUE(sb_service->enabled());
+ EXPECT_TRUE(csd_service->enabled());
// Add a new Profile. SBS should keep running.
ScopedTempDir temp_dir;
@@ -717,27 +735,32 @@ IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, StartAndStop) {
// We don't expect the state to have changed, but if it did, wait for it.
WaitForIOThread();
EXPECT_TRUE(sb_service->enabled());
+ EXPECT_TRUE(csd_service->enabled());
// Change one of the prefs. SBS should keep running.
pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false);
WaitForIOThread();
EXPECT_TRUE(sb_service->enabled());
+ EXPECT_TRUE(csd_service->enabled());
// Change the other pref. SBS should stop now.
pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, false);
WaitForIOThread();
EXPECT_FALSE(sb_service->enabled());
+ EXPECT_FALSE(csd_service->enabled());
// Turn it back on. SBS comes back.
pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, true);
WaitForIOThread();
EXPECT_TRUE(sb_service->enabled());
+ EXPECT_TRUE(csd_service->enabled());
// Delete the Profile. SBS stops again.
pref_service2 = NULL;
profile2.reset();
WaitForIOThread();
EXPECT_FALSE(sb_service->enabled());
+ EXPECT_FALSE(csd_service->enabled());
}
} // namespace
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698