OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/about_flags.h" | 5 #include "chrome/browser/about_flags.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 #if defined(OS_WIN) | 182 #if defined(OS_WIN) |
183 return base::UTF16ToUTF8(path); | 183 return base::UTF16ToUTF8(path); |
184 #else | 184 #else |
185 return path; | 185 return path; |
186 #endif | 186 #endif |
187 } | 187 } |
188 | 188 |
189 std::set<std::string> GetAllSwitchesForTesting() { | 189 std::set<std::string> GetAllSwitchesForTesting() { |
190 std::set<std::string> result; | 190 std::set<std::string> result; |
191 | 191 |
192 size_t num_experiments = 0; | 192 size_t num_entries = 0; |
193 const Experiment* experiments = | 193 const FeatureEntry* entries = |
194 testing::GetExperiments(&num_experiments); | 194 testing::GetFeatureEntries(&num_entries); |
195 | 195 |
196 for (size_t i = 0; i < num_experiments; ++i) { | 196 for (size_t i = 0; i < num_entries; ++i) { |
197 const Experiment& experiment = experiments[i]; | 197 const FeatureEntry& entry = entries[i]; |
198 if (experiment.type == Experiment::SINGLE_VALUE || | 198 if (entry.type == FeatureEntry::SINGLE_VALUE || |
199 experiment.type == Experiment::SINGLE_DISABLE_VALUE) { | 199 entry.type == FeatureEntry::SINGLE_DISABLE_VALUE) { |
200 result.insert(experiment.command_line_switch); | 200 result.insert(entry.command_line_switch); |
201 } else if (experiment.type == Experiment::MULTI_VALUE) { | 201 } else if (entry.type == FeatureEntry::MULTI_VALUE) { |
202 for (int j = 0; j < experiment.num_choices; ++j) { | 202 for (int j = 0; j < entry.num_choices; ++j) { |
203 result.insert(experiment.choices[j].command_line_switch); | 203 result.insert(entry.choices[j].command_line_switch); |
204 } | 204 } |
205 } else { | 205 } else { |
206 DCHECK_EQ(experiment.type, Experiment::ENABLE_DISABLE_VALUE); | 206 DCHECK_EQ(entry.type, FeatureEntry::ENABLE_DISABLE_VALUE); |
207 result.insert(experiment.command_line_switch); | 207 result.insert(entry.command_line_switch); |
208 result.insert(experiment.disable_command_line_switch); | 208 result.insert(entry.disable_command_line_switch); |
209 } | 209 } |
210 } | 210 } |
211 return result; | 211 return result; |
212 } | 212 } |
213 | 213 |
214 } // anonymous namespace | 214 } // anonymous namespace |
215 | 215 |
216 const Experiment::Choice kMultiChoices[] = { | 216 const FeatureEntry::Choice kMultiChoices[] = { |
217 { IDS_PRODUCT_NAME, "", "" }, | 217 { IDS_PRODUCT_NAME, "", "" }, |
218 { IDS_PRODUCT_NAME, kMultiSwitch1, "" }, | 218 { IDS_PRODUCT_NAME, kMultiSwitch1, "" }, |
219 { IDS_PRODUCT_NAME, kMultiSwitch2, kValueForMultiSwitch2 }, | 219 { IDS_PRODUCT_NAME, kMultiSwitch2, kValueForMultiSwitch2 }, |
220 }; | 220 }; |
221 | 221 |
222 // The experiments that are set for these tests. The 3rd experiment is not | 222 // The entries that are set for these tests. The 3rd entry is not supported on |
223 // supported on the current platform, all others are. | 223 // the current platform, all others are. |
224 static Experiment kExperiments[] = { | 224 static FeatureEntry kEntries[] = { |
225 { | 225 { |
226 kFlags1, | 226 kFlags1, |
227 IDS_PRODUCT_NAME, | 227 IDS_PRODUCT_NAME, |
228 IDS_PRODUCT_NAME, | 228 IDS_PRODUCT_NAME, |
229 0, // Ends up being mapped to the current platform. | 229 0, // Ends up being mapped to the current platform. |
230 Experiment::SINGLE_VALUE, | 230 FeatureEntry::SINGLE_VALUE, |
231 kSwitch1, | 231 kSwitch1, |
232 "", | 232 "", |
233 NULL, | 233 NULL, |
234 NULL, | 234 NULL, |
235 NULL, | 235 NULL, |
236 0 | 236 0 |
237 }, | 237 }, |
238 { | 238 { |
239 kFlags2, | 239 kFlags2, |
240 IDS_PRODUCT_NAME, | 240 IDS_PRODUCT_NAME, |
241 IDS_PRODUCT_NAME, | 241 IDS_PRODUCT_NAME, |
242 0, // Ends up being mapped to the current platform. | 242 0, // Ends up being mapped to the current platform. |
243 Experiment::SINGLE_VALUE, | 243 FeatureEntry::SINGLE_VALUE, |
244 kSwitch2, | 244 kSwitch2, |
245 kValueForSwitch2, | 245 kValueForSwitch2, |
246 NULL, | 246 NULL, |
247 NULL, | 247 NULL, |
248 NULL, | 248 NULL, |
249 0 | 249 0 |
250 }, | 250 }, |
251 { | 251 { |
252 kFlags3, | 252 kFlags3, |
253 IDS_PRODUCT_NAME, | 253 IDS_PRODUCT_NAME, |
254 IDS_PRODUCT_NAME, | 254 IDS_PRODUCT_NAME, |
255 0, // This ends up enabling for an OS other than the current. | 255 0, // This ends up enabling for an OS other than the current. |
256 Experiment::SINGLE_VALUE, | 256 FeatureEntry::SINGLE_VALUE, |
257 kSwitch3, | 257 kSwitch3, |
258 "", | 258 "", |
259 NULL, | 259 NULL, |
260 NULL, | 260 NULL, |
261 NULL, | 261 NULL, |
262 0 | 262 0 |
263 }, | 263 }, |
264 { | 264 { |
265 kFlags4, | 265 kFlags4, |
266 IDS_PRODUCT_NAME, | 266 IDS_PRODUCT_NAME, |
267 IDS_PRODUCT_NAME, | 267 IDS_PRODUCT_NAME, |
268 0, // Ends up being mapped to the current platform. | 268 0, // Ends up being mapped to the current platform. |
269 Experiment::MULTI_VALUE, | 269 FeatureEntry::MULTI_VALUE, |
270 "", | 270 "", |
271 "", | 271 "", |
272 "", | 272 "", |
273 "", | 273 "", |
274 kMultiChoices, | 274 kMultiChoices, |
275 arraysize(kMultiChoices) | 275 arraysize(kMultiChoices) |
276 }, | 276 }, |
277 { | 277 { |
278 kFlags5, | 278 kFlags5, |
279 IDS_PRODUCT_NAME, | 279 IDS_PRODUCT_NAME, |
280 IDS_PRODUCT_NAME, | 280 IDS_PRODUCT_NAME, |
281 0, // Ends up being mapped to the current platform. | 281 0, // Ends up being mapped to the current platform. |
282 Experiment::ENABLE_DISABLE_VALUE, | 282 FeatureEntry::ENABLE_DISABLE_VALUE, |
283 kSwitch1, | 283 kSwitch1, |
284 kEnableDisableValue1, | 284 kEnableDisableValue1, |
285 kSwitch2, | 285 kSwitch2, |
286 kEnableDisableValue2, | 286 kEnableDisableValue2, |
287 NULL, | 287 NULL, |
288 3 | 288 3 |
289 }, | 289 }, |
290 { | 290 { |
291 kFlags6, | 291 kFlags6, |
292 IDS_PRODUCT_NAME, | 292 IDS_PRODUCT_NAME, |
293 IDS_PRODUCT_NAME, | 293 IDS_PRODUCT_NAME, |
294 0, | 294 0, |
295 Experiment::SINGLE_DISABLE_VALUE, | 295 FeatureEntry::SINGLE_DISABLE_VALUE, |
296 kSwitch6, | 296 kSwitch6, |
297 "", | 297 "", |
298 NULL, | 298 NULL, |
299 NULL, | 299 NULL, |
300 NULL, | 300 NULL, |
301 0 | 301 0 |
302 }, | 302 }, |
303 }; | 303 }; |
304 | 304 |
305 class AboutFlagsTest : public ::testing::Test { | 305 class AboutFlagsTest : public ::testing::Test { |
306 protected: | 306 protected: |
307 AboutFlagsTest() : flags_storage_(&prefs_) { | 307 AboutFlagsTest() : flags_storage_(&prefs_) { |
308 prefs_.registry()->RegisterListPref( | 308 prefs_.registry()->RegisterListPref( |
309 flags_ui::prefs::kEnabledLabsExperiments); | 309 flags_ui::prefs::kEnabledLabsExperiments); |
310 testing::ClearState(); | 310 testing::ClearState(); |
311 } | 311 } |
312 | 312 |
313 void SetUp() override { | 313 void SetUp() override { |
314 for (size_t i = 0; i < arraysize(kExperiments); ++i) | 314 for (size_t i = 0; i < arraysize(kEntries); ++i) |
315 kExperiments[i].supported_platforms = GetCurrentPlatform(); | 315 kEntries[i].supported_platforms = GetCurrentPlatform(); |
316 | 316 |
317 int os_other_than_current = 1; | 317 int os_other_than_current = 1; |
318 while (os_other_than_current == GetCurrentPlatform()) | 318 while (os_other_than_current == GetCurrentPlatform()) |
319 os_other_than_current <<= 1; | 319 os_other_than_current <<= 1; |
320 kExperiments[2].supported_platforms = os_other_than_current; | 320 kEntries[2].supported_platforms = os_other_than_current; |
321 | 321 |
322 testing::SetExperiments(kExperiments, arraysize(kExperiments)); | 322 testing::SetFeatureEntries(kEntries, arraysize(kEntries)); |
323 } | 323 } |
324 | 324 |
325 void TearDown() override { testing::SetExperiments(NULL, 0); } | 325 void TearDown() override { testing::SetFeatureEntries(NULL, 0); } |
326 | 326 |
327 TestingPrefServiceSimple prefs_; | 327 TestingPrefServiceSimple prefs_; |
328 flags_ui::PrefServiceFlagsStorage flags_storage_; | 328 flags_ui::PrefServiceFlagsStorage flags_storage_; |
329 }; | 329 }; |
330 | 330 |
331 | 331 |
332 TEST_F(AboutFlagsTest, NoChangeNoRestart) { | 332 TEST_F(AboutFlagsTest, NoChangeNoRestart) { |
333 EXPECT_FALSE(IsRestartNeededToCommitChanges()); | 333 EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
334 SetExperimentEnabled(&flags_storage_, kFlags1, false); | 334 SetFeatureEntryEnabled(&flags_storage_, kFlags1, false); |
335 EXPECT_FALSE(IsRestartNeededToCommitChanges()); | 335 EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
336 | 336 |
337 // kFlags6 is enabled by default, so enabling should not require a restart. | 337 // kFlags6 is enabled by default, so enabling should not require a restart. |
338 SetExperimentEnabled(&flags_storage_, kFlags6, true); | 338 SetFeatureEntryEnabled(&flags_storage_, kFlags6, true); |
339 EXPECT_FALSE(IsRestartNeededToCommitChanges()); | 339 EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
340 } | 340 } |
341 | 341 |
342 TEST_F(AboutFlagsTest, ChangeNeedsRestart) { | 342 TEST_F(AboutFlagsTest, ChangeNeedsRestart) { |
343 EXPECT_FALSE(IsRestartNeededToCommitChanges()); | 343 EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
344 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 344 SetFeatureEntryEnabled(&flags_storage_, kFlags1, true); |
345 EXPECT_TRUE(IsRestartNeededToCommitChanges()); | 345 EXPECT_TRUE(IsRestartNeededToCommitChanges()); |
346 } | 346 } |
347 | 347 |
348 // Tests that disabling a default enabled experiment requires a restart. | 348 // Tests that disabling a default enabled entry requires a restart. |
349 TEST_F(AboutFlagsTest, DisableChangeNeedsRestart) { | 349 TEST_F(AboutFlagsTest, DisableChangeNeedsRestart) { |
350 EXPECT_FALSE(IsRestartNeededToCommitChanges()); | 350 EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
351 SetExperimentEnabled(&flags_storage_, kFlags6, false); | 351 SetFeatureEntryEnabled(&flags_storage_, kFlags6, false); |
352 EXPECT_TRUE(IsRestartNeededToCommitChanges()); | 352 EXPECT_TRUE(IsRestartNeededToCommitChanges()); |
353 } | 353 } |
354 | 354 |
355 TEST_F(AboutFlagsTest, MultiFlagChangeNeedsRestart) { | 355 TEST_F(AboutFlagsTest, MultiFlagChangeNeedsRestart) { |
356 const Experiment& experiment = kExperiments[3]; | 356 const FeatureEntry& entry = kEntries[3]; |
357 ASSERT_EQ(kFlags4, experiment.internal_name); | 357 ASSERT_EQ(kFlags4, entry.internal_name); |
358 EXPECT_FALSE(IsRestartNeededToCommitChanges()); | 358 EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
359 // Enable the 2nd choice of the multi-value. | 359 // Enable the 2nd choice of the multi-value. |
360 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); | 360 SetFeatureEntryEnabled(&flags_storage_, entry.NameForChoice(2), true); |
361 EXPECT_TRUE(IsRestartNeededToCommitChanges()); | 361 EXPECT_TRUE(IsRestartNeededToCommitChanges()); |
362 testing::ClearState(); | 362 testing::ClearState(); |
363 EXPECT_FALSE(IsRestartNeededToCommitChanges()); | 363 EXPECT_FALSE(IsRestartNeededToCommitChanges()); |
364 // Enable the default choice now. | 364 // Enable the default choice now. |
365 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); | 365 SetFeatureEntryEnabled(&flags_storage_, entry.NameForChoice(0), true); |
366 EXPECT_TRUE(IsRestartNeededToCommitChanges()); | 366 EXPECT_TRUE(IsRestartNeededToCommitChanges()); |
367 } | 367 } |
368 | 368 |
369 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveOne) { | 369 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveOne) { |
370 // Add two experiments, check they're there. | 370 // Add two entriess, check they're there. |
371 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 371 SetFeatureEntryEnabled(&flags_storage_, kFlags1, true); |
372 SetExperimentEnabled(&flags_storage_, kFlags2, true); | 372 SetFeatureEntryEnabled(&flags_storage_, kFlags2, true); |
373 | 373 |
374 const base::ListValue* experiments_list = | 374 const base::ListValue* entries_list = |
375 prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); | 375 prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); |
376 ASSERT_TRUE(experiments_list != NULL); | 376 ASSERT_TRUE(entries_list != NULL); |
377 | 377 |
378 ASSERT_EQ(2u, experiments_list->GetSize()); | 378 ASSERT_EQ(2u, entries_list->GetSize()); |
379 | 379 |
380 std::string s0; | 380 std::string s0; |
381 ASSERT_TRUE(experiments_list->GetString(0, &s0)); | 381 ASSERT_TRUE(entries_list->GetString(0, &s0)); |
382 std::string s1; | 382 std::string s1; |
383 ASSERT_TRUE(experiments_list->GetString(1, &s1)); | 383 ASSERT_TRUE(entries_list->GetString(1, &s1)); |
384 | 384 |
385 EXPECT_TRUE(s0 == kFlags1 || s1 == kFlags1); | 385 EXPECT_TRUE(s0 == kFlags1 || s1 == kFlags1); |
386 EXPECT_TRUE(s0 == kFlags2 || s1 == kFlags2); | 386 EXPECT_TRUE(s0 == kFlags2 || s1 == kFlags2); |
387 | 387 |
388 // Remove one experiment, check the other's still around. | 388 // Remove one entry, check the other's still around. |
389 SetExperimentEnabled(&flags_storage_, kFlags2, false); | 389 SetFeatureEntryEnabled(&flags_storage_, kFlags2, false); |
390 | 390 |
391 experiments_list = prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); | 391 entries_list = prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); |
392 ASSERT_TRUE(experiments_list != NULL); | 392 ASSERT_TRUE(entries_list != NULL); |
393 ASSERT_EQ(1u, experiments_list->GetSize()); | 393 ASSERT_EQ(1u, entries_list->GetSize()); |
394 ASSERT_TRUE(experiments_list->GetString(0, &s0)); | 394 ASSERT_TRUE(entries_list->GetString(0, &s0)); |
395 EXPECT_TRUE(s0 == kFlags1); | 395 EXPECT_TRUE(s0 == kFlags1); |
396 } | 396 } |
397 | 397 |
398 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveBoth) { | 398 TEST_F(AboutFlagsTest, AddTwoFlagsRemoveBoth) { |
399 // Add two experiments, check the pref exists. | 399 // Add two entries, check the pref exists. |
400 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 400 SetFeatureEntryEnabled(&flags_storage_, kFlags1, true); |
401 SetExperimentEnabled(&flags_storage_, kFlags2, true); | 401 SetFeatureEntryEnabled(&flags_storage_, kFlags2, true); |
402 const base::ListValue* experiments_list = | 402 const base::ListValue* entries_list = |
403 prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); | 403 prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); |
404 ASSERT_TRUE(experiments_list != NULL); | 404 ASSERT_TRUE(entries_list != NULL); |
405 | 405 |
406 // Remove both, the pref should have been removed completely. | 406 // Remove both, the pref should have been removed completely. |
407 SetExperimentEnabled(&flags_storage_, kFlags1, false); | 407 SetFeatureEntryEnabled(&flags_storage_, kFlags1, false); |
408 SetExperimentEnabled(&flags_storage_, kFlags2, false); | 408 SetFeatureEntryEnabled(&flags_storage_, kFlags2, false); |
409 experiments_list = prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); | 409 entries_list = prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); |
410 EXPECT_TRUE(experiments_list == NULL || experiments_list->GetSize() == 0); | 410 EXPECT_TRUE(entries_list == NULL || entries_list->GetSize() == 0); |
411 } | 411 } |
412 | 412 |
413 TEST_F(AboutFlagsTest, ConvertFlagsToSwitches) { | 413 TEST_F(AboutFlagsTest, ConvertFlagsToSwitches) { |
414 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 414 SetFeatureEntryEnabled(&flags_storage_, kFlags1, true); |
415 | 415 |
416 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 416 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
417 command_line.AppendSwitch("foo"); | 417 command_line.AppendSwitch("foo"); |
418 | 418 |
419 EXPECT_TRUE(command_line.HasSwitch("foo")); | 419 EXPECT_TRUE(command_line.HasSwitch("foo")); |
420 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 420 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
421 | 421 |
422 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 422 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
423 | 423 |
424 EXPECT_TRUE(command_line.HasSwitch("foo")); | 424 EXPECT_TRUE(command_line.HasSwitch("foo")); |
(...skipping 12 matching lines...) Expand all Loading... |
437 | 437 |
438 base::CommandLine::StringType CreateSwitch(const std::string& value) { | 438 base::CommandLine::StringType CreateSwitch(const std::string& value) { |
439 #if defined(OS_WIN) | 439 #if defined(OS_WIN) |
440 return base::ASCIIToUTF16(value); | 440 return base::ASCIIToUTF16(value); |
441 #else | 441 #else |
442 return value; | 442 return value; |
443 #endif | 443 #endif |
444 } | 444 } |
445 | 445 |
446 TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) { | 446 TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) { |
447 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 447 SetFeatureEntryEnabled(&flags_storage_, kFlags1, true); |
448 | 448 |
449 const std::string kDoubleDash("--"); | 449 const std::string kDoubleDash("--"); |
450 | 450 |
451 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 451 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
452 command_line.AppendSwitch("foo"); | 452 command_line.AppendSwitch("foo"); |
453 | 453 |
454 base::CommandLine new_command_line(base::CommandLine::NO_PROGRAM); | 454 base::CommandLine new_command_line(base::CommandLine::NO_PROGRAM); |
455 ConvertFlagsToSwitches(&flags_storage_, &new_command_line, kAddSentinels); | 455 ConvertFlagsToSwitches(&flags_storage_, &new_command_line, kAddSentinels); |
456 | 456 |
457 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( | 457 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( |
(...skipping 11 matching lines...) Expand all Loading... |
469 EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine( | 469 EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine( |
470 new_command_line, command_line, NULL)); | 470 new_command_line, command_line, NULL)); |
471 { | 471 { |
472 std::set<base::CommandLine::StringType> difference; | 472 std::set<base::CommandLine::StringType> difference; |
473 EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine( | 473 EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine( |
474 new_command_line, command_line, &difference)); | 474 new_command_line, command_line, &difference)); |
475 EXPECT_TRUE(difference.empty()); | 475 EXPECT_TRUE(difference.empty()); |
476 } | 476 } |
477 | 477 |
478 // Now both have flags but different. | 478 // Now both have flags but different. |
479 SetExperimentEnabled(&flags_storage_, kFlags1, false); | 479 SetFeatureEntryEnabled(&flags_storage_, kFlags1, false); |
480 SetExperimentEnabled(&flags_storage_, kFlags2, true); | 480 SetFeatureEntryEnabled(&flags_storage_, kFlags2, true); |
481 | 481 |
482 base::CommandLine another_command_line(base::CommandLine::NO_PROGRAM); | 482 base::CommandLine another_command_line(base::CommandLine::NO_PROGRAM); |
483 ConvertFlagsToSwitches(&flags_storage_, &another_command_line, kAddSentinels); | 483 ConvertFlagsToSwitches(&flags_storage_, &another_command_line, kAddSentinels); |
484 | 484 |
485 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( | 485 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( |
486 new_command_line, another_command_line, NULL)); | 486 new_command_line, another_command_line, NULL)); |
487 { | 487 { |
488 std::set<base::CommandLine::StringType> difference; | 488 std::set<base::CommandLine::StringType> difference; |
489 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( | 489 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( |
490 new_command_line, another_command_line, &difference)); | 490 new_command_line, another_command_line, &difference)); |
491 EXPECT_EQ(2U, difference.size()); | 491 EXPECT_EQ(2U, difference.size()); |
492 EXPECT_EQ(1U, difference.count(CreateSwitch(kDoubleDash + kSwitch1))); | 492 EXPECT_EQ(1U, difference.count(CreateSwitch(kDoubleDash + kSwitch1))); |
493 EXPECT_EQ(1U, | 493 EXPECT_EQ(1U, |
494 difference.count(CreateSwitch(kDoubleDash + kSwitch2 + "=" + | 494 difference.count(CreateSwitch(kDoubleDash + kSwitch2 + "=" + |
495 kValueForSwitch2))); | 495 kValueForSwitch2))); |
496 } | 496 } |
497 } | 497 } |
498 | 498 |
499 TEST_F(AboutFlagsTest, RemoveFlagSwitches) { | 499 TEST_F(AboutFlagsTest, RemoveFlagSwitches) { |
500 std::map<std::string, base::CommandLine::StringType> switch_list; | 500 std::map<std::string, base::CommandLine::StringType> switch_list; |
501 switch_list[kSwitch1] = base::CommandLine::StringType(); | 501 switch_list[kSwitch1] = base::CommandLine::StringType(); |
502 switch_list[switches::kFlagSwitchesBegin] = base::CommandLine::StringType(); | 502 switch_list[switches::kFlagSwitchesBegin] = base::CommandLine::StringType(); |
503 switch_list[switches::kFlagSwitchesEnd] = base::CommandLine::StringType(); | 503 switch_list[switches::kFlagSwitchesEnd] = base::CommandLine::StringType(); |
504 switch_list["foo"] = base::CommandLine::StringType(); | 504 switch_list["foo"] = base::CommandLine::StringType(); |
505 | 505 |
506 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 506 SetFeatureEntryEnabled(&flags_storage_, kFlags1, true); |
507 | 507 |
508 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called. | 508 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called. |
509 RemoveFlagsSwitches(&switch_list); | 509 RemoveFlagsSwitches(&switch_list); |
510 ASSERT_EQ(4u, switch_list.size()); | 510 ASSERT_EQ(4u, switch_list.size()); |
511 EXPECT_TRUE(switch_list.find(kSwitch1) != switch_list.end()); | 511 EXPECT_TRUE(switch_list.find(kSwitch1) != switch_list.end()); |
512 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesBegin) != | 512 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesBegin) != |
513 switch_list.end()); | 513 switch_list.end()); |
514 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesEnd) != | 514 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesEnd) != |
515 switch_list.end()); | 515 switch_list.end()); |
516 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); | 516 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); |
517 | 517 |
518 // Call ConvertFlagsToSwitches(), then RemoveFlagsSwitches() again. | 518 // Call ConvertFlagsToSwitches(), then RemoveFlagsSwitches() again. |
519 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 519 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
520 command_line.AppendSwitch("foo"); | 520 command_line.AppendSwitch("foo"); |
521 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 521 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
522 RemoveFlagsSwitches(&switch_list); | 522 RemoveFlagsSwitches(&switch_list); |
523 | 523 |
524 // Now the about:flags-related switch should have been removed. | 524 // Now the about:flags-related switch should have been removed. |
525 ASSERT_EQ(1u, switch_list.size()); | 525 ASSERT_EQ(1u, switch_list.size()); |
526 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); | 526 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); |
527 } | 527 } |
528 | 528 |
529 // Tests enabling experiments that aren't supported on the current platform. | 529 // Tests enabling entries that aren't supported on the current platform. |
530 TEST_F(AboutFlagsTest, PersistAndPrune) { | 530 TEST_F(AboutFlagsTest, PersistAndPrune) { |
531 // Enable experiments 1 and 3. | 531 // Enable entries 1 and 3. |
532 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 532 SetFeatureEntryEnabled(&flags_storage_, kFlags1, true); |
533 SetExperimentEnabled(&flags_storage_, kFlags3, true); | 533 SetFeatureEntryEnabled(&flags_storage_, kFlags3, true); |
534 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 534 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
535 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 535 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
536 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); | 536 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); |
537 | 537 |
538 // Convert the flags to switches. Experiment 3 shouldn't be among the switches | 538 // Convert the flags to switches. Entry 3 shouldn't be among the switches |
539 // as it is not applicable to the current platform. | 539 // as it is not applicable to the current platform. |
540 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 540 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
541 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); | 541 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
542 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); | 542 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); |
543 | 543 |
544 // Experiment 3 should show still be persisted in preferences though. | 544 // FeatureEntry 3 should show still be persisted in preferences though. |
545 const base::ListValue* experiments_list = | 545 const base::ListValue* entries_list = |
546 prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); | 546 prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); |
547 ASSERT_TRUE(experiments_list); | 547 ASSERT_TRUE(entries_list); |
548 EXPECT_EQ(2U, experiments_list->GetSize()); | 548 EXPECT_EQ(2U, entries_list->GetSize()); |
549 std::string s0; | 549 std::string s0; |
550 ASSERT_TRUE(experiments_list->GetString(0, &s0)); | 550 ASSERT_TRUE(entries_list->GetString(0, &s0)); |
551 EXPECT_EQ(kFlags1, s0); | 551 EXPECT_EQ(kFlags1, s0); |
552 std::string s1; | 552 std::string s1; |
553 ASSERT_TRUE(experiments_list->GetString(1, &s1)); | 553 ASSERT_TRUE(entries_list->GetString(1, &s1)); |
554 EXPECT_EQ(kFlags3, s1); | 554 EXPECT_EQ(kFlags3, s1); |
555 } | 555 } |
556 | 556 |
557 // Tests that switches which should have values get them in the command | 557 // Tests that switches which should have values get them in the command |
558 // line. | 558 // line. |
559 TEST_F(AboutFlagsTest, CheckValues) { | 559 TEST_F(AboutFlagsTest, CheckValues) { |
560 // Enable experiments 1 and 2. | 560 // Enable entries 1 and 2. |
561 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 561 SetFeatureEntryEnabled(&flags_storage_, kFlags1, true); |
562 SetExperimentEnabled(&flags_storage_, kFlags2, true); | 562 SetFeatureEntryEnabled(&flags_storage_, kFlags2, true); |
563 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 563 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
564 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 564 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
565 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); | 565 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); |
566 | 566 |
567 // Convert the flags to switches. | 567 // Convert the flags to switches. |
568 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 568 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
569 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); | 569 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
570 EXPECT_EQ(std::string(), command_line.GetSwitchValueASCII(kSwitch1)); | 570 EXPECT_EQ(std::string(), command_line.GetSwitchValueASCII(kSwitch1)); |
571 EXPECT_TRUE(command_line.HasSwitch(kSwitch2)); | 571 EXPECT_TRUE(command_line.HasSwitch(kSwitch2)); |
572 EXPECT_EQ(std::string(kValueForSwitch2), | 572 EXPECT_EQ(std::string(kValueForSwitch2), |
(...skipping 19 matching lines...) Expand all Loading... |
592 #if defined(OS_WIN) | 592 #if defined(OS_WIN) |
593 EXPECT_NE(base::string16::npos, | 593 EXPECT_NE(base::string16::npos, |
594 command_line.GetCommandLineString().find( | 594 command_line.GetCommandLineString().find( |
595 base::ASCIIToUTF16(switch2_with_equals))); | 595 base::ASCIIToUTF16(switch2_with_equals))); |
596 #else | 596 #else |
597 EXPECT_NE(std::string::npos, | 597 EXPECT_NE(std::string::npos, |
598 command_line.GetCommandLineString().find(switch2_with_equals)); | 598 command_line.GetCommandLineString().find(switch2_with_equals)); |
599 #endif | 599 #endif |
600 | 600 |
601 // And it should persist. | 601 // And it should persist. |
602 const base::ListValue* experiments_list = | 602 const base::ListValue* entries_list = |
603 prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); | 603 prefs_.GetList(flags_ui::prefs::kEnabledLabsExperiments); |
604 ASSERT_TRUE(experiments_list); | 604 ASSERT_TRUE(entries_list); |
605 EXPECT_EQ(2U, experiments_list->GetSize()); | 605 EXPECT_EQ(2U, entries_list->GetSize()); |
606 std::string s0; | 606 std::string s0; |
607 ASSERT_TRUE(experiments_list->GetString(0, &s0)); | 607 ASSERT_TRUE(entries_list->GetString(0, &s0)); |
608 EXPECT_EQ(kFlags1, s0); | 608 EXPECT_EQ(kFlags1, s0); |
609 std::string s1; | 609 std::string s1; |
610 ASSERT_TRUE(experiments_list->GetString(1, &s1)); | 610 ASSERT_TRUE(entries_list->GetString(1, &s1)); |
611 EXPECT_EQ(kFlags2, s1); | 611 EXPECT_EQ(kFlags2, s1); |
612 } | 612 } |
613 | 613 |
614 // Tests multi-value type experiments. | 614 // Tests multi-value type entries. |
615 TEST_F(AboutFlagsTest, MultiValues) { | 615 TEST_F(AboutFlagsTest, MultiValues) { |
616 const Experiment& experiment = kExperiments[3]; | 616 const FeatureEntry& entry = kEntries[3]; |
617 ASSERT_EQ(kFlags4, experiment.internal_name); | 617 ASSERT_EQ(kFlags4, entry.internal_name); |
618 | 618 |
619 // Initially, the first "deactivated" option of the multi experiment should | 619 // Initially, the first "deactivated" option of the multi entry should |
620 // be set. | 620 // be set. |
621 { | 621 { |
622 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 622 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
623 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 623 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
624 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); | 624 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); |
625 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); | 625 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); |
626 } | 626 } |
627 | 627 |
628 // Enable the 2nd choice of the multi-value. | 628 // Enable the 2nd choice of the multi-value. |
629 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); | 629 SetFeatureEntryEnabled(&flags_storage_, entry.NameForChoice(2), true); |
630 { | 630 { |
631 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 631 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
632 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 632 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
633 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); | 633 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); |
634 EXPECT_TRUE(command_line.HasSwitch(kMultiSwitch2)); | 634 EXPECT_TRUE(command_line.HasSwitch(kMultiSwitch2)); |
635 EXPECT_EQ(std::string(kValueForMultiSwitch2), | 635 EXPECT_EQ(std::string(kValueForMultiSwitch2), |
636 command_line.GetSwitchValueASCII(kMultiSwitch2)); | 636 command_line.GetSwitchValueASCII(kMultiSwitch2)); |
637 } | 637 } |
638 | 638 |
639 // Disable the multi-value experiment. | 639 // Disable the multi-value entry. |
640 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); | 640 SetFeatureEntryEnabled(&flags_storage_, entry.NameForChoice(0), true); |
641 { | 641 { |
642 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 642 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
643 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 643 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
644 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); | 644 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); |
645 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); | 645 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); |
646 } | 646 } |
647 } | 647 } |
648 | 648 |
649 // Tests that disable flags are added when an experiment is disabled. | 649 // Tests that disable flags are added when an entry is disabled. |
650 TEST_F(AboutFlagsTest, DisableFlagCommandLine) { | 650 TEST_F(AboutFlagsTest, DisableFlagCommandLine) { |
651 // Nothing selected. | 651 // Nothing selected. |
652 { | 652 { |
653 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 653 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
654 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 654 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
655 EXPECT_FALSE(command_line.HasSwitch(kSwitch6)); | 655 EXPECT_FALSE(command_line.HasSwitch(kSwitch6)); |
656 } | 656 } |
657 | 657 |
658 // Disable the experiment 6. | 658 // Disable the entry 6. |
659 SetExperimentEnabled(&flags_storage_, kFlags6, false); | 659 SetFeatureEntryEnabled(&flags_storage_, kFlags6, false); |
660 { | 660 { |
661 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 661 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
662 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 662 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
663 EXPECT_TRUE(command_line.HasSwitch(kSwitch6)); | 663 EXPECT_TRUE(command_line.HasSwitch(kSwitch6)); |
664 } | 664 } |
665 | 665 |
666 // Enable experiment 6. | 666 // Enable entry 6. |
667 SetExperimentEnabled(&flags_storage_, kFlags6, true); | 667 SetFeatureEntryEnabled(&flags_storage_, kFlags6, true); |
668 { | 668 { |
669 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 669 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
670 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 670 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
671 EXPECT_FALSE(command_line.HasSwitch(kSwitch6)); | 671 EXPECT_FALSE(command_line.HasSwitch(kSwitch6)); |
672 } | 672 } |
673 } | 673 } |
674 | 674 |
675 TEST_F(AboutFlagsTest, EnableDisableValues) { | 675 TEST_F(AboutFlagsTest, EnableDisableValues) { |
676 const Experiment& experiment = kExperiments[4]; | 676 const FeatureEntry& entry = kEntries[4]; |
677 ASSERT_EQ(kFlags5, experiment.internal_name); | 677 ASSERT_EQ(kFlags5, entry.internal_name); |
678 | 678 |
679 // Nothing selected. | 679 // Nothing selected. |
680 { | 680 { |
681 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 681 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
682 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 682 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
683 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 683 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
684 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); | 684 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); |
685 } | 685 } |
686 | 686 |
687 // "Enable" option selected. | 687 // "Enable" option selected. |
688 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(1), true); | 688 SetFeatureEntryEnabled(&flags_storage_, entry.NameForChoice(1), true); |
689 { | 689 { |
690 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 690 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
691 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 691 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
692 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); | 692 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
693 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); | 693 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); |
694 EXPECT_EQ(kEnableDisableValue1, command_line.GetSwitchValueASCII(kSwitch1)); | 694 EXPECT_EQ(kEnableDisableValue1, command_line.GetSwitchValueASCII(kSwitch1)); |
695 } | 695 } |
696 | 696 |
697 // "Disable" option selected. | 697 // "Disable" option selected. |
698 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); | 698 SetFeatureEntryEnabled(&flags_storage_, entry.NameForChoice(2), true); |
699 { | 699 { |
700 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 700 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
701 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 701 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
702 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 702 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
703 EXPECT_TRUE(command_line.HasSwitch(kSwitch2)); | 703 EXPECT_TRUE(command_line.HasSwitch(kSwitch2)); |
704 EXPECT_EQ(kEnableDisableValue2, command_line.GetSwitchValueASCII(kSwitch2)); | 704 EXPECT_EQ(kEnableDisableValue2, command_line.GetSwitchValueASCII(kSwitch2)); |
705 } | 705 } |
706 | 706 |
707 // "Default" option selected, same as nothing selected. | 707 // "Default" option selected, same as nothing selected. |
708 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); | 708 SetFeatureEntryEnabled(&flags_storage_, entry.NameForChoice(0), true); |
709 { | 709 { |
710 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | 710 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
711 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 711 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
712 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); | 712 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); |
713 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); | 713 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); |
714 } | 714 } |
715 } | 715 } |
716 | 716 |
717 // Makes sure there are no separators in any of the experiment names. | 717 // Makes sure there are no separators in any of the entry names. |
718 TEST_F(AboutFlagsTest, NoSeparators) { | 718 TEST_F(AboutFlagsTest, NoSeparators) { |
719 testing::SetExperiments(NULL, 0); | 719 testing::SetFeatureEntries(NULL, 0); |
720 size_t count; | 720 size_t count; |
721 const Experiment* experiments = testing::GetExperiments(&count); | 721 const FeatureEntry* entries = testing::GetFeatureEntries(&count); |
722 for (size_t i = 0; i < count; ++i) { | 722 for (size_t i = 0; i < count; ++i) { |
723 std::string name = experiments->internal_name; | 723 std::string name = entries[i].internal_name; |
724 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; | 724 EXPECT_EQ(std::string::npos, name.find(testing::kMultiSeparator)) << i; |
725 } | 725 } |
726 } | 726 } |
727 | 727 |
728 class AboutFlagsHistogramTest : public ::testing::Test { | 728 class AboutFlagsHistogramTest : public ::testing::Test { |
729 protected: | 729 protected: |
730 // This is a helper function to check that all IDs in enum LoginCustomFlags in | 730 // This is a helper function to check that all IDs in enum LoginCustomFlags in |
731 // histograms.xml are unique. | 731 // histograms.xml are unique. |
732 void SetSwitchToHistogramIdMapping(const std::string& switch_name, | 732 void SetSwitchToHistogramIdMapping(const std::string& switch_name, |
733 const Sample switch_histogram_id, | 733 const Sample switch_histogram_id, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 EXPECT_TRUE(enum_entry != histograms_xml_switches_ids.end() && | 814 EXPECT_TRUE(enum_entry != histograms_xml_switches_ids.end() && |
815 enum_entry->first == flag) | 815 enum_entry->first == flag) |
816 << "histograms.xml enum LoginCustomFlags doesn't contain switch '" | 816 << "histograms.xml enum LoginCustomFlags doesn't contain switch '" |
817 << flag << "' (value=" << uma_id | 817 << flag << "' (value=" << uma_id |
818 << " expected). Consider adding entry:\n" | 818 << " expected). Consider adding entry:\n" |
819 << " " << GetHistogramEnumEntryText(flag, uma_id); | 819 << " " << GetHistogramEnumEntryText(flag, uma_id); |
820 } | 820 } |
821 } | 821 } |
822 | 822 |
823 } // namespace about_flags | 823 } // namespace about_flags |
OLD | NEW |