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

Unified Diff: chrome/test/automation/proxy_launcher.h

Issue 5967003: Refactor UITestBase/ProxyLauncher. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Changes per Paweł's comments. Created 9 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/automation/proxy_launcher.h
diff --git a/chrome/test/automation/proxy_launcher.h b/chrome/test/automation/proxy_launcher.h
index 0f4d04dd8d93f0ff7832eb03a992c20109519a50..75e3f44b36b5aa82c7eeed612b71f710c888c802 100644
--- a/chrome/test/automation/proxy_launcher.h
+++ b/chrome/test/automation/proxy_launcher.h
@@ -8,6 +8,11 @@
#include <string>
#include "base/basictypes.h"
+#include "base/command_line.h"
+#include "base/process.h"
+#include "base/scoped_ptr.h"
+#include "base/scoped_temp_dir.h"
+#include "base/time.h"
class AutomationProxy;
class UITestBase;
@@ -16,8 +21,25 @@ class UITestBase;
// or to use different channel IDs inside a class that derives from UITest.
class ProxyLauncher {
public:
- ProxyLauncher() {}
- virtual ~ProxyLauncher() {}
+ // Profile theme type choices.
+ typedef enum {
Paweł Hajdan Jr. 2011/01/06 20:37:14 nit: Is the typedef needed? Just enum should be su
dtu 2011/01/07 01:46:17 Done.
+ DEFAULT_THEME = 0,
+ COMPLEX_THEME = 1,
+ NATIVE_THEME = 2,
+ CUSTOM_FRAME = 3,
+ CUSTOM_FRAME_NATIVE_THEME = 4,
+ } ProfileType;
+
+ // Different ways to quit the browser.
+ typedef enum {
+ WINDOW_CLOSE,
+ USER_QUIT,
+ SESSION_ENDING,
+ } ShutdownType;
+
+ ProxyLauncher();
+
+ virtual ~ProxyLauncher();
// Creates an automation proxy.
virtual AutomationProxy* CreateAutomationProxy(
@@ -25,13 +47,247 @@ class ProxyLauncher {
// Launches the browser if needed and establishes a connection
// connection with it using the specified UITestBase.
Nirnimesh 2011/01/06 22:56:45 Fix this comment. Don't need UITestBase here
dtu 2011/01/07 01:46:17 Done.
- virtual void InitializeConnection(UITestBase* ui_test_base) const = 0;
+ virtual void InitializeConnection(const CommandLine& arguments,
+ bool include_testing_id,
+ bool clear_profile,
+ FilePath& template_user_data,
+ ProfileType profile_type,
+ FilePath browser_directory,
+ bool show_window,
+ bool wait_for_initial_loads,
+ base::TimeTicks* launch_time,
+ base::ProcessHandle* process,
+ base::ProcessId* process_id) = 0;
// Returns the automation proxy's channel with any prefixes prepended,
// for passing as a command line parameter over to the browser.
virtual std::string PrefixedChannelID() const = 0;
+ // Launches the browser and IPC testing connection in server mode.
+ void LaunchBrowserAndServer(const CommandLine& arguments,
+ bool include_testing_id,
+ bool clear_profile,
+ FilePath& template_user_data,
+ ProfileType profile_type,
+ FilePath browser_directory,
+ bool show_window,
+ bool wait_for_initial_loads,
+ base::TimeTicks* launch_time,
+ base::ProcessHandle* process,
+ base::ProcessId* process_id);
+
+ // Launches the IPC testing connection in client mode,
+ // which then attempts to connect to a browser.
+ void ConnectToRunningBrowser(bool wait_for_initial_loads);
+
+ // Only for pyauto.
+ void set_command_execution_timeout_ms(int timeout);
+
+ // Closes the browser and IPC testing server.
+ void CloseBrowserAndServer(ShutdownType shutdown_type,
+ base::TimeDelta* quit_time,
+ base::ProcessHandle* process,
+ base::ProcessId* process_id);
+
+ // Launches the browser with the given command line.
+ // TODO(phajdan.jr): Make LaunchBrowser private. Tests should use
+ // LaunchAnotherBrowserBlockUntilClosed.
+ void LaunchBrowser(const CommandLine& arguments,
+ bool include_testing_id,
+ bool clear_profile,
+ FilePath& template_user_data,
+ ProfileType profile_type,
+ FilePath browser_directory,
+ bool show_window,
+ base::TimeTicks* launch_time,
+ base::ProcessHandle* process,
+ base::ProcessId* process_id);
+
+#if !defined(OS_MACOSX)
+ // This function is deliberately not defined on the Mac because re-using an
+ // existing browser process when launching from the command line isn't a
+ // concept that we support on the Mac; AppleEvents are the Mac solution for
+ // the same need. Any test based on this function doesn't apply to the Mac.
+
+ // Launches an another browser process and waits for it to finish. Returns
+ // true on success.
+ bool LaunchAnotherBrowserBlockUntilClosed(const CommandLine& cmdline,
+ bool include_testing_id,
+ FilePath browser_directory,
+ bool show_window,
+ base::TimeTicks* launch_time);
+#endif
+
+ // Exits out browser instance.
Nirnimesh 2011/01/06 22:56:45 s/out/our/
dtu 2011/01/07 01:46:17 Done.
+ void QuitBrowser(ShutdownType shutdown_type,
+ base::TimeDelta* quit_time,
+ base::ProcessHandle* process,
+ base::ProcessId* process_id);
+
+ // Terminates the browser, simulates end of session.
+ void TerminateBrowser(base::TimeDelta* quit_time,
+ base::ProcessHandle* process,
+ base::ProcessId* process_id);
+
+ // Check that no processes related to Chrome exist, displaying
+ // the given message if any do.
+ void AssertAppNotRunning(const std::wstring& error_message,
+ base::ProcessId process_id);
+
+ // Returns true when the browser process is running, independent if any
+ // renderer process exists or not. It will returns false if an user closed the
+ // window or if the browser process died by itself.
+ bool IsBrowserRunning(base::ProcessHandle process);
+
+ // Returns true when timeout_ms milliseconds have elapsed.
+ // Returns false if the browser process died while waiting.
+ bool CrashAwareSleep(base::ProcessHandle process, int timeout_ms);
+
+ // Wait for the browser process to shut down on its own (i.e. as a result of
+ // some action that your test has taken).
+ bool WaitForBrowserProcessToQuit(base::ProcessHandle process);
+
+ AutomationProxy* automation() const;
+
+ // Return the user data directory being used by the browser instance in
+ // UITest::SetUp().
Paweł Hajdan Jr. 2011/01/06 20:37:14 nit: Don't mention UITest::SetUp here. I think it
dtu 2011/01/07 01:46:17 Done.
+ FilePath user_data_dir() const;
+
+ void set_test_name(const std::string& name) {
+ test_name_ = name;
+ }
+
+ // Sets homepage_. Should be called before launching browser to have
+ // any effect.
+ void set_homepage(const std::string& homepage) {
+ homepage_ = homepage;
+ }
+
+ // Get/Set a flag to run the renderer in process when running the
+ // tests.
+ static bool in_process_renderer() { return in_process_renderer_; }
+ static void set_in_process_renderer(bool value) {
+ in_process_renderer_ = value;
+ }
+
+ // Get/Set a flag to run the renderer outside the sandbox when running the
+ // tests
+ static bool no_sandbox() { return no_sandbox_; }
+ static void set_no_sandbox(bool value) {
+ no_sandbox_ = value;
+ }
+
+ // Get/Set a flag to run with DCHECKs enabled in release.
+ static bool enable_dcheck() { return enable_dcheck_; }
+ static void set_enable_dcheck(bool value) {
+ enable_dcheck_ = value;
+ }
+
+ // Get/Set a flag to dump the process memory without crashing on DCHECKs.
+ static bool silent_dump_on_dcheck() { return silent_dump_on_dcheck_; }
+ static void set_silent_dump_on_dcheck(bool value) {
+ silent_dump_on_dcheck_ = value;
+ }
+
+ // Get/Set a flag to disable breakpad handling.
+ static bool disable_breakpad() { return disable_breakpad_; }
+ static void set_disable_breakpad(bool value) {
+ disable_breakpad_ = value;
+ }
+
+ // Get/Set a flag to run the plugin processes inside the sandbox when running
+ // the tests
+ static bool safe_plugins() { return safe_plugins_; }
+ static void set_safe_plugins(bool value) {
+ safe_plugins_ = value;
+ }
+
+ static bool show_error_dialogs() { return show_error_dialogs_; }
+ static void set_show_error_dialogs(bool value) {
+ show_error_dialogs_ = value;
+ }
+
+ static bool full_memory_dump() { return full_memory_dump_; }
+ static void set_full_memory_dump(bool value) {
+ full_memory_dump_ = value;
+ }
+
+ static bool dump_histograms_on_exit() { return dump_histograms_on_exit_; }
+ static void set_dump_histograms_on_exit(bool value) {
+ dump_histograms_on_exit_ = value;
+ }
+
+ static const std::string& js_flags() { return js_flags_; }
+ static void set_js_flags(const std::string& value) {
+ js_flags_ = value;
+ }
+
+ static const std::string& log_level() { return log_level_; }
+ static void set_log_level(const std::string& value) {
+ log_level_ = value;
+ }
+
+ protected:
+ virtual bool ShouldFilterInet() {
+ return true;
+ }
+
private:
+ void WaitForBrowserLaunch(bool wait_for_initial_loads);
+
+ // Prepare command line that will be used to launch the child browser process
+ // with an UI test.
Nirnimesh 2011/01/06 22:56:45 s/an/a/
dtu 2011/01/07 01:46:17 Done.
+ void PrepareTestCommandline(CommandLine* command_line,
+ bool include_testing_id);
+
+ bool LaunchBrowserHelper(const CommandLine& arguments,
+ bool include_testing_id,
+ FilePath browser_directory,
+ bool wait,
+ bool show_window,
+ base::TimeTicks* launch_time,
+ base::ProcessHandle* process);
+
+ // Wait a certain amount of time for all the app processes to exit,
+ // forcibly killing them if they haven't exited by then.
+ // It has the side-effect of killing every browser window opened in your
+ // session, even those unrelated in the test.
+ void CleanupAppProcesses(base::ProcessId process_id);
+
+ scoped_ptr<AutomationProxy> automation_proxy_;
+
+ // We use a temporary directory for profile to avoid issues with being
+ // unable to delete some files because they're in use, etc.
+ ScopedTempDir temp_profile_dir_;
+
+ // Name of currently running automeated test passed to Chrome process.
+ std::string test_name_;
Paweł Hajdan Jr. 2011/01/06 20:37:14 nit: Add empty line below.
dtu 2011/01/07 01:46:17 Done.
+ // Homepage used for testing.
+ std::string homepage_;
+
+ // True if we're in single process mode.
+ static bool in_process_renderer_;
Paweł Hajdan Jr. 2011/01/06 20:37:14 nit: Similarly here, separate the variables by emp
dtu 2011/01/07 01:46:17 Done.
+ // If true, runs the renderer outside the sandbox.
+ static bool no_sandbox_;
+ // If true, runs plugin processes inside the sandbox.
+ static bool safe_plugins_;
+ // If true, write full memory dump during crash.
+ static bool full_memory_dump_;
+ // If true, a user is paying attention to the test, so show error dialogs.
+ static bool show_error_dialogs_;
+ // Include histograms in log on exit.
+ static bool dump_histograms_on_exit_;
+ // Enable dchecks in release mode.
+ static bool enable_dcheck_;
+ // Dump process memory on dcheck without crashing.
+ static bool silent_dump_on_dcheck_;
+ // Disable breakpad on the browser.
+ static bool disable_breakpad_;
+ // Flags passed to the JS engine.
+ static std::string js_flags_;
+ // Logging level.
+ static std::string log_level_;
+
DISALLOW_COPY_AND_ASSIGN(ProxyLauncher);
};
@@ -46,7 +302,17 @@ class NamedProxyLauncher : public ProxyLauncher {
NamedProxyLauncher(bool launch_browser, bool disconnect_on_failure);
virtual AutomationProxy* CreateAutomationProxy(int execution_timeout);
- virtual void InitializeConnection(UITestBase* ui_test_base) const;
+ virtual void InitializeConnection(const CommandLine& arguments,
+ bool include_testing_id,
+ bool clear_profile,
+ FilePath& template_user_data,
+ ProfileType profile_type,
+ FilePath browser_directory,
+ bool show_window,
+ bool wait_for_initial_loads,
+ base::TimeTicks* launch_time,
+ base::ProcessHandle* process,
+ base::ProcessId* process_id);
virtual std::string PrefixedChannelID() const;
protected:
@@ -63,7 +329,17 @@ class AnonymousProxyLauncher : public ProxyLauncher {
public:
explicit AnonymousProxyLauncher(bool disconnect_on_failure);
virtual AutomationProxy* CreateAutomationProxy(int execution_timeout);
- virtual void InitializeConnection(UITestBase* ui_test_base) const;
+ virtual void InitializeConnection(const CommandLine& arguments,
+ bool include_testing_id,
+ bool clear_profile,
+ FilePath& template_user_data,
+ ProfileType profile_type,
+ FilePath browser_directory,
+ bool show_window,
+ bool wait_for_initial_loads,
+ base::TimeTicks* launch_time,
+ base::ProcessHandle* process,
+ base::ProcessId* process_id);
virtual std::string PrefixedChannelID() const;
protected:
@@ -75,4 +351,3 @@ class AnonymousProxyLauncher : public ProxyLauncher {
};
#endif // CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_
-

Powered by Google App Engine
This is Rietveld 408576698