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

Side by Side Diff: chrome/common/metrics/variations/experiment_labels_unittest.cc

Issue 93793010: Update uses of UTF conversions in chrome/common to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 "chrome/common/metrics/variations/experiment_labels.h" 5 #include "chrome/common/metrics/variations/experiment_labels.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 base::FieldTrial::ActiveGroup group; 64 base::FieldTrial::ActiveGroup group;
65 group.trial_name = group_data[j]; 65 group.trial_name = group_data[j];
66 group.group_name = group_data[j + 1]; 66 group.group_name = group_data[j + 1];
67 groups.push_back(group); 67 groups.push_back(group);
68 } 68 }
69 69
70 // Parse the expected output. 70 // Parse the expected output.
71 std::vector<std::string> expected_ids_list; 71 std::vector<std::string> expected_ids_list;
72 base::SplitString(test_cases[i].expected_ids, '#', &expected_ids_list); 72 base::SplitString(test_cases[i].expected_ids, '#', &expected_ids_list);
73 73
74 std::string experiment_labels_string = UTF16ToUTF8( 74 std::string experiment_labels_string = base::UTF16ToUTF8(
75 BuildGoogleUpdateExperimentLabel(groups)); 75 BuildGoogleUpdateExperimentLabel(groups));
76 76
77 // Split the VariationIDs from the labels for verification below. 77 // Split the VariationIDs from the labels for verification below.
78 std::vector<std::string> split_labels; 78 std::vector<std::string> split_labels;
79 std::set<std::string> parsed_ids; 79 std::set<std::string> parsed_ids;
80 base::SplitString(experiment_labels_string, ';', &split_labels); 80 base::SplitString(experiment_labels_string, ';', &split_labels);
81 for (std::vector<std::string>::const_iterator it = split_labels.begin(); 81 for (std::vector<std::string>::const_iterator it = split_labels.begin();
82 it != split_labels.end(); ++it) { 82 it != split_labels.end(); ++it) {
83 // The ID is precisely between the '=' and '|' characters in each label. 83 // The ID is precisely between the '=' and '|' characters in each label.
84 size_t index_of_equals = it->find('='); 84 size_t index_of_equals = it->find('=');
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 {"A=B|Tue, 21 Jan 2014 15:30:21 GMT;C=D|Tue, 21 Jan 2014 15:30:21 GMT", 120 {"A=B|Tue, 21 Jan 2014 15:30:21 GMT;C=D|Tue, 21 Jan 2014 15:30:21 GMT",
121 "P=Q|Tue, 21 Jan 2014 15:30:21 GMT;X=Y|Tue, 21 Jan 2014 15:30:21 GMT", 121 "P=Q|Tue, 21 Jan 2014 15:30:21 GMT;X=Y|Tue, 21 Jan 2014 15:30:21 GMT",
122 "P=Q|Tue, 21 Jan 2014 15:30:21 GMT;X=Y|Tue, 21 Jan 2014 15:30:21 GMT;" 122 "P=Q|Tue, 21 Jan 2014 15:30:21 GMT;X=Y|Tue, 21 Jan 2014 15:30:21 GMT;"
123 "A=B|Tue, 21 Jan 2014 15:30:21 GMT;C=D|Tue, 21 Jan 2014 15:30:21 GMT"}, 123 "A=B|Tue, 21 Jan 2014 15:30:21 GMT;C=D|Tue, 21 Jan 2014 15:30:21 GMT"},
124 {"", 124 {"",
125 "", 125 "",
126 ""}, 126 ""},
127 }; 127 };
128 128
129 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 129 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
130 std::string result = UTF16ToUTF8(CombineExperimentLabels( 130 std::string result = base::UTF16ToUTF8(CombineExperimentLabels(
131 ASCIIToUTF16(test_cases[i].variations_labels), 131 base::ASCIIToUTF16(test_cases[i].variations_labels),
132 ASCIIToUTF16(test_cases[i].other_labels))); 132 base::ASCIIToUTF16(test_cases[i].other_labels)));
133 EXPECT_EQ(test_cases[i].expected_label, result); 133 EXPECT_EQ(test_cases[i].expected_label, result);
134 } 134 }
135 } 135 }
136 136
137 TEST(ExperimentLabelsTest, ExtractNonVariationLabels) { 137 TEST(ExperimentLabelsTest, ExtractNonVariationLabels) {
138 struct { 138 struct {
139 const char* input_label; 139 const char* input_label;
140 const char* expected_output; 140 const char* expected_output;
141 } test_cases[] = { 141 } test_cases[] = {
142 // Empty 142 // Empty
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 "gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT"}, 176 "gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT"},
177 // Trailing semicolon 177 // Trailing semicolon
178 {"gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT;" 178 {"gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT;"
179 "CrVar1=3310002|Tue, 21 Jan 2014 15:30:21 GMT;", // Note the semi here. 179 "CrVar1=3310002|Tue, 21 Jan 2014 15:30:21 GMT;", // Note the semi here.
180 "gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT"}, 180 "gcapi_brand=123|Tue, 21 Jan 2014 15:30:21 GMT"},
181 // Semis 181 // Semis
182 {";;;;", ""}, 182 {";;;;", ""},
183 }; 183 };
184 184
185 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { 185 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
186 std::string non_variation_labels = UTF16ToUTF8( 186 std::string non_variation_labels = base::UTF16ToUTF8(
187 ExtractNonVariationLabels(ASCIIToUTF16(test_cases[i].input_label))); 187 ExtractNonVariationLabels(
188 base::ASCIIToUTF16(test_cases[i].input_label)));
188 EXPECT_EQ(test_cases[i].expected_output, non_variation_labels); 189 EXPECT_EQ(test_cases[i].expected_output, non_variation_labels);
189 } 190 }
190 } 191 }
191 192
192 } // namespace chrome_variations 193 } // namespace chrome_variations
OLDNEW
« no previous file with comments | « chrome/common/metrics/variations/experiment_labels.cc ('k') | chrome/common/multi_process_lock_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698