OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/chrome_switches.h" | 7 #include "chrome/common/chrome_switches.h" |
8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
9 #include "chrome/test/testing_pref_service.h" | 9 #include "chrome/test/testing_pref_service.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 experiments_list = prefs_.GetMutableList(prefs::kEnabledLabsExperiments); | 86 experiments_list = prefs_.GetMutableList(prefs::kEnabledLabsExperiments); |
87 EXPECT_TRUE(experiments_list == NULL || experiments_list->GetSize() == 0); | 87 EXPECT_TRUE(experiments_list == NULL || experiments_list->GetSize() == 0); |
88 } | 88 } |
89 | 89 |
90 TEST_F(AboutFlagsTest, ConvertFlagsToSwitches) { | 90 TEST_F(AboutFlagsTest, ConvertFlagsToSwitches) { |
91 if (!IsEnabled()) | 91 if (!IsEnabled()) |
92 return; | 92 return; |
93 | 93 |
94 SetExperimentEnabled(&prefs_, kFlags1, true); | 94 SetExperimentEnabled(&prefs_, kFlags1, true); |
95 | 95 |
96 CommandLine command_line(CommandLine::ARGUMENTS_ONLY); | 96 CommandLine command_line(CommandLine::NO_PROGRAM); |
97 command_line.AppendSwitch("foo"); | 97 command_line.AppendSwitch("foo"); |
98 | 98 |
99 EXPECT_TRUE(command_line.HasSwitch("foo")); | 99 EXPECT_TRUE(command_line.HasSwitch("foo")); |
100 EXPECT_FALSE(command_line.HasSwitch(kFlag1CommandLine)); | 100 EXPECT_FALSE(command_line.HasSwitch(kFlag1CommandLine)); |
101 | 101 |
102 ConvertFlagsToSwitches(&prefs_, &command_line); | 102 ConvertFlagsToSwitches(&prefs_, &command_line); |
103 | 103 |
104 EXPECT_TRUE(command_line.HasSwitch("foo")); | 104 EXPECT_TRUE(command_line.HasSwitch("foo")); |
105 EXPECT_TRUE(command_line.HasSwitch(kFlag1CommandLine)); | 105 EXPECT_TRUE(command_line.HasSwitch(kFlag1CommandLine)); |
106 } | 106 } |
(...skipping 14 matching lines...) Expand all Loading... |
121 RemoveFlagsSwitches(&switch_list); | 121 RemoveFlagsSwitches(&switch_list); |
122 ASSERT_EQ(4u, switch_list.size()); | 122 ASSERT_EQ(4u, switch_list.size()); |
123 EXPECT_TRUE(switch_list.find(kFlag1CommandLine) != switch_list.end()); | 123 EXPECT_TRUE(switch_list.find(kFlag1CommandLine) != switch_list.end()); |
124 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesBegin) != | 124 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesBegin) != |
125 switch_list.end()); | 125 switch_list.end()); |
126 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesEnd) != | 126 EXPECT_TRUE(switch_list.find(switches::kFlagSwitchesEnd) != |
127 switch_list.end()); | 127 switch_list.end()); |
128 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); | 128 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); |
129 | 129 |
130 // Call ConvertFlagsToSwitches(), then RemoveFlagsSwitches() again. | 130 // Call ConvertFlagsToSwitches(), then RemoveFlagsSwitches() again. |
131 CommandLine command_line(CommandLine::ARGUMENTS_ONLY); | 131 CommandLine command_line(CommandLine::NO_PROGRAM); |
132 command_line.AppendSwitch("foo"); | 132 command_line.AppendSwitch("foo"); |
133 ConvertFlagsToSwitches(&prefs_, &command_line); | 133 ConvertFlagsToSwitches(&prefs_, &command_line); |
134 RemoveFlagsSwitches(&switch_list); | 134 RemoveFlagsSwitches(&switch_list); |
135 | 135 |
136 // Now the about:flags-related switch should have been removed. | 136 // Now the about:flags-related switch should have been removed. |
137 ASSERT_EQ(1u, switch_list.size()); | 137 ASSERT_EQ(1u, switch_list.size()); |
138 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); | 138 EXPECT_TRUE(switch_list.find("foo") != switch_list.end()); |
139 } | 139 } |
140 | 140 |
141 } // namespace about_flags | 141 } // namespace about_flags |
OLD | NEW |