OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ |
| 6 #define CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 |
| 12 class AutomationProxy; |
| 13 class UITestBase; |
| 14 |
| 15 // Subclass from this class to use a different implementation of AutomationProxy |
| 16 // or to use different channel IDs inside a class that derives from UITest. |
| 17 class ProxyLauncher { |
| 18 public: |
| 19 virtual ~ProxyLauncher() {} |
| 20 |
| 21 // Creates an automation proxy. |
| 22 virtual AutomationProxy* CreateAutomationProxy( |
| 23 int execution_timeout) const = 0; |
| 24 |
| 25 // Launches the browser if needed and establishes a connection |
| 26 // connection with it using the specified UITestBase. |
| 27 virtual void InitializeConnection(UITestBase* ui_test_base) const = 0; |
| 28 |
| 29 // Returns the automation proxy's channel with any prefixes prepended, |
| 30 // for passing as a command line parameter over to the browser. |
| 31 virtual std::string PrefixedChannelID() const = 0; |
| 32 }; |
| 33 |
| 34 // Uses an automation proxy that communicates over a named socket. |
| 35 // This is used if you want to connect an AutomationProxy |
| 36 // to a browser process that is already running. |
| 37 // The channel id of the proxy is a constant specified by kInterfacePath. |
| 38 class NamedProxyLauncher : public ProxyLauncher { |
| 39 public: |
| 40 // If launch_browser is true, launches Chrome with named interface enabled. |
| 41 // Otherwise, there should be an existing instance the proxy can connect to. |
| 42 NamedProxyLauncher(bool launch_browser, bool disconnect_on_failure); |
| 43 |
| 44 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout) const; |
| 45 virtual void InitializeConnection(UITestBase* ui_test_base) const; |
| 46 virtual std::string PrefixedChannelID() const; |
| 47 |
| 48 protected: |
| 49 std::string channel_id_; // Channel id of automation proxy. |
| 50 bool launch_browser_; // True if we should launch the browser too. |
| 51 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. |
| 52 |
| 53 private: |
| 54 DISALLOW_COPY_AND_ASSIGN(NamedProxyLauncher); |
| 55 }; |
| 56 |
| 57 // Uses an automation proxy that communicates over an anonymous socket. |
| 58 class AnonymousProxyLauncher : public ProxyLauncher { |
| 59 public: |
| 60 explicit AnonymousProxyLauncher(bool disconnect_on_failure); |
| 61 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout) const; |
| 62 virtual void InitializeConnection(UITestBase* ui_test_base) const; |
| 63 virtual std::string PrefixedChannelID() const; |
| 64 |
| 65 protected: |
| 66 std::string channel_id_; // Channel id of automation proxy. |
| 67 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. |
| 68 |
| 69 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(AnonymousProxyLauncher); |
| 71 }; |
| 72 |
| 73 #endif // CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ |
| 74 |
OLD | NEW |