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

Side by Side Diff: chrome/common/variations/variations_util_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
« no previous file with comments | « chrome/common/variations/variations_util.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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/common/variations/variations_util.h"
6
7 #include "base/metrics/field_trial.h"
8 #include "components/variations/variations_associated_data.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace chrome_variations {
12
13 class VariationsUtilTest : public ::testing::Test {
14 public:
15 VariationsUtilTest() : field_trial_list_(NULL) {}
16
17 ~VariationsUtilTest() override {
18 // Ensure that the maps are cleared between tests, since they are stored as
19 // process singletons.
20 variations::testing::ClearAllVariationIDs();
21 variations::testing::ClearAllVariationParams();
22 }
23
24 private:
25 base::FieldTrialList field_trial_list_;
26
27 DISALLOW_COPY_AND_ASSIGN(VariationsUtilTest);
28 };
29
30 TEST_F(VariationsUtilTest, AssociateParamsFromString) {
31 const std::string kTrialName = "AssociateVariationParams";
32 const std::string kVariationsString =
33 "AssociateVariationParams.A:a/10/b/test,AssociateVariationParams.B:a/%2F";
34 ASSERT_TRUE(AssociateParamsFromString(kVariationsString));
35
36 base::FieldTrialList::CreateFieldTrial(kTrialName, "B");
37 EXPECT_EQ("/", variations::GetVariationParamValue(kTrialName, "a"));
38 EXPECT_EQ(std::string(), variations::GetVariationParamValue(kTrialName, "b"));
39 EXPECT_EQ(std::string(), variations::GetVariationParamValue(kTrialName, "x"));
40
41 std::map<std::string, std::string> params;
42 EXPECT_TRUE(variations::GetVariationParams(kTrialName, &params));
43 EXPECT_EQ(1U, params.size());
44 EXPECT_EQ("/", params["a"]);
45 }
46
47 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « chrome/common/variations/variations_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698