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

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

Issue 412943002: Move variations component code to variations namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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 chrome_variations { 10 namespace variations {
11 11
12 namespace { 12 namespace {
13 13
14 const VariationID TEST_VALUE_A = 3300200; 14 const VariationID TEST_VALUE_A = 3300200;
15 const VariationID TEST_VALUE_B = 3300201; 15 const VariationID TEST_VALUE_B = 3300201;
16 16
17 // Convenience helper to retrieve the chrome_variations::VariationID for a 17 // Convenience helper to retrieve the variations::VariationID for a FieldTrial.
18 // FieldTrial. Note that this will do the group assignment in |trial| if not 18 // Note that this will do the group assignment in |trial| if not already done.
19 // already done.
20 VariationID GetIDForTrial(IDCollectionKey key, base::FieldTrial* trial) { 19 VariationID GetIDForTrial(IDCollectionKey key, base::FieldTrial* trial) {
21 return GetGoogleVariationID(key, trial->trial_name(), trial->group_name()); 20 return GetGoogleVariationID(key, trial->trial_name(), trial->group_name());
22 } 21 }
23 22
24 // Tests whether a field trial is active (i.e. group() has been called on it). 23 // Tests whether a field trial is active (i.e. group() has been called on it).
25 bool IsFieldTrialActive(const std::string& trial_name) { 24 bool IsFieldTrialActive(const std::string& trial_name) {
26 base::FieldTrial::ActiveGroups active_groups; 25 base::FieldTrial::ActiveGroups active_groups;
27 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups); 26 base::FieldTrialList::GetActiveFieldTrialGroups(&active_groups);
28 for (size_t i = 0; i < active_groups.size(); ++i) { 27 for (size_t i = 0; i < active_groups.size(); ++i) {
29 if (active_groups[i].trial_name == trial_name) 28 if (active_groups[i].trial_name == trial_name)
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 ASSERT_FALSE(IsFieldTrialActive(kTrialName)); 321 ASSERT_FALSE(IsFieldTrialActive(kTrialName));
323 scoped_refptr<base::FieldTrial> trial( 322 scoped_refptr<base::FieldTrial> trial(
324 CreateFieldTrial(kTrialName, 100, "A", NULL)); 323 CreateFieldTrial(kTrialName, 100, "A", NULL));
325 ASSERT_FALSE(IsFieldTrialActive(kTrialName)); 324 ASSERT_FALSE(IsFieldTrialActive(kTrialName));
326 325
327 std::map<std::string, std::string> params; 326 std::map<std::string, std::string> params;
328 EXPECT_EQ(std::string(), GetVariationParamValue(kTrialName, "x")); 327 EXPECT_EQ(std::string(), GetVariationParamValue(kTrialName, "x"));
329 ASSERT_TRUE(IsFieldTrialActive(kTrialName)); 328 ASSERT_TRUE(IsFieldTrialActive(kTrialName));
330 } 329 }
331 330
332 } // namespace chrome_variations 331 } // namespace variations
OLDNEW
« no previous file with comments | « components/variations/variations_associated_data.cc ('k') | components/variations/variations_http_header_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698