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

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

Issue 10787010: Switch to TimeDelta interfaces in chrome automation test infrastructure. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase onto master. Created 8 years, 5 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
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_PROXY_LAUNCHER_H_ 5 #ifndef CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_
6 #define CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ 6 #define CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // Terminates the browser, simulates end of session. 98 // Terminates the browser, simulates end of session.
99 void TerminateBrowser(); 99 void TerminateBrowser();
100 100
101 // Check that no processes related to Chrome exist, displaying 101 // Check that no processes related to Chrome exist, displaying
102 // the given message if any do. 102 // the given message if any do.
103 void AssertAppNotRunning(const std::string& error_message); 103 void AssertAppNotRunning(const std::string& error_message);
104 104
105 // Wait for the browser process to shut down on its own (i.e. as a result of 105 // Wait for the browser process to shut down on its own (i.e. as a result of
106 // some action that your test has taken). If it has exited within |timeout|, 106 // some action that your test has taken). If it has exited within |timeout|,
107 // puts the exit code in |exit_code| and returns true. 107 // puts the exit code in |exit_code| and returns true.
108 bool WaitForBrowserProcessToQuit(int timeout, int* exit_code); 108 bool WaitForBrowserProcessToQuit(base::TimeDelta timeout, int* exit_code);
109 109
110 AutomationProxy* automation() const; 110 AutomationProxy* automation() const;
111 111
112 // Return the user data directory being used by the browser instance. 112 // Return the user data directory being used by the browser instance.
113 FilePath user_data_dir() const; 113 FilePath user_data_dir() const;
114 114
115 // Get the handle of browser process connected to the automation. This 115 // Get the handle of browser process connected to the automation. This
116 // function only returns a reference to the handle so the caller does not 116 // function only returns a reference to the handle so the caller does not
117 // own the handle returned. 117 // own the handle returned.
118 base::ProcessHandle process() const; 118 base::ProcessHandle process() const;
119 119
120 // Return the process id of the browser process (-1 on error). 120 // Return the process id of the browser process (-1 on error).
121 base::ProcessId process_id() const; 121 base::ProcessId process_id() const;
122 122
123 // Return the time when the browser was run. 123 // Return the time when the browser was run.
124 base::TimeTicks browser_launch_time() const; 124 base::TimeTicks browser_launch_time() const;
125 125
126 // Return how long the shutdown took. 126 // Return how long the shutdown took.
127 base::TimeDelta browser_quit_time() const; 127 base::TimeDelta browser_quit_time() const;
128 128
129 // Sets the shutdown type, which defaults to WINDOW_CLOSE. 129 // Sets the shutdown type, which defaults to WINDOW_CLOSE.
130 void set_shutdown_type(ShutdownType value) { 130 void set_shutdown_type(ShutdownType value) {
131 shutdown_type_ = value; 131 shutdown_type_ = value;
132 } 132 }
133 133
134 protected: 134 protected:
135 // Creates an automation proxy. 135 // Creates an automation proxy.
136 virtual AutomationProxy* CreateAutomationProxy( 136 virtual AutomationProxy* CreateAutomationProxy(
137 int execution_timeout) = 0; 137 base::TimeDelta execution_timeout) = 0;
138 138
139 // Returns the automation proxy's channel with any prefixes prepended, 139 // Returns the automation proxy's channel with any prefixes prepended,
140 // for passing as a command line parameter over to the browser. 140 // for passing as a command line parameter over to the browser.
141 virtual std::string PrefixedChannelID() const = 0; 141 virtual std::string PrefixedChannelID() const = 0;
142 142
143 // Paired with ConnectToRunningBrowser(). 143 // Paired with ConnectToRunningBrowser().
144 // Disconnects the testing IPC from the browser. 144 // Disconnects the testing IPC from the browser.
145 void DisconnectFromRunningBrowser(); 145 void DisconnectFromRunningBrowser();
146 146
147 private: 147 private:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // This is used if you want to connect an AutomationProxy 211 // This is used if you want to connect an AutomationProxy
212 // to a browser process that is already running. 212 // to a browser process that is already running.
213 // The channel id of the proxy is a constant specified by kInterfacePath. 213 // The channel id of the proxy is a constant specified by kInterfacePath.
214 class NamedProxyLauncher : public ProxyLauncher { 214 class NamedProxyLauncher : public ProxyLauncher {
215 public: 215 public:
216 // If launch_browser is true, launches Chrome with named interface enabled. 216 // If launch_browser is true, launches Chrome with named interface enabled.
217 // Otherwise, there should be an existing instance the proxy can connect to. 217 // Otherwise, there should be an existing instance the proxy can connect to.
218 NamedProxyLauncher(const std::string& channel_id, 218 NamedProxyLauncher(const std::string& channel_id,
219 bool launch_browser, bool disconnect_on_failure); 219 bool launch_browser, bool disconnect_on_failure);
220 220
221 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); 221 virtual AutomationProxy* CreateAutomationProxy(
222 base::TimeDelta execution_timeout);
222 virtual bool InitializeConnection( 223 virtual bool InitializeConnection(
223 const LaunchState& state, 224 const LaunchState& state,
224 bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT; 225 bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT;
225 virtual void TerminateConnection(); 226 virtual void TerminateConnection();
226 virtual std::string PrefixedChannelID() const; 227 virtual std::string PrefixedChannelID() const;
227 228
228 protected: 229 protected:
229 std::string channel_id_; // Channel id of automation proxy. 230 std::string channel_id_; // Channel id of automation proxy.
230 bool launch_browser_; // True if we should launch the browser too. 231 bool launch_browser_; // True if we should launch the browser too.
231 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. 232 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure.
232 233
233 private: 234 private:
234 DISALLOW_COPY_AND_ASSIGN(NamedProxyLauncher); 235 DISALLOW_COPY_AND_ASSIGN(NamedProxyLauncher);
235 }; 236 };
236 237
237 // Uses an automation proxy that communicates over an anonymous socket. 238 // Uses an automation proxy that communicates over an anonymous socket.
238 class AnonymousProxyLauncher : public ProxyLauncher { 239 class AnonymousProxyLauncher : public ProxyLauncher {
239 public: 240 public:
240 explicit AnonymousProxyLauncher(bool disconnect_on_failure); 241 explicit AnonymousProxyLauncher(bool disconnect_on_failure);
241 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); 242 virtual AutomationProxy* CreateAutomationProxy(
243 base::TimeDelta execution_timeout);
242 virtual bool InitializeConnection( 244 virtual bool InitializeConnection(
243 const LaunchState& state, 245 const LaunchState& state,
244 bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT; 246 bool wait_for_initial_loads) OVERRIDE WARN_UNUSED_RESULT;
245 virtual void TerminateConnection(); 247 virtual void TerminateConnection();
246 virtual std::string PrefixedChannelID() const; 248 virtual std::string PrefixedChannelID() const;
247 249
248 protected: 250 protected:
249 std::string channel_id_; // Channel id of automation proxy. 251 std::string channel_id_; // Channel id of automation proxy.
250 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. 252 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure.
251 253
252 private: 254 private:
253 DISALLOW_COPY_AND_ASSIGN(AnonymousProxyLauncher); 255 DISALLOW_COPY_AND_ASSIGN(AnonymousProxyLauncher);
254 }; 256 };
255 257
256 #endif // CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ 258 #endif // CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_
OLDNEW
« no previous file with comments | « chrome/test/automation/javascript_execution_controller.h ('k') | chrome/test/automation/proxy_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698