| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/safe_browsing/client_side_model_loader.h" | 5 #include "chrome/browser/safe_browsing/client_side_model_loader.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 DISALLOW_COPY_AND_ASSIGN(MockModelLoader); | 49 DISALLOW_COPY_AND_ASSIGN(MockModelLoader); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 class ModelLoaderTest : public testing::Test { | 54 class ModelLoaderTest : public testing::Test { |
| 55 protected: | 55 protected: |
| 56 ModelLoaderTest() | 56 ModelLoaderTest() |
| 57 : factory_(new net::FakeURLFetcherFactory(NULL)), | 57 : factory_(new net::FakeURLFetcherFactory(nullptr)), |
| 58 field_trials_(new base::FieldTrialList(NULL)) {} | 58 field_trials_(new base::FieldTrialList(nullptr)) {} |
| 59 | 59 |
| 60 void SetUp() override { | 60 void SetUp() override { |
| 61 variations::testing::ClearAllVariationIDs(); | 61 variations::testing::ClearAllVariationIDs(); |
| 62 variations::testing::ClearAllVariationParams(); | 62 variations::testing::ClearAllVariationParams(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Set up the finch experiment to control the model number | 65 // Set up the finch experiment to control the model number |
| 66 // used in the model URL. This clears all existing state. | 66 // used in the model URL. This clears all existing state. |
| 67 void SetFinchModelNumber(int model_number) { | 67 void SetFinchModelNumber(int model_number) { |
| 68 // Destroy the existing FieldTrialList before creating a new one to avoid | 68 // Destroy the existing FieldTrialList before creating a new one to avoid |
| 69 // a DCHECK. | 69 // a DCHECK. |
| 70 field_trials_.reset(); | 70 field_trials_.reset(); |
| 71 field_trials_.reset(new base::FieldTrialList(NULL)); | 71 field_trials_.reset(new base::FieldTrialList(nullptr)); |
| 72 variations::testing::ClearAllVariationIDs(); | 72 variations::testing::ClearAllVariationIDs(); |
| 73 variations::testing::ClearAllVariationParams(); | 73 variations::testing::ClearAllVariationParams(); |
| 74 | 74 |
| 75 const std::string group_name = "ModelFoo"; // Not used in CSD code. | 75 const std::string group_name = "ModelFoo"; // Not used in CSD code. |
| 76 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 76 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 77 ModelLoader::kClientModelFinchExperiment, group_name)); | 77 ModelLoader::kClientModelFinchExperiment, group_name)); |
| 78 | 78 |
| 79 std::map<std::string, std::string> params; | 79 std::map<std::string, std::string> params; |
| 80 params[ModelLoader::kClientModelFinchParam] = | 80 params[ModelLoader::kClientModelFinchParam] = |
| 81 base::IntToString(model_number); | 81 base::IntToString(model_number); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 EXPECT_FALSE(ModelLoader::ModelHasValidHashIds(model)); | 337 EXPECT_FALSE(ModelLoader::ModelHasValidHashIds(model)); |
| 338 | 338 |
| 339 rule->set_feature(2, 2); | 339 rule->set_feature(2, 2); |
| 340 EXPECT_FALSE(ModelLoader::ModelHasValidHashIds(model)); | 340 EXPECT_FALSE(ModelLoader::ModelHasValidHashIds(model)); |
| 341 | 341 |
| 342 rule->set_feature(2, 1); | 342 rule->set_feature(2, 1); |
| 343 EXPECT_TRUE(ModelLoader::ModelHasValidHashIds(model)); | 343 EXPECT_TRUE(ModelLoader::ModelHasValidHashIds(model)); |
| 344 } | 344 } |
| 345 | 345 |
| 346 } // namespace safe_browsing | 346 } // namespace safe_browsing |
| OLD | NEW |