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

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

Issue 6685099: Removing command_execution_timeout_ms in favor of action_max_timeout_ms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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) 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/file_path.h" 7 #include "base/file_path.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "base/test/test_timeouts.h"
12 #include "chrome/common/automation_messages.h" 13 #include "chrome/common/automation_messages.h"
13 #include "chrome/common/json_value_serializer.h" 14 #include "chrome/common/json_value_serializer.h"
14 #include "chrome/test/automation/automation_proxy.h" 15 #include "chrome/test/automation/automation_proxy.h"
15 16
16 namespace { 17 namespace {
17 18
18 bool SendAutomationJSONRequest(AutomationMessageSender* sender, 19 bool SendAutomationJSONRequest(AutomationMessageSender* sender,
19 const DictionaryValue& request_dict, 20 const DictionaryValue& request_dict,
20 DictionaryValue* reply_dict) { 21 DictionaryValue* reply_dict) {
21 std::string request, reply; 22 std::string request, reply;
22 base::JSONWriter::Write(&request_dict, false, &request); 23 base::JSONWriter::Write(&request_dict, false, &request);
23 bool success = false; 24 bool success = false;
24 if (!SendAutomationJSONRequest(sender, request, &reply, &success)) 25 if (!SendAutomationJSONRequest(sender, request,
26 TestTimeouts::action_max_timeout_ms(), &reply, &success))
Paweł Hajdan Jr. 2011/03/31 20:11:09 nit: I think this should be indented 4 more spaces
25 return false; 27 return false;
26 scoped_ptr<Value> value(base::JSONReader::Read(reply, true)); 28 scoped_ptr<Value> value(base::JSONReader::Read(reply, true));
27 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) { 29 if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) {
28 std::string command; 30 std::string command;
29 request_dict.GetString("command", &command); 31 request_dict.GetString("command", &command);
30 LOG(ERROR) << "JSON request did not return dict: " << command << "\n"; 32 LOG(ERROR) << "JSON request did not return dict: " << command << "\n";
31 return false; 33 return false;
32 } 34 }
33 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 35 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
34 if (!success) { 36 if (!success) {
(...skipping 16 matching lines...) Expand all
51 const std::string& modified_text, 53 const std::string& modified_text,
52 int modifiers) 54 int modifiers)
53 : type(type), 55 : type(type),
54 key_code(key_code), 56 key_code(key_code),
55 unmodified_text(unmodified_text), 57 unmodified_text(unmodified_text),
56 modified_text(modified_text), 58 modified_text(modified_text),
57 modifiers(modifiers) {} 59 modifiers(modifiers) {}
58 60
59 bool SendAutomationJSONRequest(AutomationMessageSender* sender, 61 bool SendAutomationJSONRequest(AutomationMessageSender* sender,
60 const std::string& request, 62 const std::string& request,
63 int timeout_ms,
61 std::string* reply, 64 std::string* reply,
62 bool* success) { 65 bool* success) {
63 return sender->Send(new AutomationMsg_SendJSONRequest( 66 return sender->Send(new AutomationMsg_SendJSONRequest(
64 -1, request, reply, success)); 67 -1, request, reply, success), timeout_ms);
65 } 68 }
66 69
67 bool SendGetIndicesFromTabIdJSONRequest( 70 bool SendGetIndicesFromTabIdJSONRequest(
68 AutomationMessageSender* sender, 71 AutomationMessageSender* sender,
69 int tab_id, 72 int tab_id,
70 int* browser_index, 73 int* browser_index,
71 int* tab_index) { 74 int* tab_index) {
72 DictionaryValue request_dict; 75 DictionaryValue request_dict;
73 request_dict.SetString("command", "GetIndicesFromTab"); 76 request_dict.SetString("command", "GetIndicesFromTab");
74 request_dict.SetInteger("tab_id", tab_id); 77 request_dict.SetInteger("tab_id", tab_id);
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 return SendAutomationJSONRequest(sender, dict, &reply_dict); 452 return SendAutomationJSONRequest(sender, dict, &reply_dict);
450 } 453 }
451 454
452 bool SendWaitForAllTabsToStopLoadingJSONRequest( 455 bool SendWaitForAllTabsToStopLoadingJSONRequest(
453 AutomationMessageSender* sender) { 456 AutomationMessageSender* sender) {
454 DictionaryValue dict; 457 DictionaryValue dict;
455 dict.SetString("command", "WaitForAllTabsToStopLoading"); 458 dict.SetString("command", "WaitForAllTabsToStopLoading");
456 DictionaryValue reply_dict; 459 DictionaryValue reply_dict;
457 return SendAutomationJSONRequest(sender, dict, &reply_dict); 460 return SendAutomationJSONRequest(sender, dict, &reply_dict);
458 } 461 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698