OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 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 "components/variations/active_field_trials.h" | |
6 | |
7 #include "components/variations/metrics_util.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 | |
10 namespace chrome_variations { | |
11 | |
12 TEST(VariationsUtilTest, GetFieldTrialActiveGroups) { | |
13 typedef std::set<ActiveGroupId, ActiveGroupIdCompare> ActiveGroupIdSet; | |
14 std::string trial_one("trial one"); | |
15 std::string group_one("group one"); | |
16 std::string trial_two("trial two"); | |
17 std::string group_two("group two"); | |
18 | |
19 base::FieldTrial::ActiveGroups active_groups; | |
20 base::FieldTrial::ActiveGroup active_group; | |
21 active_group.trial_name = trial_one; | |
22 active_group.group_name = group_one; | |
23 active_groups.push_back(active_group); | |
24 | |
25 active_group.trial_name = trial_two; | |
26 active_group.group_name = group_two; | |
27 active_groups.push_back(active_group); | |
28 | |
29 // Create our expected groups of IDs. | |
30 ActiveGroupIdSet expected_groups; | |
31 ActiveGroupId name_group_id; | |
32 name_group_id.name = metrics::HashName(trial_one); | |
33 name_group_id.group = metrics::HashName(group_one); | |
34 expected_groups.insert(name_group_id); | |
35 name_group_id.name = metrics::HashName(trial_two); | |
36 name_group_id.group = metrics::HashName(group_two); | |
37 expected_groups.insert(name_group_id); | |
38 | |
39 std::vector<ActiveGroupId> active_group_ids; | |
40 testing::TestGetFieldTrialActiveGroupIds(active_groups, &active_group_ids); | |
41 EXPECT_EQ(2U, active_group_ids.size()); | |
42 for (size_t i = 0; i < active_group_ids.size(); ++i) { | |
43 ActiveGroupIdSet::iterator expected_group = | |
44 expected_groups.find(active_group_ids[i]); | |
45 EXPECT_FALSE(expected_group == expected_groups.end()); | |
46 expected_groups.erase(expected_group); | |
47 } | |
48 EXPECT_EQ(0U, expected_groups.size()); | |
49 } | |
Ilya Sherman
2014/05/19 12:29:42
It's too bad that this looks like a new file rathe
| |
50 | |
51 } // namespace chrome_variations | |
Ilya Sherman
2014/05/19 12:29:42
nit: Please update the namespace.
Alexei Svitkine (slow)
2014/05/19 12:50:47
Done.
| |
OLD | NEW |