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