OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromedriver/capabilities.h" | 5 #include "chrome/test/chromedriver/capabilities.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 if (parser_map.find(it.key()) == parser_map.end()) | 392 if (parser_map.find(it.key()) == parser_map.end()) |
393 return Status(kUnknownError, "unrecognized performance logging " | 393 return Status(kUnknownError, "unrecognized performance logging " |
394 "option: " + it.key()); | 394 "option: " + it.key()); |
395 Status status = parser_map[it.key()].Run(it.value(), capabilities); | 395 Status status = parser_map[it.key()].Run(it.value(), capabilities); |
396 if (status.IsError()) | 396 if (status.IsError()) |
397 return Status(kUnknownError, "cannot parse " + it.key(), status); | 397 return Status(kUnknownError, "cannot parse " + it.key(), status); |
398 } | 398 } |
399 return Status(kOk); | 399 return Status(kOk); |
400 } | 400 } |
401 | 401 |
402 Status ParseDevToolsEventsLoggingPrefs(const base::Value& option, | |
403 Capabilities* capabilities) { | |
404 const base::ListValue* dt_events_logging_prefs = NULL; | |
samuong
2017/03/27 18:42:10
use nullptr instead of NULL
| |
405 if (!option.GetAsList(&dt_events_logging_prefs)) | |
406 return Status(kUnknownError, "must be a list"); | |
407 if (dt_events_logging_prefs->empty()) | |
408 return Status(kUnknownError, "list must contain values"); | |
409 capabilities->dt_events_logging_prefs = dt_events_logging_prefs->DeepCopy(); | |
410 return Status(kOk); | |
411 } | |
412 | |
402 Status ParseWindowTypes(const base::Value& option, Capabilities* capabilities) { | 413 Status ParseWindowTypes(const base::Value& option, Capabilities* capabilities) { |
403 const base::ListValue* window_types = NULL; | 414 const base::ListValue* window_types = NULL; |
404 if (!option.GetAsList(&window_types)) | 415 if (!option.GetAsList(&window_types)) |
405 return Status(kUnknownError, "must be a list"); | 416 return Status(kUnknownError, "must be a list"); |
406 std::set<WebViewInfo::Type> window_types_tmp; | 417 std::set<WebViewInfo::Type> window_types_tmp; |
407 for (size_t i = 0; i < window_types->GetSize(); ++i) { | 418 for (size_t i = 0; i < window_types->GetSize(); ++i) { |
408 std::string window_type; | 419 std::string window_type; |
409 if (!window_types->GetString(i, &window_type)) { | 420 if (!window_types->GetString(i, &window_type)) { |
410 return Status(kUnknownError, "each window type must be a string"); | 421 return Status(kUnknownError, "each window type must be a string"); |
411 } | 422 } |
(...skipping 18 matching lines...) Expand all Loading... | |
430 bool is_remote = chrome_options->HasKey("debuggerAddress"); | 441 bool is_remote = chrome_options->HasKey("debuggerAddress"); |
431 | 442 |
432 std::map<std::string, Parser> parser_map; | 443 std::map<std::string, Parser> parser_map; |
433 // Ignore 'args', 'binary' and 'extensions' capabilities by default, since the | 444 // Ignore 'args', 'binary' and 'extensions' capabilities by default, since the |
434 // Java client always passes them. | 445 // Java client always passes them. |
435 parser_map["args"] = base::Bind(&IgnoreCapability); | 446 parser_map["args"] = base::Bind(&IgnoreCapability); |
436 parser_map["binary"] = base::Bind(&IgnoreCapability); | 447 parser_map["binary"] = base::Bind(&IgnoreCapability); |
437 parser_map["extensions"] = base::Bind(&IgnoreCapability); | 448 parser_map["extensions"] = base::Bind(&IgnoreCapability); |
438 | 449 |
439 parser_map["perfLoggingPrefs"] = base::Bind(&ParsePerfLoggingPrefs); | 450 parser_map["perfLoggingPrefs"] = base::Bind(&ParsePerfLoggingPrefs); |
451 parser_map["devToolsEventsToLog"] = base::Bind( | |
452 &ParseDevToolsEventsLoggingPrefs); | |
440 parser_map["windowTypes"] = base::Bind(&ParseWindowTypes); | 453 parser_map["windowTypes"] = base::Bind(&ParseWindowTypes); |
441 // Compliance is read when session is initialized and correct response is | 454 // Compliance is read when session is initialized and correct response is |
442 // sent if not parsed correctly. | 455 // sent if not parsed correctly. |
443 parser_map["w3c"] = base::Bind(&IgnoreCapability); | 456 parser_map["w3c"] = base::Bind(&IgnoreCapability); |
444 | 457 |
445 if (is_android) { | 458 if (is_android) { |
446 parser_map["androidActivity"] = | 459 parser_map["androidActivity"] = |
447 base::Bind(&ParseString, &capabilities->android_activity); | 460 base::Bind(&ParseString, &capabilities->android_activity); |
448 parser_map["androidDeviceSerial"] = | 461 parser_map["androidDeviceSerial"] = |
449 base::Bind(&ParseString, &capabilities->android_device_serial); | 462 base::Bind(&ParseString, &capabilities->android_device_serial); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 LoggingPrefs::const_iterator iter = logging_prefs.find( | 668 LoggingPrefs::const_iterator iter = logging_prefs.find( |
656 WebDriverLog::kPerformanceType); | 669 WebDriverLog::kPerformanceType); |
657 if (iter == logging_prefs.end() || iter->second == Log::kOff) { | 670 if (iter == logging_prefs.end() || iter->second == Log::kOff) { |
658 const base::DictionaryValue* chrome_options = NULL; | 671 const base::DictionaryValue* chrome_options = NULL; |
659 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && | 672 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && |
660 chrome_options->HasKey("perfLoggingPrefs")) { | 673 chrome_options->HasKey("perfLoggingPrefs")) { |
661 return Status(kUnknownError, "perfLoggingPrefs specified, " | 674 return Status(kUnknownError, "perfLoggingPrefs specified, " |
662 "but performance logging was not enabled"); | 675 "but performance logging was not enabled"); |
663 } | 676 } |
664 } | 677 } |
678 LoggingPrefs::const_iterator dt_events_logging_iter = logging_prefs.find( | |
679 WebDriverLog::kDevToolsType); | |
680 if (dt_events_logging_iter == logging_prefs.end() | |
681 || dt_events_logging_iter->second == Log::kOff) { | |
682 const base::DictionaryValue* chrome_options = NULL; | |
683 if (desired_caps.GetDictionary("chromeOptions", &chrome_options) && | |
684 chrome_options->HasKey("devToolsEventsToLog")) { | |
685 return Status(kUnknownError, "devToolsEventsToLog specified, " | |
686 "but devtools events logging was not enabled"); | |
687 } | |
688 } | |
665 return Status(kOk); | 689 return Status(kOk); |
666 } | 690 } |
OLD | NEW |