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

Side by Side Diff: chrome/test/automation/automation_proxy.h

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 #ifndef CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ 5 #ifndef CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_
6 #define CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ 6 #define CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // received or a timeout has expired. 42 // received or a timeout has expired.
43 // 43 //
44 // The function returns true if a response is received, and returns false if 44 // The function returns true if a response is received, and returns false if
45 // there is a failure or timeout (in milliseconds). 45 // there is a failure or timeout (in milliseconds).
46 // 46 //
47 // NOTE: When timeout occurs, the connection between proxy provider may be 47 // NOTE: When timeout occurs, the connection between proxy provider may be
48 // in transit state. Specifically, there might be pending IPC messages, 48 // in transit state. Specifically, there might be pending IPC messages,
49 // and the proxy provider might be still working on the previous 49 // and the proxy provider might be still working on the previous
50 // request. 50 // request.
51 virtual bool Send(IPC::Message* message) = 0; 51 virtual bool Send(IPC::Message* message) = 0;
52 virtual bool Send(IPC::Message* message, int timeout_ms) = 0;
52 }; 53 };
53 54
54 // This is the interface that external processes can use to interact with 55 // This is the interface that external processes can use to interact with
55 // a running instance of the app. 56 // a running instance of the app.
56 class AutomationProxy : public IPC::Channel::Listener, 57 class AutomationProxy : public IPC::Channel::Listener,
57 public AutomationMessageSender { 58 public AutomationMessageSender {
58 public: 59 public:
59 AutomationProxy(int command_execution_timeout_ms, bool disconnect_on_failure); 60 AutomationProxy(int action_timeout_ms, bool disconnect_on_failure);
60 virtual ~AutomationProxy(); 61 virtual ~AutomationProxy();
61 62
62 // Creates a previously unused channel id. 63 // Creates a previously unused channel id.
63 static std::string GenerateChannelID(); 64 static std::string GenerateChannelID();
64 65
65 // Initializes a channel for a connection to an AutomationProvider. 66 // Initializes a channel for a connection to an AutomationProvider.
66 // If use_named_interface is false, it will act as a client 67 // If use_named_interface is false, it will act as a client
67 // and connect to the named IPC socket with channel_id as its path. 68 // and connect to the named IPC socket with channel_id as its path.
68 // If use_named_interface is true, it will act as a server and 69 // If use_named_interface is true, it will act as a server and
69 // use an anonymous socketpair instead. 70 // use an anonymous socketpair instead.
70 void InitializeChannel(const std::string& channel_id, 71 void InitializeChannel(const std::string& channel_id,
71 bool use_named_interface); 72 bool use_named_interface);
72 73
73 // IPC callback 74 // IPC callback
74 virtual bool OnMessageReceived(const IPC::Message& msg); 75 virtual bool OnMessageReceived(const IPC::Message& msg);
75 virtual void OnChannelError(); 76 virtual void OnChannelError();
76 77
77 // Close the automation IPC channel. 78 // Close the automation IPC channel.
78 void Disconnect(); 79 void Disconnect();
79 80
80 // Waits for the app to launch and the automation provider to say hello 81 // Waits for the app to launch and the automation provider to say hello
81 // (the app isn't fully done loading by this point). 82 // (the app isn't fully done loading by this point).
82 // Returns SUCCESS if the launch is successful. 83 // Returns SUCCESS if the launch is successful.
83 // Returns TIMEOUT if there was no response by command_execution_timeout_ 84 // Returns TIMEOUT if there was no response by action_timeout_
84 // Returns VERSION_MISMATCH if the automation protocol version of the 85 // Returns VERSION_MISMATCH if the automation protocol version of the
85 // automation provider does not match and if perform_version_check_ is set 86 // automation provider does not match and if perform_version_check_ is set
86 // to true. Note that perform_version_check_ defaults to false, call 87 // to true. Note that perform_version_check_ defaults to false, call
87 // set_perform_version_check() to set it. 88 // set_perform_version_check() to set it.
88 AutomationLaunchResult WaitForAppLaunch(); 89 AutomationLaunchResult WaitForAppLaunch();
89 90
90 // See description in AutomationMsg_WaitForProcessLauncherThreadToGoIdle. 91 // See description in AutomationMsg_WaitForProcessLauncherThreadToGoIdle.
91 bool WaitForProcessLauncherThreadToGoIdle() WARN_UNUSED_RESULT; 92 bool WaitForProcessLauncherThreadToGoIdle() WARN_UNUSED_RESULT;
92 93
93 // Waits for any initial page loads to complete. 94 // Waits for any initial page loads to complete.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 bool with_ui); 205 bool with_ui);
205 206
206 // Asserts that the next extension test result is true. 207 // Asserts that the next extension test result is true.
207 void EnsureExtensionTestResult(); 208 void EnsureExtensionTestResult();
208 209
209 // Resets to the default theme. Returns true on success. 210 // Resets to the default theme. Returns true on success.
210 bool ResetToDefaultTheme(); 211 bool ResetToDefaultTheme();
211 212
212 // Generic pattern for sending automation requests. 213 // Generic pattern for sending automation requests.
213 bool SendJSONRequest(const std::string& request, 214 bool SendJSONRequest(const std::string& request,
215 int timeout_ms,
214 std::string* response) WARN_UNUSED_RESULT; 216 std::string* response) WARN_UNUSED_RESULT;
215 217
216 #if defined(OS_CHROMEOS) 218 #if defined(OS_CHROMEOS)
217 // Logs in through the Chrome OS login wizard with given |username| 219 // Logs in through the Chrome OS login wizard with given |username|
218 // and |password|. Returns true on success. 220 // and |password|. Returns true on success.
219 bool LoginWithUserAndPass(const std::string& username, 221 bool LoginWithUserAndPass(const std::string& username,
220 const std::string& password) WARN_UNUSED_RESULT; 222 const std::string& password) WARN_UNUSED_RESULT;
221 #endif 223 #endif
222 224
223 #if defined(OS_POSIX) 225 #if defined(OS_POSIX)
224 base::file_handle_mapping_vector fds_to_map() const; 226 base::file_handle_mapping_vector fds_to_map() const;
225 #endif 227 #endif
226 228
227 // AutomationMessageSender implementation. 229 // AutomationMessageSender implementation.
228 virtual bool Send(IPC::Message* message) WARN_UNUSED_RESULT; 230 virtual bool Send(IPC::Message* message) WARN_UNUSED_RESULT;
231 virtual bool Send(IPC::Message* message, int timeout_ms) WARN_UNUSED_RESULT;
229 232
230 // Wrapper over AutomationHandleTracker::InvalidateHandle. Receives the 233 // Wrapper over AutomationHandleTracker::InvalidateHandle. Receives the
231 // message from AutomationProxy, unpacks the messages and routes that call to 234 // message from AutomationProxy, unpacks the messages and routes that call to
232 // the tracker. 235 // the tracker.
233 virtual void InvalidateHandle(const IPC::Message& message); 236 virtual void InvalidateHandle(const IPC::Message& message);
234 237
235 // Creates a tab that can hosted in an external process. The function 238 // Creates a tab that can hosted in an external process. The function
236 // returns a TabProxy representing the tab as well as a window handle 239 // returns a TabProxy representing the tab as well as a window handle
237 // that can be reparented in another process. 240 // that can be reparented in another process.
238 scoped_refptr<TabProxy> CreateExternalTab( 241 scoped_refptr<TabProxy> CreateExternalTab(
239 const ExternalTabSettings& settings, 242 const ExternalTabSettings& settings,
240 gfx::NativeWindow* external_tab_container, 243 gfx::NativeWindow* external_tab_container,
241 gfx::NativeWindow* tab); 244 gfx::NativeWindow* tab);
242 245
243 int command_execution_timeout_ms() const { 246 int action_timeout_ms() const {
244 return static_cast<int>(command_execution_timeout_.InMilliseconds()); 247 return static_cast<int>(action_timeout_.InMilliseconds());
245 } 248 }
246 249
247 // Sets the timeout for subsequent automation calls. 250 // Sets the timeout for subsequent automation calls.
248 void set_command_execution_timeout_ms(int timeout_ms) { 251 void set_action_timeout_ms(int timeout_ms) {
249 DCHECK(timeout_ms <= 10 * 60 * 1000 ) << "10+ min of automation timeout " 252 DCHECK(timeout_ms <= 10 * 60 * 1000 ) << "10+ min of automation timeout "
250 "can make the test hang and be killed by buildbot"; 253 "can make the test hang and be killed by buildbot";
251 command_execution_timeout_ = base::TimeDelta::FromMilliseconds(timeout_ms); 254 action_timeout_ = base::TimeDelta::FromMilliseconds(timeout_ms);
252 } 255 }
253 256
254 // Returns the server version of the server connected. You may only call this 257 // Returns the server version of the server connected. You may only call this
255 // method after WaitForAppLaunch() has returned SUCCESS or VERSION_MISMATCH. 258 // method after WaitForAppLaunch() has returned SUCCESS or VERSION_MISMATCH.
256 // If you call it before this, the return value is undefined. 259 // If you call it before this, the return value is undefined.
257 std::string server_version() const { 260 std::string server_version() const {
258 return server_version_; 261 return server_version_;
259 } 262 }
260 263
261 // Call this while passing true to tell the automation proxy to perform 264 // Call this while passing true to tell the automation proxy to perform
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // the automation provider at connection time. Defaults to false, you can 299 // the automation provider at connection time. Defaults to false, you can
297 // set this to true if building the automation proxy into a module with 300 // set this to true if building the automation proxy into a module with
298 // a version resource. 301 // a version resource.
299 bool perform_version_check_; 302 bool perform_version_check_;
300 303
301 // If true, the proxy will disconnect the IPC channel on first failure 304 // If true, the proxy will disconnect the IPC channel on first failure
302 // to send an IPC message. This helps avoid long timeouts in tests. 305 // to send an IPC message. This helps avoid long timeouts in tests.
303 bool disconnect_on_failure_; 306 bool disconnect_on_failure_;
304 307
305 // Delay to let the browser execute the command. 308 // Delay to let the browser execute the command.
306 base::TimeDelta command_execution_timeout_; 309 base::TimeDelta action_timeout_;
307 310
308 base::PlatformThreadId listener_thread_id_; 311 base::PlatformThreadId listener_thread_id_;
309 312
310 DISALLOW_COPY_AND_ASSIGN(AutomationProxy); 313 DISALLOW_COPY_AND_ASSIGN(AutomationProxy);
311 }; 314 };
312 315
313 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_ 316 #endif // CHROME_TEST_AUTOMATION_AUTOMATION_PROXY_H_
OLDNEW
« no previous file with comments | « chrome/test/automation/automation_json_requests.cc ('k') | chrome/test/automation/automation_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698