| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/safe_browsing_db/remote_database_manager.h" | 5 #include "components/safe_browsing_db/remote_database_manager.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 public: | 22 public: |
| 23 void StartURLCheck(const URLCheckCallbackMeta& callback, | 23 void StartURLCheck(const URLCheckCallbackMeta& callback, |
| 24 const GURL& url, | 24 const GURL& url, |
| 25 const std::vector<SBThreatType>& threat_types) override {} | 25 const std::vector<SBThreatType>& threat_types) override {} |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 class RemoteDatabaseManagerTest : public testing::Test { | 30 class RemoteDatabaseManagerTest : public testing::Test { |
| 31 protected: | 31 protected: |
| 32 RemoteDatabaseManagerTest() : field_trials_(new base::FieldTrialList(NULL)) {} | 32 RemoteDatabaseManagerTest() |
| 33 : field_trials_(new base::FieldTrialList(nullptr)) {} |
| 33 | 34 |
| 34 void SetUp() override { | 35 void SetUp() override { |
| 35 SafeBrowsingApiHandler::SetInstance(&api_handler_); | 36 SafeBrowsingApiHandler::SetInstance(&api_handler_); |
| 36 db_ = new RemoteSafeBrowsingDatabaseManager(); | 37 db_ = new RemoteSafeBrowsingDatabaseManager(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 // Setup the two field trial params. These are read in db_'s ctor. | 40 // Setup the two field trial params. These are read in db_'s ctor. |
| 40 void SetFieldTrialParams(const std::string types_to_check_val) { | 41 void SetFieldTrialParams(const std::string types_to_check_val) { |
| 41 // Destroy the existing FieldTrialList before creating a new one to avoid | 42 // Destroy the existing FieldTrialList before creating a new one to avoid |
| 42 // a DCHECK. | 43 // a DCHECK. |
| 43 field_trials_.reset(); | 44 field_trials_.reset(); |
| 44 field_trials_.reset(new base::FieldTrialList(NULL)); | 45 field_trials_.reset(new base::FieldTrialList(nullptr)); |
| 45 variations::testing::ClearAllVariationIDs(); | 46 variations::testing::ClearAllVariationIDs(); |
| 46 variations::testing::ClearAllVariationParams(); | 47 variations::testing::ClearAllVariationParams(); |
| 47 | 48 |
| 48 const std::string group_name = "GroupFoo"; // Value not used | 49 const std::string group_name = "GroupFoo"; // Value not used |
| 49 const std::string experiment_name = "SafeBrowsingAndroid"; | 50 const std::string experiment_name = "SafeBrowsingAndroid"; |
| 50 ASSERT_TRUE( | 51 ASSERT_TRUE( |
| 51 base::FieldTrialList::CreateFieldTrial(experiment_name, group_name)); | 52 base::FieldTrialList::CreateFieldTrial(experiment_name, group_name)); |
| 52 | 53 |
| 53 std::map<std::string, std::string> params; | 54 std::map<std::string, std::string> params; |
| 54 if (!types_to_check_val.empty()) | 55 if (!types_to_check_val.empty()) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_SUB_FRAME)); | 97 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_SUB_FRAME)); |
| 97 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_STYLESHEET)); | 98 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_STYLESHEET)); |
| 98 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_SCRIPT)); | 99 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_SCRIPT)); |
| 99 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_IMAGE)); | 100 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_IMAGE)); |
| 100 // ... | 101 // ... |
| 101 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_MEDIA)); | 102 EXPECT_FALSE(db_->CanCheckResourceType(content::RESOURCE_TYPE_MEDIA)); |
| 102 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_WORKER)); | 103 EXPECT_TRUE(db_->CanCheckResourceType(content::RESOURCE_TYPE_WORKER)); |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace safe_browsing | 106 } // namespace safe_browsing |
| OLD | NEW |