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

Side by Side Diff: chrome/test/automation/automation_json_requests.cc

Issue 7139001: In chromedriver, add /log url (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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
« no previous file with comments | « no previous file | chrome/test/webdriver/automation.cc » ('j') | chrome/test/webdriver/dispatch.cc » ('J')
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 "chrome/test/automation/automation_json_requests.h" 5 #include "chrome/test/automation/automation_json_requests.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 11 matching lines...) Expand all
22 22
23 bool SendAutomationJSONRequest(AutomationMessageSender* sender, 23 bool SendAutomationJSONRequest(AutomationMessageSender* sender,
24 const DictionaryValue& request_dict, 24 const DictionaryValue& request_dict,
25 DictionaryValue* reply_dict, 25 DictionaryValue* reply_dict,
26 std::string* error_msg) { 26 std::string* error_msg) {
27 std::string request, reply; 27 std::string request, reply;
28 base::JSONWriter::Write(&request_dict, false, &request); 28 base::JSONWriter::Write(&request_dict, false, &request);
29 bool success = false; 29 bool success = false;
30 int timeout_ms = TestTimeouts::action_max_timeout_ms(); 30 int timeout_ms = TestTimeouts::action_max_timeout_ms();
31 base::Time before_sending = base::Time::Now(); 31 base::Time before_sending = base::Time::Now();
32 std::string command;
33 request_dict.GetString("command", &command);
34 LOG(INFO) << "Sending '" << command << "' command.";
32 if (!SendAutomationJSONRequest( 35 if (!SendAutomationJSONRequest(
33 sender, request, timeout_ms, &reply, &success)) { 36 sender, request, timeout_ms, &reply, &success)) {
34 int64 elapsed_ms = (base::Time::Now() - before_sending).InMilliseconds(); 37 int64 elapsed_ms = (base::Time::Now() - before_sending).InMilliseconds();
35 std::string command;
36 request_dict.GetString("command", &command);
37 if (elapsed_ms >= timeout_ms) { 38 if (elapsed_ms >= timeout_ms) {
38 *error_msg = base::StringPrintf( 39 *error_msg = base::StringPrintf(
39 "Chrome did not respond to '%s'. Request may have timed out. " 40 "Chrome did not respond to '%s'. Request may have timed out. "
40 "Elapsed time was %" PRId64 " ms. Request timeout was %d ms. " 41 "Elapsed time was %" PRId64 " ms. Request timeout was %d ms. "
41 "Request details: (%s).", 42 "Request details: (%s).",
42 command.c_str(), 43 command.c_str(),
43 elapsed_ms, 44 elapsed_ms,
44 timeout_ms, 45 timeout_ms,
45 request.c_str()); 46 request.c_str());
46 } else { 47 } else {
47 *error_msg = base::StringPrintf( 48 *error_msg = base::StringPrintf(
48 "Chrome did not respond to '%s'. Elapsed time was %" PRId64 " ms. " 49 "Chrome did not respond to '%s'. Elapsed time was %" PRId64 " ms. "
49 "Request details: (%s).", 50 "Request details: (%s).",
50 command.c_str(), 51 command.c_str(),
51 elapsed_ms, 52 elapsed_ms,
52 request.c_str()); 53 request.c_str());
53 } 54 }
54 return false; 55 return false;
55 } 56 }
56 scoped_ptr<Value> value(base::JSONReader::Read(reply, true)); 57 scoped_ptr<Value> value(base::JSONReader::Read(reply, true));
57 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { 58 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) {
58 std::string command;
59 request_dict.GetString("command", &command);
60 LOG(ERROR) << "JSON request did not return dict: " << command << "\n"; 59 LOG(ERROR) << "JSON request did not return dict: " << command << "\n";
61 return false; 60 return false;
62 } 61 }
63 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 62 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
64 if (!success) { 63 if (!success) {
65 std::string command, error; 64 std::string error;
66 request_dict.GetString("command", &command);
67 dict->GetString("error", &error); 65 dict->GetString("error", &error);
68 *error_msg = base::StringPrintf( 66 *error_msg = base::StringPrintf(
69 "Internal Chrome error during '%s': (%s). Request details: (%s).", 67 "Internal Chrome error during '%s': (%s). Request details: (%s).",
70 command.c_str(), 68 command.c_str(),
71 error.c_str(), 69 error.c_str(),
72 request.c_str()); 70 request.c_str());
73 LOG(ERROR) << "JSON request failed: " << command << "\n" 71 LOG(ERROR) << "JSON request failed: " << command << "\n"
74 << " with error: " << error; 72 << " with error: " << error;
75 return false; 73 return false;
76 } 74 }
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 AutomationMessageSender* sender, 626 AutomationMessageSender* sender,
629 int* version, 627 int* version,
630 std::string* error_msg) { 628 std::string* error_msg) {
631 DictionaryValue dict; 629 DictionaryValue dict;
632 dict.SetString("command", "GetChromeDriverAutomationVersion"); 630 dict.SetString("command", "GetChromeDriverAutomationVersion");
633 DictionaryValue reply_dict; 631 DictionaryValue reply_dict;
634 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg)) 632 if (!SendAutomationJSONRequest(sender, dict, &reply_dict, error_msg))
635 return false; 633 return false;
636 return reply_dict.GetInteger("version", version); 634 return reply_dict.GetInteger("version", version);
637 } 635 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/webdriver/automation.cc » ('j') | chrome/test/webdriver/dispatch.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698