| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 // Remove both, the pref should have been removed completely. | 378 // Remove both, the pref should have been removed completely. |
| 379 SetExperimentEnabled(&flags_storage_, kFlags1, false); | 379 SetExperimentEnabled(&flags_storage_, kFlags1, false); |
| 380 SetExperimentEnabled(&flags_storage_, kFlags2, false); | 380 SetExperimentEnabled(&flags_storage_, kFlags2, false); |
| 381 experiments_list = prefs_.GetList(prefs::kEnabledLabsExperiments); | 381 experiments_list = prefs_.GetList(prefs::kEnabledLabsExperiments); |
| 382 EXPECT_TRUE(experiments_list == NULL || experiments_list->GetSize() == 0); | 382 EXPECT_TRUE(experiments_list == NULL || experiments_list->GetSize() == 0); |
| 383 } | 383 } |
| 384 | 384 |
| 385 TEST_F(AboutFlagsTest, ConvertFlagsToSwitches) { | 385 TEST_F(AboutFlagsTest, ConvertFlagsToSwitches) { |
| 386 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 386 SetExperimentEnabled(&flags_storage_, kFlags1, true); |
| 387 | 387 |
| 388 CommandLine command_line(CommandLine::NO_PROGRAM); | 388 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 389 command_line.AppendSwitch("foo"); | 389 command_line.AppendSwitch("foo"); |
| 390 | 390 |
| 391 EXPECT_TRUE(command_line.HasSwitch("foo")); | 391 EXPECT_TRUE(command_line.HasSwitch("foo")); |
| 392 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 392 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
| 393 | 393 |
| 394 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 394 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 395 | 395 |
| 396 EXPECT_TRUE(command_line.HasSwitch("foo")); | 396 EXPECT_TRUE(command_line.HasSwitch("foo")); |
| 397 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); | 397 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
| 398 EXPECT_TRUE(command_line.HasSwitch(switches::kFlagSwitchesBegin)); | 398 EXPECT_TRUE(command_line.HasSwitch(switches::kFlagSwitchesBegin)); |
| 399 EXPECT_TRUE(command_line.HasSwitch(switches::kFlagSwitchesEnd)); | 399 EXPECT_TRUE(command_line.HasSwitch(switches::kFlagSwitchesEnd)); |
| 400 | 400 |
| 401 CommandLine command_line2(CommandLine::NO_PROGRAM); | 401 base::CommandLine command_line2(base::CommandLine::NO_PROGRAM); |
| 402 | 402 |
| 403 ConvertFlagsToSwitches(&flags_storage_, &command_line2, kNoSentinels); | 403 ConvertFlagsToSwitches(&flags_storage_, &command_line2, kNoSentinels); |
| 404 | 404 |
| 405 EXPECT_TRUE(command_line2.HasSwitch(kSwitch1)); | 405 EXPECT_TRUE(command_line2.HasSwitch(kSwitch1)); |
| 406 EXPECT_FALSE(command_line2.HasSwitch(switches::kFlagSwitchesBegin)); | 406 EXPECT_FALSE(command_line2.HasSwitch(switches::kFlagSwitchesBegin)); |
| 407 EXPECT_FALSE(command_line2.HasSwitch(switches::kFlagSwitchesEnd)); | 407 EXPECT_FALSE(command_line2.HasSwitch(switches::kFlagSwitchesEnd)); |
| 408 } | 408 } |
| 409 | 409 |
| 410 CommandLine::StringType CreateSwitch(const std::string& value) { | 410 base::CommandLine::StringType CreateSwitch(const std::string& value) { |
| 411 #if defined(OS_WIN) | 411 #if defined(OS_WIN) |
| 412 return base::ASCIIToUTF16(value); | 412 return base::ASCIIToUTF16(value); |
| 413 #else | 413 #else |
| 414 return value; | 414 return value; |
| 415 #endif | 415 #endif |
| 416 } | 416 } |
| 417 | 417 |
| 418 TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) { | 418 TEST_F(AboutFlagsTest, CompareSwitchesToCurrentCommandLine) { |
| 419 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 419 SetExperimentEnabled(&flags_storage_, kFlags1, true); |
| 420 | 420 |
| 421 const std::string kDoubleDash("--"); | 421 const std::string kDoubleDash("--"); |
| 422 | 422 |
| 423 CommandLine command_line(CommandLine::NO_PROGRAM); | 423 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 424 command_line.AppendSwitch("foo"); | 424 command_line.AppendSwitch("foo"); |
| 425 | 425 |
| 426 CommandLine new_command_line(CommandLine::NO_PROGRAM); | 426 base::CommandLine new_command_line(base::CommandLine::NO_PROGRAM); |
| 427 ConvertFlagsToSwitches(&flags_storage_, &new_command_line, kAddSentinels); | 427 ConvertFlagsToSwitches(&flags_storage_, &new_command_line, kAddSentinels); |
| 428 | 428 |
| 429 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( | 429 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( |
| 430 new_command_line, command_line, NULL)); | 430 new_command_line, command_line, NULL)); |
| 431 { | 431 { |
| 432 std::set<CommandLine::StringType> difference; | 432 std::set<base::CommandLine::StringType> difference; |
| 433 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( | 433 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( |
| 434 new_command_line, command_line, &difference)); | 434 new_command_line, command_line, &difference)); |
| 435 EXPECT_EQ(1U, difference.size()); | 435 EXPECT_EQ(1U, difference.size()); |
| 436 EXPECT_EQ(1U, difference.count(CreateSwitch(kDoubleDash + kSwitch1))); | 436 EXPECT_EQ(1U, difference.count(CreateSwitch(kDoubleDash + kSwitch1))); |
| 437 } | 437 } |
| 438 | 438 |
| 439 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 439 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 440 | 440 |
| 441 EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine( | 441 EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine( |
| 442 new_command_line, command_line, NULL)); | 442 new_command_line, command_line, NULL)); |
| 443 { | 443 { |
| 444 std::set<CommandLine::StringType> difference; | 444 std::set<base::CommandLine::StringType> difference; |
| 445 EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine( | 445 EXPECT_TRUE(AreSwitchesIdenticalToCurrentCommandLine( |
| 446 new_command_line, command_line, &difference)); | 446 new_command_line, command_line, &difference)); |
| 447 EXPECT_TRUE(difference.empty()); | 447 EXPECT_TRUE(difference.empty()); |
| 448 } | 448 } |
| 449 | 449 |
| 450 // Now both have flags but different. | 450 // Now both have flags but different. |
| 451 SetExperimentEnabled(&flags_storage_, kFlags1, false); | 451 SetExperimentEnabled(&flags_storage_, kFlags1, false); |
| 452 SetExperimentEnabled(&flags_storage_, kFlags2, true); | 452 SetExperimentEnabled(&flags_storage_, kFlags2, true); |
| 453 | 453 |
| 454 CommandLine another_command_line(CommandLine::NO_PROGRAM); | 454 base::CommandLine another_command_line(base::CommandLine::NO_PROGRAM); |
| 455 ConvertFlagsToSwitches(&flags_storage_, &another_command_line, kAddSentinels); | 455 ConvertFlagsToSwitches(&flags_storage_, &another_command_line, kAddSentinels); |
| 456 | 456 |
| 457 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( | 457 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( |
| 458 new_command_line, another_command_line, NULL)); | 458 new_command_line, another_command_line, NULL)); |
| 459 { | 459 { |
| 460 std::set<CommandLine::StringType> difference; | 460 std::set<base::CommandLine::StringType> difference; |
| 461 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( | 461 EXPECT_FALSE(AreSwitchesIdenticalToCurrentCommandLine( |
| 462 new_command_line, another_command_line, &difference)); | 462 new_command_line, another_command_line, &difference)); |
| 463 EXPECT_EQ(2U, difference.size()); | 463 EXPECT_EQ(2U, difference.size()); |
| 464 EXPECT_EQ(1U, difference.count(CreateSwitch(kDoubleDash + kSwitch1))); | 464 EXPECT_EQ(1U, difference.count(CreateSwitch(kDoubleDash + kSwitch1))); |
| 465 EXPECT_EQ(1U, | 465 EXPECT_EQ(1U, |
| 466 difference.count(CreateSwitch(kDoubleDash + kSwitch2 + "=" + | 466 difference.count(CreateSwitch(kDoubleDash + kSwitch2 + "=" + |
| 467 kValueForSwitch2))); | 467 kValueForSwitch2))); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 | 470 |
| 471 TEST_F(AboutFlagsTest, RemoveFlagSwitches) { | 471 TEST_F(AboutFlagsTest, RemoveFlagSwitches) { |
| 472 std::map<std::string, CommandLine::StringType> switch_list; | 472 std::map<std::string, base::CommandLine::StringType> switch_list; |
| 473 switch_list[kSwitch1] = CommandLine::StringType(); | 473 switch_list[kSwitch1] = base::CommandLine::StringType(); |
| 474 switch_list[switches::kFlagSwitchesBegin] = CommandLine::StringType(); | 474 switch_list[switches::kFlagSwitchesBegin] = base::CommandLine::StringType(); |
| 475 switch_list[switches::kFlagSwitchesEnd] = CommandLine::StringType(); | 475 switch_list[switches::kFlagSwitchesEnd] = base::CommandLine::StringType(); |
| 476 switch_list["foo"] = CommandLine::StringType(); | 476 switch_list["foo"] = base::CommandLine::StringType(); |
| 477 | 477 |
| 478 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 478 SetExperimentEnabled(&flags_storage_, kFlags1, true); |
| 479 | 479 |
| 480 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called. | 480 // This shouldn't do anything before ConvertFlagsToSwitches() wasn't called. |
| 481 RemoveFlagsSwitches(&switch_list); | 481 RemoveFlagsSwitches(&switch_list); |
| 482 ASSERT_EQ(4u, switch_list.size()); | 482 ASSERT_EQ(4u, switch_list.size()); |
| 483 EXPECT_TRUE(switch_list.find(kSwitch1) != switch_list.end()); | 483 EXPECT_TRUE(switch_list.find(kSwitch1) != switch_list.end()); |
| 484 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesBegin) != | 484 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesBegin) != |
| 485 switch_list.end()); | 485 switch_list.end()); |
| 486 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesEnd) != | 486 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesEnd) != |
| 487 switch_list.end()); | 487 switch_list.end()); |
| 488 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); | 488 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); |
| 489 | 489 |
| 490 // Call ConvertFlagsToSwitches(), then RemoveFlagsSwitches() again. | 490 // Call ConvertFlagsToSwitches(), then RemoveFlagsSwitches() again. |
| 491 CommandLine command_line(CommandLine::NO_PROGRAM); | 491 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 492 command_line.AppendSwitch("foo"); | 492 command_line.AppendSwitch("foo"); |
| 493 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 493 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 494 RemoveFlagsSwitches(&switch_list); | 494 RemoveFlagsSwitches(&switch_list); |
| 495 | 495 |
| 496 // Now the about:flags-related switch should have been removed. | 496 // Now the about:flags-related switch should have been removed. |
| 497 ASSERT_EQ(1u, switch_list.size()); | 497 ASSERT_EQ(1u, switch_list.size()); |
| 498 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); | 498 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); |
| 499 } | 499 } |
| 500 | 500 |
| 501 // Tests enabling experiments that aren't supported on the current platform. | 501 // Tests enabling experiments that aren't supported on the current platform. |
| 502 TEST_F(AboutFlagsTest, PersistAndPrune) { | 502 TEST_F(AboutFlagsTest, PersistAndPrune) { |
| 503 // Enable experiments 1 and 3. | 503 // Enable experiments 1 and 3. |
| 504 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 504 SetExperimentEnabled(&flags_storage_, kFlags1, true); |
| 505 SetExperimentEnabled(&flags_storage_, kFlags3, true); | 505 SetExperimentEnabled(&flags_storage_, kFlags3, true); |
| 506 CommandLine command_line(CommandLine::NO_PROGRAM); | 506 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 507 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 507 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
| 508 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); | 508 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); |
| 509 | 509 |
| 510 // Convert the flags to switches. Experiment 3 shouldn't be among the switches | 510 // Convert the flags to switches. Experiment 3 shouldn't be among the switches |
| 511 // as it is not applicable to the current platform. | 511 // as it is not applicable to the current platform. |
| 512 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 512 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 513 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); | 513 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
| 514 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); | 514 EXPECT_FALSE(command_line.HasSwitch(kSwitch3)); |
| 515 | 515 |
| 516 // Experiment 3 should show still be persisted in preferences though. | 516 // Experiment 3 should show still be persisted in preferences though. |
| 517 const base::ListValue* experiments_list = | 517 const base::ListValue* experiments_list = |
| 518 prefs_.GetList(prefs::kEnabledLabsExperiments); | 518 prefs_.GetList(prefs::kEnabledLabsExperiments); |
| 519 ASSERT_TRUE(experiments_list); | 519 ASSERT_TRUE(experiments_list); |
| 520 EXPECT_EQ(2U, experiments_list->GetSize()); | 520 EXPECT_EQ(2U, experiments_list->GetSize()); |
| 521 std::string s0; | 521 std::string s0; |
| 522 ASSERT_TRUE(experiments_list->GetString(0, &s0)); | 522 ASSERT_TRUE(experiments_list->GetString(0, &s0)); |
| 523 EXPECT_EQ(kFlags1, s0); | 523 EXPECT_EQ(kFlags1, s0); |
| 524 std::string s1; | 524 std::string s1; |
| 525 ASSERT_TRUE(experiments_list->GetString(1, &s1)); | 525 ASSERT_TRUE(experiments_list->GetString(1, &s1)); |
| 526 EXPECT_EQ(kFlags3, s1); | 526 EXPECT_EQ(kFlags3, s1); |
| 527 } | 527 } |
| 528 | 528 |
| 529 // Tests that switches which should have values get them in the command | 529 // Tests that switches which should have values get them in the command |
| 530 // line. | 530 // line. |
| 531 TEST_F(AboutFlagsTest, CheckValues) { | 531 TEST_F(AboutFlagsTest, CheckValues) { |
| 532 // Enable experiments 1 and 2. | 532 // Enable experiments 1 and 2. |
| 533 SetExperimentEnabled(&flags_storage_, kFlags1, true); | 533 SetExperimentEnabled(&flags_storage_, kFlags1, true); |
| 534 SetExperimentEnabled(&flags_storage_, kFlags2, true); | 534 SetExperimentEnabled(&flags_storage_, kFlags2, true); |
| 535 CommandLine command_line(CommandLine::NO_PROGRAM); | 535 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 536 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 536 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
| 537 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); | 537 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); |
| 538 | 538 |
| 539 // Convert the flags to switches. | 539 // Convert the flags to switches. |
| 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_EQ(std::string(), command_line.GetSwitchValueASCII(kSwitch1)); | 542 EXPECT_EQ(std::string(), command_line.GetSwitchValueASCII(kSwitch1)); |
| 543 EXPECT_TRUE(command_line.HasSwitch(kSwitch2)); | 543 EXPECT_TRUE(command_line.HasSwitch(kSwitch2)); |
| 544 EXPECT_EQ(std::string(kValueForSwitch2), | 544 EXPECT_EQ(std::string(kValueForSwitch2), |
| 545 command_line.GetSwitchValueASCII(kSwitch2)); | 545 command_line.GetSwitchValueASCII(kSwitch2)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 584 } |
| 585 | 585 |
| 586 // Tests multi-value type experiments. | 586 // Tests multi-value type experiments. |
| 587 TEST_F(AboutFlagsTest, MultiValues) { | 587 TEST_F(AboutFlagsTest, MultiValues) { |
| 588 const Experiment& experiment = kExperiments[3]; | 588 const Experiment& experiment = kExperiments[3]; |
| 589 ASSERT_EQ(kFlags4, experiment.internal_name); | 589 ASSERT_EQ(kFlags4, experiment.internal_name); |
| 590 | 590 |
| 591 // Initially, the first "deactivated" option of the multi experiment should | 591 // Initially, the first "deactivated" option of the multi experiment should |
| 592 // be set. | 592 // be set. |
| 593 { | 593 { |
| 594 CommandLine command_line(CommandLine::NO_PROGRAM); | 594 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 595 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 595 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 596 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); | 596 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); |
| 597 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); | 597 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); |
| 598 } | 598 } |
| 599 | 599 |
| 600 // Enable the 2nd choice of the multi-value. | 600 // Enable the 2nd choice of the multi-value. |
| 601 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); | 601 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); |
| 602 { | 602 { |
| 603 CommandLine command_line(CommandLine::NO_PROGRAM); | 603 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 604 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 604 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 605 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); | 605 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); |
| 606 EXPECT_TRUE(command_line.HasSwitch(kMultiSwitch2)); | 606 EXPECT_TRUE(command_line.HasSwitch(kMultiSwitch2)); |
| 607 EXPECT_EQ(std::string(kValueForMultiSwitch2), | 607 EXPECT_EQ(std::string(kValueForMultiSwitch2), |
| 608 command_line.GetSwitchValueASCII(kMultiSwitch2)); | 608 command_line.GetSwitchValueASCII(kMultiSwitch2)); |
| 609 } | 609 } |
| 610 | 610 |
| 611 // Disable the multi-value experiment. | 611 // Disable the multi-value experiment. |
| 612 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); | 612 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); |
| 613 { | 613 { |
| 614 CommandLine command_line(CommandLine::NO_PROGRAM); | 614 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 615 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 615 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 616 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); | 616 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); |
| 617 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); | 617 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 TEST_F(AboutFlagsTest, EnableDisableValues) { | 621 TEST_F(AboutFlagsTest, EnableDisableValues) { |
| 622 const Experiment& experiment = kExperiments[4]; | 622 const Experiment& experiment = kExperiments[4]; |
| 623 ASSERT_EQ(kFlags5, experiment.internal_name); | 623 ASSERT_EQ(kFlags5, experiment.internal_name); |
| 624 | 624 |
| 625 // Nothing selected. | 625 // Nothing selected. |
| 626 { | 626 { |
| 627 CommandLine command_line(CommandLine::NO_PROGRAM); | 627 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 628 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 628 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 629 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 629 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
| 630 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); | 630 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); |
| 631 } | 631 } |
| 632 | 632 |
| 633 // "Enable" option selected. | 633 // "Enable" option selected. |
| 634 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(1), true); | 634 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(1), true); |
| 635 { | 635 { |
| 636 CommandLine command_line(CommandLine::NO_PROGRAM); | 636 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 637 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 637 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 638 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); | 638 EXPECT_TRUE(command_line.HasSwitch(kSwitch1)); |
| 639 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); | 639 EXPECT_FALSE(command_line.HasSwitch(kSwitch2)); |
| 640 EXPECT_EQ(kEnableDisableValue1, command_line.GetSwitchValueASCII(kSwitch1)); | 640 EXPECT_EQ(kEnableDisableValue1, command_line.GetSwitchValueASCII(kSwitch1)); |
| 641 } | 641 } |
| 642 | 642 |
| 643 // "Disable" option selected. | 643 // "Disable" option selected. |
| 644 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); | 644 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(2), true); |
| 645 { | 645 { |
| 646 CommandLine command_line(CommandLine::NO_PROGRAM); | 646 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 647 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 647 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 648 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); | 648 EXPECT_FALSE(command_line.HasSwitch(kSwitch1)); |
| 649 EXPECT_TRUE(command_line.HasSwitch(kSwitch2)); | 649 EXPECT_TRUE(command_line.HasSwitch(kSwitch2)); |
| 650 EXPECT_EQ(kEnableDisableValue2, command_line.GetSwitchValueASCII(kSwitch2)); | 650 EXPECT_EQ(kEnableDisableValue2, command_line.GetSwitchValueASCII(kSwitch2)); |
| 651 } | 651 } |
| 652 | 652 |
| 653 // "Default" option selected, same as nothing selected. | 653 // "Default" option selected, same as nothing selected. |
| 654 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); | 654 SetExperimentEnabled(&flags_storage_, experiment.NameForChoice(0), true); |
| 655 { | 655 { |
| 656 CommandLine command_line(CommandLine::NO_PROGRAM); | 656 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); |
| 657 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); | 657 ConvertFlagsToSwitches(&flags_storage_, &command_line, kAddSentinels); |
| 658 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); | 658 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch1)); |
| 659 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); | 659 EXPECT_FALSE(command_line.HasSwitch(kMultiSwitch2)); |
| 660 } | 660 } |
| 661 } | 661 } |
| 662 | 662 |
| 663 // Makes sure there are no separators in any of the experiment names. | 663 // Makes sure there are no separators in any of the experiment names. |
| 664 TEST_F(AboutFlagsTest, NoSeparators) { | 664 TEST_F(AboutFlagsTest, NoSeparators) { |
| 665 testing::SetExperiments(NULL, 0); | 665 testing::SetExperiments(NULL, 0); |
| 666 size_t count; | 666 size_t count; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 EXPECT_TRUE(enum_entry != histograms_xml_switches_ids.end() && | 760 EXPECT_TRUE(enum_entry != histograms_xml_switches_ids.end() && |
| 761 enum_entry->first == flag) | 761 enum_entry->first == flag) |
| 762 << "histograms.xml enum LoginCustomFlags doesn't contain switch '" | 762 << "histograms.xml enum LoginCustomFlags doesn't contain switch '" |
| 763 << flag << "' (value=" << uma_id | 763 << flag << "' (value=" << uma_id |
| 764 << " expected). Consider adding entry:\n" | 764 << " expected). Consider adding entry:\n" |
| 765 << " " << GetHistogramEnumEntryText(flag, uma_id); | 765 << " " << GetHistogramEnumEntryText(flag, uma_id); |
| 766 } | 766 } |
| 767 } | 767 } |
| 768 | 768 |
| 769 } // namespace about_flags | 769 } // namespace about_flags |
| OLD | NEW |