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

Side by Side Diff: chrome/install_static/install_util_unittest.cc

Issue 2487783002: Make Crashpad use the user data dir, rather than always default location (Closed)
Patch Set: . Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/install_static/install_util.h" 5 #include "chrome/install_static/install_util.h"
6 6
7 #include "testing/gmock/include/gmock/gmock.h" 7 #include "testing/gmock/include/gmock/gmock.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 using ::testing::ElementsAre; 10 using ::testing::ElementsAre;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 EXPECT_EQ(1, result); 126 EXPECT_EQ(1, result);
127 127
128 // Case 11. Version1 < Version2. Multiple digit number. 128 // Case 11. Version1 < Version2. Multiple digit number.
129 EXPECT_TRUE(CompareVersionStrings("10.11.12.13", "12.11.12.13", &result)); 129 EXPECT_TRUE(CompareVersionStrings("10.11.12.13", "12.11.12.13", &result));
130 EXPECT_EQ(-1, result); 130 EXPECT_EQ(-1, result);
131 } 131 }
132 132
133 // Tests the install_static::GetSwitchValueFromCommandLine function. 133 // Tests the install_static::GetSwitchValueFromCommandLine function.
134 TEST(InstallStaticTest, GetSwitchValueFromCommandLineTest) { 134 TEST(InstallStaticTest, GetSwitchValueFromCommandLineTest) {
135 // Simple case with one switch. 135 // Simple case with one switch.
136 std::string value = 136 std::wstring value =
137 GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=bar", "type"); 137 GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type=bar", L"type");
138 EXPECT_EQ("bar", value); 138 EXPECT_EQ("bar", value);
139 139
140 // Multiple switches with trailing spaces between them. 140 // Multiple switches with trailing spaces between them.
141 value = GetSwitchValueFromCommandLine( 141 value = GetSwitchValueFromCommandLine(
142 "c:\\temp\\bleh.exe --type=bar --abc=def bleh", "abc"); 142 L"c:\\temp\\bleh.exe --type=bar --abc=def bleh", L"abc");
143 EXPECT_EQ("def", value); 143 EXPECT_EQ(L"def", value);
144 144
145 // Multiple switches with trailing spaces and tabs between them. 145 // Multiple switches with trailing spaces and tabs between them.
146 value = GetSwitchValueFromCommandLine( 146 value = GetSwitchValueFromCommandLine(
147 "c:\\temp\\bleh.exe --type=bar \t\t\t --abc=def bleh", "abc"); 147 L"c:\\temp\\bleh.exe --type=bar \t\t\t --abc=def bleh", L"abc");
148 EXPECT_EQ("def", value); 148 EXPECT_EQ("def", value);
149 149
150 // Non existent switch. 150 // Non existent switch.
151 value = GetSwitchValueFromCommandLine( 151 value = GetSwitchValueFromCommandLine(
152 "c:\\temp\\bleh.exe --foo=bar --abc=def bleh", "type"); 152 L"c:\\temp\\bleh.exe --foo=bar --abc=def bleh", L"type");
153 EXPECT_EQ("", value); 153 EXPECT_EQ(L"", value);
154 154
155 // Non existent switch. 155 // Non existent switch.
156 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe", "type"); 156 value = GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe", L"type");
157 EXPECT_EQ("", value); 157 EXPECT_EQ(L"", value);
158 158
159 // Non existent switch. 159 // Non existent switch.
160 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe type=bar", "type"); 160 value =
161 EXPECT_EQ("", value); 161 GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe type=bar", L"type");
162 EXPECT_EQ(L"", value);
162 163
163 // Trailing spaces after the switch. 164 // Trailing spaces after the switch.
164 value = GetSwitchValueFromCommandLine( 165 value = GetSwitchValueFromCommandLine(
165 "c:\\temp\\bleh.exe --type=bar \t\t", "type"); 166 L"c:\\temp\\bleh.exe --type=bar \t\t", L"type");
166 EXPECT_EQ("bar", value); 167 EXPECT_EQ(L"bar", value);
167 168
168 // Multiple switches with trailing spaces and tabs between them. 169 // Multiple switches with trailing spaces and tabs between them.
169 value = GetSwitchValueFromCommandLine( 170 value = GetSwitchValueFromCommandLine(
170 "c:\\temp\\bleh.exe --type=bar \t\t --foo=bleh", "foo"); 171 L"c:\\temp\\bleh.exe --type=bar \t\t --foo=bleh", L"foo");
171 EXPECT_EQ("bleh", value); 172 EXPECT_EQ(L"bleh", value);
172 173
173 // Nothing after a switch. 174 // Nothing after a switch.
174 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=", "type"); 175 value = GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type=", L"type");
175 EXPECT_TRUE(value.empty()); 176 EXPECT_TRUE(value.empty());
176 177
177 // Whitespace after a switch. 178 // Whitespace after a switch.
178 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type= ", "type"); 179 value =
180 GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type= ", L"type");
179 EXPECT_TRUE(value.empty()); 181 EXPECT_TRUE(value.empty());
180 182
181 // Just tabs after a switch. 183 // Just tabs after a switch.
182 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=\t\t\t", 184 value = GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type=\t\t\t",
183 "type"); 185 L"type");
184 EXPECT_TRUE(value.empty()); 186 EXPECT_TRUE(value.empty());
185 187
186 // Whitespace after the "=" before the value. 188 // Whitespace after the "=" before the value.
187 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type= bar", 189 value =
188 "type"); 190 GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type= bar", L"type");
189 EXPECT_EQ("bar", value); 191 EXPECT_EQ(L"bar", value);
190 192
191 // Tabs after the "=" before the value. 193 // Tabs after the "=" before the value.
192 value = GetSwitchValueFromCommandLine("c:\\temp\\bleh.exe --type=\t\t\tbar", 194 value = GetSwitchValueFromCommandLine(L"c:\\temp\\bleh.exe --type=\t\t\tbar",
193 "type"); 195 L"type");
194 EXPECT_EQ(value, "bar"); 196 EXPECT_EQ(value, L"bar");
195 } 197 }
196 198
197 } // namespace install_static 199 } // namespace install_static
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698