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

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

Issue 1943993006: Create test fixture for SafeBrowsingService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase update Created 4 years, 7 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/unverified_download_policy_unittest.cc
diff --git a/chrome/browser/safe_browsing/unverified_download_policy_unittest.cc b/chrome/browser/safe_browsing/unverified_download_policy_unittest.cc
index 67dc35c62e7f8c8488d23e8b535b1956b377f6cd..61e31ca06e066740423c28c5442c738ae3c6bb24 100644
--- a/chrome/browser/safe_browsing/unverified_download_policy_unittest.cc
+++ b/chrome/browser/safe_browsing/unverified_download_policy_unittest.cc
@@ -10,7 +10,7 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/run_loop.h"
-#include "chrome/browser/safe_browsing/safe_browsing_service.h"
+#include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_browser_process.h"
@@ -37,28 +37,6 @@ class FakeDatabaseManager : public TestSafeBrowsingDatabaseManager {
~FakeDatabaseManager() override {}
};
-class TestSafeBrowsingService : public SafeBrowsingService {
- public:
- SafeBrowsingDatabaseManager* CreateDatabaseManager() override {
- return new FakeDatabaseManager();
- }
-
- protected:
- ~TestSafeBrowsingService() override {}
-
- SafeBrowsingProtocolManagerDelegate* GetProtocolManagerDelegate() override {
- // Our FakeDatabaseManager doesn't implement this delegate.
- return NULL;
- }
-};
-
-class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory {
- public:
- SafeBrowsingService* CreateSafeBrowsingService() override {
- return new TestSafeBrowsingService();
- }
-};
-
class CompletionCallback {
public:
CompletionCallback() {}
@@ -95,12 +73,14 @@ class CompletionCallback {
class UnverifiedDownloadPolicyTest : public ::testing::Test {
public:
void SetUp() override {
- SafeBrowsingService::RegisterFactory(&test_safe_browsing_service_factory_);
- testing_safe_browsing_service_ =
- SafeBrowsingService::CreateSafeBrowsingService();
+ SafeBrowsingService::RegisterFactory(
+ &testing_safe_browsing_service_factory_);
TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal();
+ // Set up FakeDatabaseManager.
+ testing_safe_browsing_service_factory_.SetTestDatabaseManager(
+ new FakeDatabaseManager());
browser_process->SetSafeBrowsingService(
- testing_safe_browsing_service_.get());
+ testing_safe_browsing_service_factory_.CreateSafeBrowsingService());
browser_process->safe_browsing_service()->Initialize();
base::RunLoop().RunUntilIdle();
@@ -116,16 +96,14 @@ class UnverifiedDownloadPolicyTest : public ::testing::Test {
TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal();
browser_process->safe_browsing_service()->ShutDown();
browser_process->SetSafeBrowsingService(nullptr);
- testing_safe_browsing_service_ = nullptr;
SafeBrowsingService::RegisterFactory(nullptr);
base::RunLoop().RunUntilIdle();
}
protected:
content::TestBrowserThreadBundle thread_bundle_;
- TestSafeBrowsingServiceFactory test_safe_browsing_service_factory_;
+ TestSafeBrowsingServiceFactory testing_safe_browsing_service_factory_;
std::unique_ptr<TestingProfileManager> testing_profile_manager_;
- scoped_refptr<SafeBrowsingService> testing_safe_browsing_service_;
TestingProfile* testing_profile_ = nullptr;
};

Powered by Google App Engine
This is Rietveld 408576698