Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/chromedriver/commands.h" | 5 #include "chrome/test/chromedriver/commands.h" |
| 6 | 6 |
| 7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
| 8 #include "base/sys_info.h" | 8 #include "base/sys_info.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/test/chromedriver/capabilities.h" | 10 #include "chrome/test/chromedriver/capabilities.h" |
| 11 #include "chrome/test/chromedriver/chrome/chrome.h" | 11 #include "chrome/test/chromedriver/chrome/chrome.h" |
| 12 #include "chrome/test/chromedriver/chrome/chrome_android_impl.h" | 12 #include "chrome/test/chromedriver/chrome/chrome_android_impl.h" |
| 13 #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h" | 13 #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h" |
| 14 #include "chrome/test/chromedriver/chrome/devtools_event_logger.h" | |
| 14 #include "chrome/test/chromedriver/chrome/status.h" | 15 #include "chrome/test/chromedriver/chrome/status.h" |
| 15 #include "chrome/test/chromedriver/chrome/version.h" | 16 #include "chrome/test/chromedriver/chrome/version.h" |
| 16 #include "chrome/test/chromedriver/chrome/web_view.h" | 17 #include "chrome/test/chromedriver/chrome/web_view.h" |
| 17 #include "chrome/test/chromedriver/chrome_launcher.h" | 18 #include "chrome/test/chromedriver/chrome_launcher.h" |
| 19 #include "chrome/test/chromedriver/logging.h" | |
| 18 #include "chrome/test/chromedriver/net/net_util.h" | 20 #include "chrome/test/chromedriver/net/net_util.h" |
| 19 #include "chrome/test/chromedriver/net/url_request_context_getter.h" | 21 #include "chrome/test/chromedriver/net/url_request_context_getter.h" |
| 20 #include "chrome/test/chromedriver/session.h" | 22 #include "chrome/test/chromedriver/session.h" |
| 21 #include "chrome/test/chromedriver/session_map.h" | 23 #include "chrome/test/chromedriver/session_map.h" |
| 22 #include "chrome/test/chromedriver/util.h" | 24 #include "chrome/test/chromedriver/util.h" |
| 23 | 25 |
| 24 Status ExecuteGetStatus( | 26 Status ExecuteGetStatus( |
| 25 const base::DictionaryValue& params, | 27 const base::DictionaryValue& params, |
| 26 const std::string& session_id, | 28 const std::string& session_id, |
| 27 scoped_ptr<base::Value>* out_value, | 29 scoped_ptr<base::Value>* out_value, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 55 | 57 |
| 56 const base::DictionaryValue* desired_caps; | 58 const base::DictionaryValue* desired_caps; |
| 57 if (!params.GetDictionary("desiredCapabilities", &desired_caps)) | 59 if (!params.GetDictionary("desiredCapabilities", &desired_caps)) |
| 58 return Status(kUnknownError, "cannot find dict 'desiredCapabilities'"); | 60 return Status(kUnknownError, "cannot find dict 'desiredCapabilities'"); |
| 59 | 61 |
| 60 Capabilities capabilities; | 62 Capabilities capabilities; |
| 61 Status status = capabilities.Parse(*desired_caps); | 63 Status status = capabilities.Parse(*desired_caps); |
| 62 if (status.IsError()) | 64 if (status.IsError()) |
| 63 return status; | 65 return status; |
| 64 | 66 |
| 67 // Create DevToolsEventLoggers, fail if log levels are invalid. | |
| 68 ScopedVector<DevToolsEventLogger> devtools_event_loggers; | |
| 69 status = CreateLoggers(capabilities, &devtools_event_loggers); | |
| 70 if (!status.IsOk()) { | |
| 71 return status; | |
| 72 } | |
| 73 | |
| 65 scoped_ptr<Chrome> chrome; | 74 scoped_ptr<Chrome> chrome; |
| 75 std::list<DevToolsEventLogger*> devtools_event_logger_list( | |
| 76 devtools_event_loggers.begin(), devtools_event_loggers.end()); | |
| 66 status = LaunchChrome(context_getter, port, socket_factory, | 77 status = LaunchChrome(context_getter, port, socket_factory, |
| 67 capabilities, &chrome); | 78 capabilities, devtools_event_logger_list, &chrome); |
| 68 if (status.IsError()) | 79 if (status.IsError()) |
| 69 return status; | 80 return status; |
| 70 | 81 |
| 82 /* KLM REMOVE BEFORE SUBMISSION | |
|
kkania
2013/04/18 17:34:39
whoops
klm
2013/04/18 19:11:31
Done.
| |
| 83 // Add DevToolsEventLoggers to Chrome before DevToolsClients get created. | |
| 84 for (ScopedVector<DevToolsEventLogger>::const_iterator logger = | |
| 85 devtools_event_loggers.begin(); | |
| 86 logger != devtools_event_loggers.end(); ++logger) { | |
| 87 devtools_event_logger_list.push_back(*logger); | |
| 88 } | |
| 89 */ | |
| 90 | |
| 71 std::list<std::string> web_view_ids; | 91 std::list<std::string> web_view_ids; |
| 72 status = chrome->GetWebViewIds(&web_view_ids); | 92 status = chrome->GetWebViewIds(&web_view_ids); |
| 73 if (status.IsError() || web_view_ids.empty()) { | 93 if (status.IsError() || web_view_ids.empty()) { |
| 74 chrome->Quit(); | 94 chrome->Quit(); |
| 75 return status.IsError() ? status : | 95 return status.IsError() ? status : |
| 76 Status(kUnknownError, "unable to discover open window in chrome"); | 96 Status(kUnknownError, "unable to discover open window in chrome"); |
| 77 } | 97 } |
| 78 | 98 |
| 79 std::string new_id = session_id; | 99 std::string new_id = session_id; |
| 80 if (new_id.empty()) | 100 if (new_id.empty()) |
| 81 new_id = GenerateId(); | 101 new_id = GenerateId(); |
| 82 scoped_ptr<Session> session(new Session(new_id, chrome.Pass())); | 102 scoped_ptr<Session> session(new Session(new_id, chrome.Pass())); |
| 103 session->devtools_event_loggers.swap(devtools_event_loggers); | |
| 83 if (!session->thread.Start()) { | 104 if (!session->thread.Start()) { |
| 84 chrome->Quit(); | 105 chrome->Quit(); |
| 85 return Status(kUnknownError, | 106 return Status(kUnknownError, |
| 86 "failed to start a thread for the new session"); | 107 "failed to start a thread for the new session"); |
| 87 } | 108 } |
| 88 session->window = web_view_ids.front(); | 109 session->window = web_view_ids.front(); |
| 89 out_value->reset(session->capabilities->DeepCopy()); | 110 out_value->reset(session->capabilities->DeepCopy()); |
| 90 *out_session_id = new_id; | 111 *out_session_id = new_id; |
| 91 | 112 |
| 92 scoped_refptr<SessionAccessor> accessor( | 113 scoped_refptr<SessionAccessor> accessor( |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 105 std::string* out_session_id) { | 126 std::string* out_session_id) { |
| 106 std::vector<std::string> session_ids; | 127 std::vector<std::string> session_ids; |
| 107 session_map->GetKeys(&session_ids); | 128 session_map->GetKeys(&session_ids); |
| 108 for (size_t i = 0; i < session_ids.size(); ++i) { | 129 for (size_t i = 0; i < session_ids.size(); ++i) { |
| 109 scoped_ptr<base::Value> unused_value; | 130 scoped_ptr<base::Value> unused_value; |
| 110 std::string unused_session_id; | 131 std::string unused_session_id; |
| 111 quit_command.Run(params, session_ids[i], &unused_value, &unused_session_id); | 132 quit_command.Run(params, session_ids[i], &unused_value, &unused_session_id); |
| 112 } | 133 } |
| 113 return Status(kOk); | 134 return Status(kOk); |
| 114 } | 135 } |
| OLD | NEW |