| OLD | NEW |
| 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 // This file declares the C++ side of PyAuto, the python interface to | 5 // This file declares the C++ side of PyAuto, the python interface to |
| 6 // Chromium automation. It access Chromium's internals using Automation Proxy. | 6 // Chromium automation. It access Chromium's internals using Automation Proxy. |
| 7 | 7 |
| 8 #ifndef CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ | 8 #ifndef CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ |
| 9 #define CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ | 9 #define CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ |
| 10 #pragma once | 10 #pragma once |
| 11 | 11 |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/mac/scoped_nsautorelease_pool.h" | 13 #include "base/mac/scoped_nsautorelease_pool.h" |
| 14 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
| 15 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_test.h" |
| 16 #include "chrome/test/ui/ui_test_suite.h" | 16 #include "chrome/test/ui/ui_test_suite.h" |
| 17 | 17 |
| 18 // The C++ style guide forbids using default arguments but I'm taking the | 18 // The C++ style guide forbids using default arguments but I'm taking the |
| 19 // liberty of allowing it in this file. The sole purpose of this (and the | 19 // liberty of allowing it in this file. The sole purpose of this (and the |
| 20 // .cc) is to support the python interface, and default args are allowed in | 20 // .cc) is to support the python interface, and default args are allowed in |
| 21 // python. Strictly adhering to the guide here would mean having to re-define | 21 // python. Strictly adhering to the guide here would mean having to re-define |
| 22 // all methods in python just for the sake of providing default args. This | 22 // all methods in python just for the sake of providing default args. This |
| 23 // seems cumbersome and unwanted. | 23 // seems cumbersome and unwanted. |
| 24 | 24 |
| 25 // Test Suite for Pyauto tests. All one-time initializations go here. | 25 // Test Suite for Pyauto tests. All one-time initializations go here. |
| 26 class PyUITestSuiteBase : public UITestSuite { | 26 class PyUITestSuiteBase : public UITestSuite { |
| 27 public: | 27 public: |
| 28 PyUITestSuiteBase(int argc, char** argv); | 28 PyUITestSuiteBase(int argc, char** argv); |
| 29 ~PyUITestSuiteBase(); | 29 virtual ~PyUITestSuiteBase(); |
| 30 | 30 |
| 31 void Initialize(const FilePath& browser_dir); | 31 void InitializeWithPath(const FilePath& browser_dir); |
| 32 | 32 |
| 33 void SetCrSourceRoot(const FilePath& path); | 33 void SetCrSourceRoot(const FilePath& path); |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 base::mac::ScopedNSAutoreleasePool pool_; | 36 base::mac::ScopedNSAutoreleasePool pool_; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // The primary class that interfaces with Automation Proxy. | 39 // The primary class that interfaces with Automation Proxy. |
| 40 // This class is accessed from python using swig. | 40 // This class is accessed from python using swig. |
| 41 class PyUITestBase : public UITestBase { | 41 class PyUITestBase : public UITestBase { |
| 42 public: | 42 public: |
| 43 // Only public methods are accessible from swig. | 43 // Only public methods are accessible from swig. |
| 44 | 44 |
| 45 // Constructor. Lookup pyauto.py for doc on these args. | 45 // Constructor. Lookup pyauto.py for doc on these args. |
| 46 PyUITestBase(bool clear_profile, std::wstring homepage); | 46 PyUITestBase(bool clear_profile, std::wstring homepage); |
| 47 ~PyUITestBase(); | 47 virtual ~PyUITestBase(); |
| 48 | 48 |
| 49 // Initialize the setup. Should be called before launching the browser. | 49 // Initialize the setup. Should be called before launching the browser. |
| 50 // |browser_dir| is the path to dir containing chromium binaries. | 50 // |browser_dir| is the path to dir containing chromium binaries. |
| 51 void Initialize(const FilePath& browser_dir); | 51 void Initialize(const FilePath& browser_dir); |
| 52 | 52 |
| 53 void UseNamedChannelID(const std::string& named_channel_id) { | 53 void UseNamedChannelID(const std::string& named_channel_id) { |
| 54 named_channel_id_ = named_channel_id; | 54 named_channel_id_ = named_channel_id; |
| 55 launcher_.reset(CreateProxyLauncher()); | 55 launcher_.reset(CreateProxyLauncher()); |
| 56 } | 56 } |
| 57 | 57 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // This is necessary since python's unittest module creates instances of | 217 // This is necessary since python's unittest module creates instances of |
| 218 // TestCase at load time itself. | 218 // TestCase at load time itself. |
| 219 static MessageLoop* GetSharedMessageLoop(MessageLoop::Type msg_loop_type); | 219 static MessageLoop* GetSharedMessageLoop(MessageLoop::Type msg_loop_type); |
| 220 static MessageLoop* message_loop_; | 220 static MessageLoop* message_loop_; |
| 221 | 221 |
| 222 // Path to named channel id. | 222 // Path to named channel id. |
| 223 std::string named_channel_id_; | 223 std::string named_channel_id_; |
| 224 }; | 224 }; |
| 225 | 225 |
| 226 #endif // CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ | 226 #endif // CHROME_TEST_PYAUTOLIB_PYAUTOLIB_H_ |
| OLD | NEW |