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 ProxyLauncher() {} |
| 20 virtual ~ProxyLauncher() {} |
| 21 |
| 22 // Creates an automation proxy. |
| 23 virtual AutomationProxy* CreateAutomationProxy( |
| 24 int execution_timeout) = 0; |
| 25 |
| 26 // Launches the browser if needed and establishes a connection |
| 27 // connection with it using the specified UITestBase. |
| 28 virtual void InitializeConnection(UITestBase* ui_test_base) const = 0; |
| 29 |
| 30 // Returns the automation proxy's channel with any prefixes prepended, |
| 31 // for passing as a command line parameter over to the browser. |
| 32 virtual std::string PrefixedChannelID() const = 0; |
| 33 |
| 34 private: |
| 35 DISALLOW_COPY_AND_ASSIGN(ProxyLauncher); |
| 36 }; |
| 37 |
| 38 // Uses an automation proxy that communicates over a named socket. |
| 39 // This is used if you want to connect an AutomationProxy |
| 40 // to a browser process that is already running. |
| 41 // The channel id of the proxy is a constant specified by kInterfacePath. |
| 42 class NamedProxyLauncher : public ProxyLauncher { |
| 43 public: |
| 44 // If launch_browser is true, launches Chrome with named interface enabled. |
| 45 // Otherwise, there should be an existing instance the proxy can connect to. |
| 46 NamedProxyLauncher(bool launch_browser, bool disconnect_on_failure); |
| 47 |
| 48 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); |
| 49 virtual void InitializeConnection(UITestBase* ui_test_base) const; |
| 50 virtual std::string PrefixedChannelID() const; |
| 51 |
| 52 protected: |
| 53 std::string channel_id_; // Channel id of automation proxy. |
| 54 bool launch_browser_; // True if we should launch the browser too. |
| 55 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. |
| 56 |
| 57 private: |
| 58 DISALLOW_COPY_AND_ASSIGN(NamedProxyLauncher); |
| 59 }; |
| 60 |
| 61 // Uses an automation proxy that communicates over an anonymous socket. |
| 62 class AnonymousProxyLauncher : public ProxyLauncher { |
| 63 public: |
| 64 explicit AnonymousProxyLauncher(bool disconnect_on_failure); |
| 65 virtual AutomationProxy* CreateAutomationProxy(int execution_timeout); |
| 66 virtual void InitializeConnection(UITestBase* ui_test_base) const; |
| 67 virtual std::string PrefixedChannelID() const; |
| 68 |
| 69 protected: |
| 70 std::string channel_id_; // Channel id of automation proxy. |
| 71 bool disconnect_on_failure_; // True if we disconnect on IPC channel failure. |
| 72 |
| 73 private: |
| 74 DISALLOW_COPY_AND_ASSIGN(AnonymousProxyLauncher); |
| 75 }; |
| 76 |
| 77 #endif // CHROME_TEST_AUTOMATION_PROXY_LAUNCHER_H_ |
| 78 |
OLD | NEW |