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

Side by Side Diff: trunk/src/components/variations/variations_seed_simulator_unittest.cc

Issue 416333008: Revert 285657 "Move variations component code to variations name..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/components/variations/variations_seed_simulator.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 chrome_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 virtual ~TestEntropyProvider() {}
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 // Simulates the differences between |study| and the current field trial 104 // Simulates the differences between |study| and the current field trial
105 // state, returning a string like "1 2 3", where 1 is the number of regular 105 // state, returning a string like "1 2 3", where 1 is the number of regular
106 // group changes, 2 is the number of "kill best effort" group changes and 3 106 // group changes, 2 is the number of "kill best effort" group changes and 3
107 // is the number of "kill critical" group changes. 107 // is the number of "kill critical" group changes.
108 std::string SimulateStudyDifferences(const Study* study) { 108 std::string SimulateStudyDifferences(const Study* study) {
109 std::vector<ProcessedStudy> studies; 109 std::vector<ProcessedStudy> studies;
110 if (!ProcessedStudy::ValidateAndAppendStudy(study, false, &studies)) 110 if (!ProcessedStudy::ValidateAndAppendStudy(study, false, &studies))
111 return "invalid study"; 111 return "invalid study";
112 return ConvertSimulationResultToString(SimulateDifferences(studies)); 112 return ConvertSimulationResultToString(SimulateDifferences(studies));
113
113 } 114 }
114 115
115 // Simulates the differences between expired |study| and the current field 116 // Simulates the differences between expired |study| and the current field
116 // trial state, returning a string like "1 2 3", where 1 is the number of 117 // trial state, returning a string like "1 2 3", where 1 is the number of
117 // regular group changes, 2 is the number of "kill best effort" group changes 118 // regular group changes, 2 is the number of "kill best effort" group changes
118 // and 3 is the number of "kill critical" group changes. 119 // and 3 is the number of "kill critical" group changes.
119 std::string SimulateStudyDifferencesExpired(const Study* study) { 120 std::string SimulateStudyDifferencesExpired(const Study* study) {
120 std::vector<ProcessedStudy> studies; 121 std::vector<ProcessedStudy> studies;
121 if (!ProcessedStudy::ValidateAndAppendStudy(study, true, &studies)) 122 if (!ProcessedStudy::ValidateAndAppendStudy(study, true, &studies))
122 return "invalid study"; 123 return "invalid study";
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 experiment->set_type(Study_Experiment_Type_NORMAL); 372 experiment->set_type(Study_Experiment_Type_NORMAL);
372 EXPECT_EQ("1 0 0", SimulateStudyDifferences(&study)); 373 EXPECT_EQ("1 0 0", SimulateStudyDifferences(&study));
373 experiment->set_type(Study_Experiment_Type_IGNORE_CHANGE); 374 experiment->set_type(Study_Experiment_Type_IGNORE_CHANGE);
374 EXPECT_EQ("0 0 0", SimulateStudyDifferences(&study)); 375 EXPECT_EQ("0 0 0", SimulateStudyDifferences(&study));
375 experiment->set_type(Study_Experiment_Type_KILL_BEST_EFFORT); 376 experiment->set_type(Study_Experiment_Type_KILL_BEST_EFFORT);
376 EXPECT_EQ("0 1 0", SimulateStudyDifferences(&study)); 377 EXPECT_EQ("0 1 0", SimulateStudyDifferences(&study));
377 experiment->set_type(Study_Experiment_Type_KILL_CRITICAL); 378 experiment->set_type(Study_Experiment_Type_KILL_CRITICAL);
378 EXPECT_EQ("0 0 1", SimulateStudyDifferences(&study)); 379 EXPECT_EQ("0 0 1", SimulateStudyDifferences(&study));
379 } 380 }
380 381
381 } // namespace variations 382 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « trunk/src/components/variations/variations_seed_simulator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698