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

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

Issue 10411031: Fixing loglevel in chrome driver to accept string rather than an integer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/test/webdriver/webdriver_capabilities_parser.h" 5 #include "chrome/test/webdriver/webdriver_capabilities_parser.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/webdriver/webdriver_error.h" 13 #include "chrome/test/webdriver/webdriver_error.h"
14 #include "chrome/test/webdriver/webdriver_logging.h"
14 #include "chrome/test/webdriver/webdriver_util.h" 15 #include "chrome/test/webdriver/webdriver_util.h"
15 16
16 using base::DictionaryValue; 17 using base::DictionaryValue;
17 using base::Value; 18 using base::Value;
18 19
19 namespace webdriver { 20 namespace webdriver {
20 21
21 namespace { 22 namespace {
22 23
23 Error* CreateBadInputError(const std::string& name, 24 Error* CreateBadInputError(const std::string& name,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 return CreateBadInputError("loggingPrefs", Value::TYPE_DICTIONARY, option); 233 return CreateBadInputError("loggingPrefs", Value::TYPE_DICTIONARY, option);
233 234
234 DictionaryValue::key_iterator key_iter = logging_prefs->begin_keys(); 235 DictionaryValue::key_iterator key_iter = logging_prefs->begin_keys();
235 for (; key_iter != logging_prefs->end_keys(); ++key_iter) { 236 for (; key_iter != logging_prefs->end_keys(); ++key_iter) {
236 LogType log_type; 237 LogType log_type;
237 if (!LogType::FromString(*key_iter, &log_type)) 238 if (!LogType::FromString(*key_iter, &log_type))
238 continue; 239 continue;
239 240
240 Value* level_value; 241 Value* level_value;
241 logging_prefs->Get(*key_iter, &level_value); 242 logging_prefs->Get(*key_iter, &level_value);
242 int level; 243 std::string level_name;
243 if (!level_value->GetAsInteger(&level)) { 244 if (!level_value->GetAsString(&level_name)) {
244 return CreateBadInputError( 245 return CreateBadInputError(
245 std::string("loggingPrefs.") + *key_iter, 246 std::string("loggingPrefs.") + *key_iter,
246 Value::TYPE_INTEGER, 247 Value::TYPE_STRING,
247 level_value); 248 level_value);
248 } 249 }
249 caps_->log_levels[log_type.type()] = static_cast<LogLevel>(level); 250 caps_->log_levels[log_type.type()] = LogLevelFromString(level_name);
250 } 251 }
251 return NULL; 252 return NULL;
252 } 253 }
253 254
254 Error* CapabilitiesParser::ParseNativeEvents(const Value* option) { 255 Error* CapabilitiesParser::ParseNativeEvents(const Value* option) {
255 if (!option->GetAsBoolean(&caps_->native_events)) 256 if (!option->GetAsBoolean(&caps_->native_events))
256 return CreateBadInputError("nativeEvents", Value::TYPE_BOOLEAN, option); 257 return CreateBadInputError("nativeEvents", Value::TYPE_BOOLEAN, option);
257 return NULL; 258 return NULL;
258 } 259 }
259 260
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 if (error) { 332 if (error) {
332 error->AddDetails("Error occurred while processing 'proxyType': " + 333 error->AddDetails("Error occurred while processing 'proxyType': " +
333 proxy_type); 334 proxy_type);
334 return error; 335 return error;
335 } 336 }
336 } 337 }
337 return NULL; 338 return NULL;
338 } 339 }
339 340
340 Error* CapabilitiesParser::ParseProxyAutoDetect( 341 Error* CapabilitiesParser::ParseProxyAutoDetect(
341 const DictionaryValue* options){ 342 const DictionaryValue* options) {
342 const char kProxyAutoDetectKey[] = "autodetect"; 343 const char kProxyAutoDetectKey[] = "autodetect";
343 bool proxy_auto_detect = false; 344 bool proxy_auto_detect = false;
344 if (!options->GetBoolean(kProxyAutoDetectKey, &proxy_auto_detect)) 345 if (!options->GetBoolean(kProxyAutoDetectKey, &proxy_auto_detect))
345 return CreateBadInputError(kProxyAutoDetectKey, 346 return CreateBadInputError(kProxyAutoDetectKey,
346 Value::TYPE_BOOLEAN, options); 347 Value::TYPE_BOOLEAN, options);
347 if (proxy_auto_detect) 348 if (proxy_auto_detect)
348 caps_->command.AppendSwitch(switches::kProxyAutoDetect); 349 caps_->command.AppendSwitch(switches::kProxyAutoDetect);
349 return NULL; 350 return NULL;
350 } 351 }
351 352
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 } 424 }
424 425
425 Error* CapabilitiesParser::ParseNoWebsiteTestingDefaults(const Value* option) { 426 Error* CapabilitiesParser::ParseNoWebsiteTestingDefaults(const Value* option) {
426 if (!option->GetAsBoolean(&caps_->no_website_testing_defaults)) 427 if (!option->GetAsBoolean(&caps_->no_website_testing_defaults))
427 return CreateBadInputError("noWebsiteTestingDefaults", 428 return CreateBadInputError("noWebsiteTestingDefaults",
428 Value::TYPE_BOOLEAN, option); 429 Value::TYPE_BOOLEAN, option);
429 return NULL; 430 return NULL;
430 } 431 }
431 432
432 } // namespace webdriver 433 } // namespace webdriver
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698