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