| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/variations/variations_seed_simulator.h" | 5 #include "components/variations/variations_seed_simulator.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "components/variations/processed_study.h" | 10 #include "components/variations/processed_study.h" |
| 11 #include "components/variations/proto/study.pb.h" | 11 #include "components/variations/proto/study.pb.h" |
| 12 #include "components/variations/variations_associated_data.h" | 12 #include "components/variations/variations_associated_data.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace variations { | 15 namespace variations { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // An implementation of EntropyProvider that always returns a specific entropy | 19 // An implementation of EntropyProvider that always returns a specific entropy |
| 20 // value, regardless of field trial. | 20 // value, regardless of field trial. |
| 21 class TestEntropyProvider : public base::FieldTrial::EntropyProvider { | 21 class TestEntropyProvider : public base::FieldTrial::EntropyProvider { |
| 22 public: | 22 public: |
| 23 explicit TestEntropyProvider(double entropy_value) | 23 explicit TestEntropyProvider(double entropy_value) |
| 24 : entropy_value_(entropy_value) {} | 24 : entropy_value_(entropy_value) {} |
| 25 virtual ~TestEntropyProvider() {} | 25 ~TestEntropyProvider() override {} |
| 26 | 26 |
| 27 // base::FieldTrial::EntropyProvider implementation: | 27 // base::FieldTrial::EntropyProvider implementation: |
| 28 virtual double GetEntropyForTrial(const std::string& trial_name, | 28 double GetEntropyForTrial(const std::string& trial_name, |
| 29 uint32 randomization_seed) const override { | 29 uint32 randomization_seed) const override { |
| 30 return entropy_value_; | 30 return entropy_value_; |
| 31 } | 31 } |
| 32 | 32 |
| 33 private: | 33 private: |
| 34 const double entropy_value_; | 34 const double entropy_value_; |
| 35 | 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(TestEntropyProvider); | 36 DISALLOW_COPY_AND_ASSIGN(TestEntropyProvider); |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // Creates and activates a single-group field trial with name |trial_name| and | 39 // Creates and activates a single-group field trial with name |trial_name| and |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 EXPECT_EQ("1 0 0", SimulateStudyDifferences(&study)); | 372 EXPECT_EQ("1 0 0", SimulateStudyDifferences(&study)); |
| 373 experiment->set_type(Study_Experiment_Type_IGNORE_CHANGE); | 373 experiment->set_type(Study_Experiment_Type_IGNORE_CHANGE); |
| 374 EXPECT_EQ("0 0 0", SimulateStudyDifferences(&study)); | 374 EXPECT_EQ("0 0 0", SimulateStudyDifferences(&study)); |
| 375 experiment->set_type(Study_Experiment_Type_KILL_BEST_EFFORT); | 375 experiment->set_type(Study_Experiment_Type_KILL_BEST_EFFORT); |
| 376 EXPECT_EQ("0 1 0", SimulateStudyDifferences(&study)); | 376 EXPECT_EQ("0 1 0", SimulateStudyDifferences(&study)); |
| 377 experiment->set_type(Study_Experiment_Type_KILL_CRITICAL); | 377 experiment->set_type(Study_Experiment_Type_KILL_CRITICAL); |
| 378 EXPECT_EQ("0 0 1", SimulateStudyDifferences(&study)); | 378 EXPECT_EQ("0 0 1", SimulateStudyDifferences(&study)); |
| 379 } | 379 } |
| 380 | 380 |
| 381 } // namespace variations | 381 } // namespace variations |
| OLD | NEW |