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

Side by Side Diff: chrome/test/webdriver/webdriver_capabilities_parser_unittest.cc

Issue 8995021: ignore null value in proxy servers and bypass list capabilities (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/test/webdriver/webdriver_capabilities_parser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/base64.h" 5 #include "base/base64.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/scoped_temp_dir.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 DictionaryValue dict; 173 DictionaryValue dict;
174 DictionaryValue* options = new DictionaryValue(); 174 DictionaryValue* options = new DictionaryValue();
175 dict.Set("proxy", options); 175 dict.Set("proxy", options);
176 176
177 options->SetString("proxyType", "manual"); 177 options->SetString("proxyType", "manual");
178 178
179 CapabilitiesParser parser(&dict, FilePath(), &caps); 179 CapabilitiesParser parser(&dict, FilePath(), &caps);
180 ASSERT_TRUE(parser.Parse()); 180 ASSERT_TRUE(parser.Parse());
181 } 181 }
182 182
183 TEST(CapabilitiesParser, ProxyTypeCapNullValue) {
184 Capabilities caps;
185 DictionaryValue dict;
186 DictionaryValue* options = new DictionaryValue();
187 dict.Set("proxy", options);
188
189 options->Set("proxyType", Value::CreateNullValue());
190
191 CapabilitiesParser parser(&dict, FilePath(), &caps);
192 ASSERT_TRUE(parser.Parse());
193 }
194
183 TEST(CapabilitiesParser, ProxyTypeManualCap) { 195 TEST(CapabilitiesParser, ProxyTypeManualCap) {
184 const char kProxyServers[] = "ftp=localhost:9001;http=localhost:8001"; 196 const char kProxyServers[] = "ftp=localhost:9001;http=localhost:8001";
185 Capabilities caps; 197 Capabilities caps;
186 DictionaryValue dict; 198 DictionaryValue dict;
187 DictionaryValue* options = new DictionaryValue(); 199 DictionaryValue* options = new DictionaryValue();
188 dict.Set("proxy", options); 200 dict.Set("proxy", options);
189 201
190 options->SetString("proxyType", "manual"); 202 options->SetString("proxyType", "manual");
191 options->SetString("httpProxy", "localhost:8001"); 203 options->SetString("httpProxy", "localhost:8001");
192 options->SetString("ftpProxy", "localhost:9001"); 204 options->SetString("ftpProxy", "localhost:9001");
193 205
194 CapabilitiesParser parser(&dict, FilePath(), &caps); 206 CapabilitiesParser parser(&dict, FilePath(), &caps);
195 ASSERT_FALSE(parser.Parse()); 207 ASSERT_FALSE(parser.Parse());
196 EXPECT_STREQ(kProxyServers, 208 EXPECT_STREQ(kProxyServers,
197 caps.command.GetSwitchValueASCII(switches::kProxyServer).c_str()); 209 caps.command.GetSwitchValueASCII(switches::kProxyServer).c_str());
198 } 210 }
199 211
200 TEST(CapabilitiesParser, ProxyBypassListCap) { 212 TEST(CapabilitiesParser, ProxyBypassListCap) {
201 const char kBypassList[] = "google.com, youtube.com"; 213 const char kBypassList[] = "google.com, youtube.com";
202 Capabilities caps; 214 Capabilities caps;
203 DictionaryValue dict; 215 DictionaryValue dict;
204 DictionaryValue* proxy_options = new DictionaryValue(); 216 DictionaryValue* options = new DictionaryValue();
205 dict.Set("proxy", proxy_options); 217 dict.Set("proxy", options);
206 218
207 proxy_options->SetString("proxyType", "manual"); 219 options->SetString("proxyType", "manual");
208 proxy_options->SetString("noProxy", kBypassList); 220 options->SetString("noProxy", kBypassList);
209 221
210 CapabilitiesParser parser(&dict, FilePath(), &caps); 222 CapabilitiesParser parser(&dict, FilePath(), &caps);
211 ASSERT_FALSE(parser.Parse()); 223 ASSERT_FALSE(parser.Parse());
212 EXPECT_STREQ(kBypassList, 224 EXPECT_STREQ(kBypassList,
213 caps.command.GetSwitchValueASCII(switches::kProxyBypassList).c_str()); 225 caps.command.GetSwitchValueASCII(switches::kProxyBypassList).c_str());
214 } 226 }
215 227
228 TEST(CapabilitiesParser, ProxyBypassListCapNullValue) {
229 Capabilities caps;
230 DictionaryValue dict;
231 DictionaryValue* options = new DictionaryValue();
232 dict.Set("proxy", options);
233
234 options->SetString("proxyType", "manual");
235 options->Set("noProxy", Value::CreateNullValue());
236 options->SetString("httpProxy", "localhost:8001");
237
238 CapabilitiesParser parser(&dict, FilePath(), &caps);
239 ASSERT_FALSE(parser.Parse());
240 EXPECT_STREQ("",
241 caps.command.GetSwitchValueASCII(switches::kProxyBypassList).c_str());
kkania 2011/12/19 23:53:20 EXPECT_FALSE(caps.command.HasSwitch...
Huyen 2011/12/19 23:59:12 Done.
242 }
243
216 TEST(CapabilitiesParser, UnknownProxyCap) { 244 TEST(CapabilitiesParser, UnknownProxyCap) {
217 Capabilities caps; 245 Capabilities caps;
218 DictionaryValue dict; 246 DictionaryValue dict;
219 DictionaryValue* options = new DictionaryValue(); 247 DictionaryValue* options = new DictionaryValue();
220 dict.Set("proxy", options); 248 dict.Set("proxy", options);
221 249
222 options->SetString("proxyType", "DIRECT"); 250 options->SetString("proxyType", "DIRECT");
223 options->SetString("badProxyCap", "error"); 251 options->SetString("badProxyCap", "error");
224 252
225 CapabilitiesParser parser(&dict, FilePath(), &caps); 253 CapabilitiesParser parser(&dict, FilePath(), &caps);
226 ASSERT_TRUE(parser.Parse()); 254 ASSERT_FALSE(parser.Parse());
255 }
256
257 TEST(CapabilitiesParser, ProxyFtpServerCapNullValue) {
258 Capabilities caps;
259 DictionaryValue dict;
260 DictionaryValue* options = new DictionaryValue();
261 dict.Set("proxy", options);
262
263 options->SetString("proxyType", "manual");
264 options->SetString("httpProxy", "localhost:8001");
265 options->Set("ftpProxy", Value::CreateNullValue());
266
267 CapabilitiesParser parser(&dict, FilePath(), &caps);
268 ASSERT_FALSE(parser.Parse());
269 EXPECT_STREQ("http=localhost:8001",
270 caps.command.GetSwitchValueASCII(switches::kProxyServer).c_str());
227 } 271 }
228 272
229 } // namespace webdriver 273 } // namespace webdriver
OLDNEW
« no previous file with comments | « chrome/test/webdriver/webdriver_capabilities_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698