summaryrefslogtreecommitdiffstats
path: root/chrome/test/pyautolib/pyautolib.cc
diff options
context:
space:
mode:
authornirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 23:23:12 +0000
committernirnimesh@chromium.org <nirnimesh@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-21 23:23:12 +0000
commitc5647608aaf50455dc0b41b8e9f03e597589d76c (patch)
treec4ab2e971161e92188b1b8543a4d859c76586f52 /chrome/test/pyautolib/pyautolib.cc
parent9e42ad6261487d76b9336d7417361ee9de515adc (diff)
downloadchromium_src-c5647608aaf50455dc0b41b8e9f03e597589d76c.zip
chromium_src-c5647608aaf50455dc0b41b8e9f03e597589d76c.tar.gz
chromium_src-c5647608aaf50455dc0b41b8e9f03e597589d76c.tar.bz2
PyAuto: Python Interface to Chromium's Automation Proxy.
PyAuto is a python interface to chromium's automation framework. It exposes some of the Automation Proxy functions in Python. This can be used to play around with chromium, or automate functional tests. SWIG is used to bridge Automation Proxy's C++ to Python. This CL addresses Mac-only to begin with. I'll be adding win/linux shortly. Also, this CL breaks down UITest class into parts that does not use gtest (UITestBase) and parts that does (UITest). UITestBase is used by pyauto. BUG=32283 TEST=None Review URL: http://codereview.chromium.org/555022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/pyautolib/pyautolib.cc')
-rw-r--r--chrome/test/pyautolib/pyautolib.cc74
1 files changed, 74 insertions, 0 deletions
diff --git a/chrome/test/pyautolib/pyautolib.cc b/chrome/test/pyautolib/pyautolib.cc
new file mode 100644
index 0000000..a891e8e
--- /dev/null
+++ b/chrome/test/pyautolib/pyautolib.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/scoped_ptr.h"
+#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/test/pyautolib/pyautolib.h"
+#include "googleurl/src/gurl.h"
+
+PyUITestSuite::PyUITestSuite(int argc, char** argv)
+ : UITestSuite(argc, argv),
+ UITestBase() {
+ UITestSuite::Initialize();
+}
+
+PyUITestSuite::~PyUITestSuite() {
+ UITestSuite::Shutdown();
+}
+
+void PyUITestSuite::SetUp() {
+ UITestBase::SetUp();
+}
+
+void PyUITestSuite::TearDown() {
+ UITestBase::TearDown();
+}
+
+void PyUITestSuite::NavigateToURL(const char* url_string) {
+ GURL url(url_string);
+ UITestBase::NavigateToURL(url);
+}
+
+void PyUITestSuite::SetShelfVisible(bool is_visible) {
+ scoped_refptr<BrowserProxy> browser_proxy = automation()->GetBrowserWindow(0);
+ ASSERT_TRUE(browser_proxy.get());
+ EXPECT_TRUE(browser_proxy->SetShelfVisible(is_visible));
+}
+
+bool PyUITestSuite::IsShelfVisible() {
+ scoped_refptr<BrowserProxy> browser_proxy = automation()->GetBrowserWindow(0);
+ EXPECT_TRUE(browser_proxy.get());
+ if (!browser_proxy.get())
+ return false;
+ bool visible = false;
+ EXPECT_TRUE(browser_proxy->IsShelfVisible(&visible));
+ return visible;
+}
+
+std::wstring PyUITestSuite::GetActiveTabTitle() {
+ std::wstring title;
+ scoped_refptr<TabProxy> tab_proxy(GetActiveTab());
+ EXPECT_TRUE(tab_proxy.get());
+ if (!tab_proxy.get())
+ return title;
+ EXPECT_TRUE(tab_proxy->GetTabTitle(&title));
+ return title;
+}
+
+void PyUITestSuite::OpenFindInPage() {
+ scoped_refptr<BrowserProxy> browser_proxy = automation()->GetBrowserWindow(0);
+ ASSERT_TRUE(browser_proxy.get());
+ EXPECT_TRUE(browser_proxy->OpenFindInPage());
+}
+
+bool PyUITestSuite::IsFindInPageVisible() {
+ scoped_refptr<BrowserProxy> browser_proxy = automation()->GetBrowserWindow(0);
+ EXPECT_TRUE(browser_proxy.get());
+ if (!browser_proxy.get())
+ return false;
+ bool is_visible;
+ EXPECT_TRUE(browser_proxy->IsFindWindowFullyVisible(&is_visible));
+ return is_visible;
+}
+