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 "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 Loading... |
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_FALSE(caps.command.HasSwitch(switches::kProxyBypassList)); |
| 241 } |
| 242 |
216 TEST(CapabilitiesParser, UnknownProxyCap) { | 243 TEST(CapabilitiesParser, UnknownProxyCap) { |
217 Capabilities caps; | 244 Capabilities caps; |
218 DictionaryValue dict; | 245 DictionaryValue dict; |
219 DictionaryValue* options = new DictionaryValue(); | 246 DictionaryValue* options = new DictionaryValue(); |
220 dict.Set("proxy", options); | 247 dict.Set("proxy", options); |
221 | 248 |
222 options->SetString("proxyType", "DIRECT"); | 249 options->SetString("proxyType", "DIRECT"); |
223 options->SetString("badProxyCap", "error"); | 250 options->SetString("badProxyCap", "error"); |
224 | 251 |
225 CapabilitiesParser parser(&dict, FilePath(), &caps); | 252 CapabilitiesParser parser(&dict, FilePath(), &caps); |
226 ASSERT_TRUE(parser.Parse()); | 253 ASSERT_FALSE(parser.Parse()); |
| 254 } |
| 255 |
| 256 TEST(CapabilitiesParser, ProxyFtpServerCapNullValue) { |
| 257 Capabilities caps; |
| 258 DictionaryValue dict; |
| 259 DictionaryValue* options = new DictionaryValue(); |
| 260 dict.Set("proxy", options); |
| 261 |
| 262 options->SetString("proxyType", "manual"); |
| 263 options->SetString("httpProxy", "localhost:8001"); |
| 264 options->Set("ftpProxy", Value::CreateNullValue()); |
| 265 |
| 266 CapabilitiesParser parser(&dict, FilePath(), &caps); |
| 267 ASSERT_FALSE(parser.Parse()); |
| 268 EXPECT_STREQ("http=localhost:8001", |
| 269 caps.command.GetSwitchValueASCII(switches::kProxyServer).c_str()); |
227 } | 270 } |
228 | 271 |
229 } // namespace webdriver | 272 } // namespace webdriver |
OLD | NEW |