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/study_filtering.h" | 5 #include "components/variations/study_filtering.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 #include <string.h> |
| 10 |
7 #include <vector> | 11 #include <vector> |
8 | 12 |
| 13 #include "base/macros.h" |
9 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
10 #include "components/variations/processed_study.h" | 15 #include "components/variations/processed_study.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
12 | 17 |
13 namespace variations { | 18 namespace variations { |
14 | 19 |
15 namespace { | 20 namespace { |
16 | 21 |
17 // Converts |time| to Study proto format. | 22 // Converts |time| to Study proto format. |
18 int64 TimeToProtoTime(const base::Time& time) { | 23 int64_t TimeToProtoTime(const base::Time& time) { |
19 return (time - base::Time::UnixEpoch()).InSeconds(); | 24 return (time - base::Time::UnixEpoch()).InSeconds(); |
20 } | 25 } |
21 | 26 |
22 // Adds an experiment to |study| with the specified |name| and |probability|. | 27 // Adds an experiment to |study| with the specified |name| and |probability|. |
23 Study_Experiment* AddExperiment(const std::string& name, int probability, | 28 Study_Experiment* AddExperiment(const std::string& name, int probability, |
24 Study* study) { | 29 Study* study) { |
25 Study_Experiment* experiment = study->add_experiment(); | 30 Study_Experiment* experiment = study->add_experiment(); |
26 experiment->set_name(name); | 31 experiment->set_name(name); |
27 experiment->set_probability_weight(probability); | 32 experiment->set_probability_weight(probability); |
28 return experiment; | 33 return experiment; |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 | 573 |
569 default_group->set_name("def"); | 574 default_group->set_name("def"); |
570 EXPECT_TRUE(processed_study.Init(&study, false)); | 575 EXPECT_TRUE(processed_study.Init(&study, false)); |
571 Study_Experiment* repeated_group = study.add_experiment(); | 576 Study_Experiment* repeated_group = study.add_experiment(); |
572 repeated_group->set_name("abc"); | 577 repeated_group->set_name("abc"); |
573 repeated_group->set_probability_weight(1); | 578 repeated_group->set_probability_weight(1); |
574 EXPECT_FALSE(processed_study.Init(&study, false)); | 579 EXPECT_FALSE(processed_study.Init(&study, false)); |
575 } | 580 } |
576 | 581 |
577 } // namespace variations | 582 } // namespace variations |
OLD | NEW |