[email protected] | 2a28e0b2 | 2011-02-03 21:49:03 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_TEST_WEBDRIVER_AUTOMATION_H_ |
| 6 | #define CHROME_TEST_WEBDRIVER_AUTOMATION_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/task.h" |
| 11 | #include "base/ref_counted.h" |
| 12 | #include "base/scoped_temp_dir.h" |
[email protected] | 2a28e0b2 | 2011-02-03 21:49:03 | [diff] [blame] | 13 | #include "chrome/test/ui/ui_test.h" |
| 14 | |
| 15 | namespace webdriver { |
| 16 | |
| 17 | // Creates and controls the Chrome instance. |
| 18 | // This class should be created and accessed on a single thread. |
| 19 | // TODO(phajdan.jr): Abstract UITestBase classes, see: |
| 20 | // http://code.google.com/p/chromium/issues/detail?id=56865 |
| 21 | class Automation : private UITestBase { |
| 22 | public: |
[email protected] | 808d103 | 2011-02-09 20:16:55 | [diff] [blame^] | 23 | Automation(); |
| 24 | virtual ~Automation(); |
[email protected] | 2a28e0b2 | 2011-02-03 21:49:03 | [diff] [blame] | 25 | |
| 26 | // Creates a browser. |
| 27 | void Init(bool* success); |
| 28 | |
| 29 | // Terminates this session and disconnects its automation proxy. After |
| 30 | // invoking this method, the Automation can safely be deleted. |
| 31 | void Terminate(); |
| 32 | |
| 33 | // Executes the given |script| in the specified frame of the current |
| 34 | // tab. |result| will be set to the JSON result. Returns true on success. |
| 35 | void ExecuteScript(const std::string& frame_xpath, |
| 36 | const std::string& script, |
| 37 | std::string* result, |
| 38 | bool* success); |
| 39 | |
| 40 | void NavigateToURL(const std::string& url, bool* success); |
| 41 | void GoForward(bool* success); |
| 42 | void GoBack(bool* success); |
| 43 | void Reload(bool* success); |
| 44 | void GetURL(std::string* url, bool* success); |
| 45 | void GetTabTitle(std::string* tab_title, bool* success); |
| 46 | |
| 47 | private: |
| 48 | scoped_refptr<BrowserProxy> browser_; |
| 49 | scoped_refptr<TabProxy> tab_; |
| 50 | |
| 51 | ScopedTempDir profile_dir_; |
| 52 | |
| 53 | DISALLOW_COPY_AND_ASSIGN(Automation); |
| 54 | }; |
| 55 | |
| 56 | } // namespace webdriver |
| 57 | |
| 58 | DISABLE_RUNNABLE_METHOD_REFCOUNT(webdriver::Automation); |
| 59 | |
| 60 | #endif // CHROME_TEST_WEBDRIVER_AUTOMATION_H_ |