OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_associated_data.h" | 5 #include "components/variations/variations_associated_data.h" |
6 | 6 |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace variations { | 10 namespace variations { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 ASSERT_FALSE(IsFieldTrialActive(kTrialName)); | 349 ASSERT_FALSE(IsFieldTrialActive(kTrialName)); |
350 scoped_refptr<base::FieldTrial> trial( | 350 scoped_refptr<base::FieldTrial> trial( |
351 CreateFieldTrial(kTrialName, 100, "A", NULL)); | 351 CreateFieldTrial(kTrialName, 100, "A", NULL)); |
352 ASSERT_FALSE(IsFieldTrialActive(kTrialName)); | 352 ASSERT_FALSE(IsFieldTrialActive(kTrialName)); |
353 | 353 |
354 std::map<std::string, std::string> params; | 354 std::map<std::string, std::string> params; |
355 EXPECT_EQ(std::string(), GetVariationParamValue(kTrialName, "x")); | 355 EXPECT_EQ(std::string(), GetVariationParamValue(kTrialName, "x")); |
356 ASSERT_TRUE(IsFieldTrialActive(kTrialName)); | 356 ASSERT_TRUE(IsFieldTrialActive(kTrialName)); |
357 } | 357 } |
358 | 358 |
| 359 TEST_F(VariationsAssociatedDataTest, AssociateParamsFromString) { |
| 360 const std::string kTrialName = "AssociateVariationParams"; |
| 361 const std::string kVariationsString = |
| 362 "AssociateVariationParams.A:a/10/b/test,AssociateVariationParams.B:a/%2F"; |
| 363 ASSERT_TRUE(AssociateParamsFromString(kVariationsString)); |
| 364 |
| 365 base::FieldTrialList::CreateFieldTrial(kTrialName, "B"); |
| 366 EXPECT_EQ("/", GetVariationParamValue(kTrialName, "a")); |
| 367 EXPECT_EQ(std::string(), GetVariationParamValue(kTrialName, "b")); |
| 368 EXPECT_EQ(std::string(), GetVariationParamValue(kTrialName, "x")); |
| 369 |
| 370 std::map<std::string, std::string> params; |
| 371 EXPECT_TRUE(GetVariationParams(kTrialName, ¶ms)); |
| 372 EXPECT_EQ(1U, params.size()); |
| 373 EXPECT_EQ("/", params["a"]); |
| 374 } |
| 375 |
359 } // namespace variations | 376 } // namespace variations |
OLD | NEW |