| OLD | NEW |
| 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/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/test/test_timeouts.h" |
| 11 #include "chrome/common/automation_messages.h" | 12 #include "chrome/common/automation_messages.h" |
| 12 #include "chrome/common/json_value_serializer.h" | 13 #include "chrome/common/json_value_serializer.h" |
| 13 #include "chrome/test/automation/automation_proxy.h" | 14 #include "chrome/test/automation/automation_proxy.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 bool SendAutomationJSONRequest(AutomationMessageSender* sender, | 18 bool SendAutomationJSONRequest(AutomationMessageSender* sender, |
| 18 const DictionaryValue& request_dict, | 19 const DictionaryValue& request_dict, |
| 19 DictionaryValue* reply_dict) { | 20 DictionaryValue* reply_dict) { |
| 20 std::string request, reply; | 21 std::string request, reply; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 : type(type), | 53 : type(type), |
| 53 key_code(key_code), | 54 key_code(key_code), |
| 54 unmodified_text(unmodified_text), | 55 unmodified_text(unmodified_text), |
| 55 modified_text(modified_text), | 56 modified_text(modified_text), |
| 56 modifiers(modifiers) {} | 57 modifiers(modifiers) {} |
| 57 | 58 |
| 58 bool SendAutomationJSONRequest(AutomationMessageSender* sender, | 59 bool SendAutomationJSONRequest(AutomationMessageSender* sender, |
| 59 const std::string& request, | 60 const std::string& request, |
| 60 std::string* reply, | 61 std::string* reply, |
| 61 bool* success) { | 62 bool* success) { |
| 63 return SendAutomationJSONRequest(sender, request, reply, success, |
| 64 TestTimeouts::action_max_timeout_ms()); |
| 65 } |
| 66 |
| 67 bool SendAutomationJSONRequest(AutomationMessageSender* sender, |
| 68 const std::string& request, |
| 69 std::string* reply, |
| 70 bool* success, |
| 71 int timeout) { |
| 62 return sender->Send(new AutomationMsg_SendJSONRequest( | 72 return sender->Send(new AutomationMsg_SendJSONRequest( |
| 63 -1, request, reply, success)); | 73 -1, request, reply, success), timeout); |
| 64 } | 74 } |
| 65 | 75 |
| 66 bool SendGetIndicesFromTabIdJSONRequest( | 76 bool SendGetIndicesFromTabIdJSONRequest( |
| 67 AutomationMessageSender* sender, | 77 AutomationMessageSender* sender, |
| 68 int tab_id, | 78 int tab_id, |
| 69 int* browser_index, | 79 int* browser_index, |
| 70 int* tab_index) { | 80 int* tab_index) { |
| 71 DictionaryValue request_dict; | 81 DictionaryValue request_dict; |
| 72 request_dict.SetString("command", "GetIndicesFromTab"); | 82 request_dict.SetString("command", "GetIndicesFromTab"); |
| 73 request_dict.SetInteger("tab_id", tab_id); | 83 request_dict.SetInteger("tab_id", tab_id); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 return SendAutomationJSONRequest(sender, dict, &reply_dict); | 399 return SendAutomationJSONRequest(sender, dict, &reply_dict); |
| 390 } | 400 } |
| 391 | 401 |
| 392 bool SendWaitForAllTabsToStopLoadingJSONRequest( | 402 bool SendWaitForAllTabsToStopLoadingJSONRequest( |
| 393 AutomationMessageSender* sender) { | 403 AutomationMessageSender* sender) { |
| 394 DictionaryValue dict; | 404 DictionaryValue dict; |
| 395 dict.SetString("command", "WaitForAllTabsToStopLoading"); | 405 dict.SetString("command", "WaitForAllTabsToStopLoading"); |
| 396 DictionaryValue reply_dict; | 406 DictionaryValue reply_dict; |
| 397 return SendAutomationJSONRequest(sender, dict, &reply_dict); | 407 return SendAutomationJSONRequest(sender, dict, &reply_dict); |
| 398 } | 408 } |
| OLD | NEW |