OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/common/variations/variations_util.h" | 5 #include "chrome/common/variations/variations_util.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 EXPECT_EQ("/", variations::GetVariationParamValue(kTrialName, "a")); | 42 EXPECT_EQ("/", variations::GetVariationParamValue(kTrialName, "a")); |
43 EXPECT_EQ(std::string(), variations::GetVariationParamValue(kTrialName, "b")); | 43 EXPECT_EQ(std::string(), variations::GetVariationParamValue(kTrialName, "b")); |
44 EXPECT_EQ(std::string(), variations::GetVariationParamValue(kTrialName, "x")); | 44 EXPECT_EQ(std::string(), variations::GetVariationParamValue(kTrialName, "x")); |
45 | 45 |
46 std::map<std::string, std::string> params; | 46 std::map<std::string, std::string> params; |
47 EXPECT_TRUE(variations::GetVariationParams(kTrialName, ¶ms)); | 47 EXPECT_TRUE(variations::GetVariationParams(kTrialName, ¶ms)); |
48 EXPECT_EQ(1U, params.size()); | 48 EXPECT_EQ(1U, params.size()); |
49 EXPECT_EQ("/", params["a"]); | 49 EXPECT_EQ("/", params["a"]); |
50 } | 50 } |
51 | 51 |
| 52 TEST_F(VariationsUtilTest, AssociateParamsFromStringWithSameStudy) { |
| 53 const std::string kTrialName = "AssociateVariationParams"; |
| 54 const std::string kVariationsString = |
| 55 "AssociateVariationParams.A:a/10/b/test,AssociateVariationParams.A:a/x"; |
| 56 ASSERT_FALSE(AssociateParamsFromString(kVariationsString)); |
| 57 } |
| 58 |
52 TEST_F(VariationsUtilTest, AssociateParamsFromFieldTrialConfig) { | 59 TEST_F(VariationsUtilTest, AssociateParamsFromFieldTrialConfig) { |
53 const FieldTrialGroupParams array_kFieldTrialConfig_params[] = {{"x", "1"}, | 60 const FieldTrialGroupParams array_kFieldTrialConfig_params[] = {{"x", "1"}, |
54 {"y", "2"}}; | 61 {"y", "2"}}; |
55 | 62 |
56 const FieldTrialTestingGroup array_kFieldTrialConfig_groups[] = { | 63 const FieldTrialTestingGroup array_kFieldTrialConfig_groups[] = { |
57 {"TestStudy1", "TestGroup1", array_kFieldTrialConfig_params, 2, NULL, 0, | 64 {"TestStudy1", "TestGroup1", array_kFieldTrialConfig_params, 2, NULL, 0, |
58 NULL, 0}, | 65 NULL, 0}, |
59 {"TestStudy2", "TestGroup2", NULL, 0, NULL, 0, NULL, 0}}; | 66 {"TestStudy2", "TestGroup2", NULL, 0, NULL, 0, NULL, 0}}; |
60 | 67 |
61 const FieldTrialTestingConfig kConfig = { | 68 const FieldTrialTestingConfig kConfig = { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 EXPECT_TRUE(base::FeatureList::IsEnabled(kFeatureB)); | 114 EXPECT_TRUE(base::FeatureList::IsEnabled(kFeatureB)); |
108 EXPECT_TRUE(base::FieldTrialList::IsTrialActive("TestStudy1")); | 115 EXPECT_TRUE(base::FieldTrialList::IsTrialActive("TestStudy1")); |
109 | 116 |
110 EXPECT_FALSE(base::FieldTrialList::IsTrialActive("TestStudy2")); | 117 EXPECT_FALSE(base::FieldTrialList::IsTrialActive("TestStudy2")); |
111 EXPECT_FALSE(base::FeatureList::IsEnabled(kFeatureC)); | 118 EXPECT_FALSE(base::FeatureList::IsEnabled(kFeatureC)); |
112 EXPECT_FALSE(base::FeatureList::IsEnabled(kFeatureD)); | 119 EXPECT_FALSE(base::FeatureList::IsEnabled(kFeatureD)); |
113 EXPECT_TRUE(base::FieldTrialList::IsTrialActive("TestStudy2")); | 120 EXPECT_TRUE(base::FieldTrialList::IsTrialActive("TestStudy2")); |
114 } | 121 } |
115 | 122 |
116 } // namespace chrome_variations | 123 } // namespace chrome_variations |
OLD | NEW |