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

Side by Side Diff: components/variations/variations_associated_data_unittest.cc

Issue 1090813005: Add a mechanism to force parameters of a group to a specific value. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
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
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, &params));
372 EXPECT_EQ(1U, params.size());
373 EXPECT_EQ("/", params["a"]);
374 }
375
359 } // namespace variations 376 } // namespace variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698