summaryrefslogtreecommitdiffstats
path: root/chrome/test/functional
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 00:52:49 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 00:52:49 +0000
commit7060bb292ea9e20cb0f45dadd1a2b06ef61bcc2f (patch)
tree4919709ddb82f03e87f7627f1a3b03ed1ce21af0 /chrome/test/functional
parent26199ae574cad50fa5ac8ab222daa60843d8308f (diff)
downloadchromium_src-7060bb292ea9e20cb0f45dadd1a2b06ef61bcc2f.zip
chromium_src-7060bb292ea9e20cb0f45dadd1a2b06ef61bcc2f.tar.gz
chromium_src-7060bb292ea9e20cb0f45dadd1a2b06ef61bcc2f.tar.bz2
Enable "get html from page" functionality for PyAuto.
BUG=36184 TEST=Run PyAuto's content.py and make sure it passes. Review URL: http://codereview.chromium.org/2861019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50678 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/functional')
-rw-r--r--chrome/test/functional/PYAUTO_TESTS1
-rw-r--r--chrome/test/functional/content.py92
2 files changed, 93 insertions, 0 deletions
diff --git a/chrome/test/functional/PYAUTO_TESTS b/chrome/test/functional/PYAUTO_TESTS
index 656f2b99..d512cd4 100644
--- a/chrome/test/functional/PYAUTO_TESTS
+++ b/chrome/test/functional/PYAUTO_TESTS
@@ -24,6 +24,7 @@
'bookmark_bar',
'bookmarks',
'browser',
+ 'content',
'downloads',
'history',
'navigation',
diff --git a/chrome/test/functional/content.py b/chrome/test/functional/content.py
new file mode 100644
index 0000000..8765cb8
--- /dev/null
+++ b/chrome/test/functional/content.py
@@ -0,0 +1,92 @@
+#!/usr/bin/python
+# 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.
+
+import os
+
+import pyauto_functional # Must be imported before pyauto
+import pyauto
+
+
+class ContentTest(pyauto.PyUITest):
+ """TestCase for getting html content from the browser."""
+
+ def _DataDirURL(self, filename):
+ """Return a URL in the data dir for the given filename."""
+ return self.GetFileURLForPath(os.path.join(self.DataDir(), filename))
+
+ def _StringContentCheck(self, content_string, have_list, nothave_list):
+ """Look for the presence or absence of strings in content.
+
+ Confirm all strings in have_list are found in content_string.
+ Confirm all strings in nothave_list are NOT found in content_string.
+ """
+ for s in have_list:
+ self.assertTrue(s in content_string)
+ for s in nothave_list:
+ self.assertTrue(s not in content_string)
+
+ def _FileContentCheck(self, filename, have_list, nothave_list):
+ """String check in local file.
+
+ For each local filename, tell the browser to load it as a file
+ UEL from the DataDir. Ask the browser for the loaded html.
+ Confirm all strings in have_list are found in it. Confirm all
+ strings in nothave_list are NOT found in it. Assumes only one
+ window/tab is open.
+ """
+ self.NavigateToURL(self._DataDirURL(filename))
+ self._StringContentCheck(self.GetTabContents(), have_list, nothave_list)
+
+ def testLocalFileBasics(self):
+ """For a few local files, do some basic has / not has."""
+ self._FileContentCheck('title1.html',
+ ['<html>', '</html>', 'page has no title'],
+ ['Title Of Awesomeness', '<b>'])
+ self._FileContentCheck('title2.html',
+ ['<html>', '</html>', 'Title Of Awesomeness'],
+ ['plastic flower', '<b>'])
+ self._FileContentCheck('title3.html',
+ ['<html>', '</html>', 'Title Of More Awesomeness'],
+ ['dinfidnfid', 'Title Of Awesomeness', '<b>'])
+
+ def testTwoTabs(self):
+ """Test content when we have 2 tabs."""
+ self.NavigateToURL(self._DataDirURL('title1.html'))
+ self.AppendTab(pyauto.GURL(self._DataDirURL('title2.html')), 0)
+ self._StringContentCheck(self.GetTabContents(0, 0),
+ ['page has no title'],
+ ['Awesomeness'])
+ self._StringContentCheck(self.GetTabContents(1, 0),
+ ['Awesomeness'],
+ ['page has no title'])
+
+ def testThreeWindows(self):
+ """Test content when we have 3 windows."""
+ self.NavigateToURL(self._DataDirURL('title1.html'))
+ for (window_index, url) in ((1, 'title2.html'), (2, 'title3.html')):
+ self.OpenNewBrowserWindow(True)
+ self.GetBrowserWindow(window_index).BringToFront()
+ self.NavigateToURL(self._DataDirURL(url), window_index, 0)
+
+ self._StringContentCheck(self.GetTabContents(0, 0),
+ ['page has no title'],
+ ['Awesomeness'])
+ self._StringContentCheck(self.GetTabContents(0, 1),
+ ['Awesomeness'],
+ ['page has no title'])
+ self._StringContentCheck(self.GetTabContents(0, 2),
+ ['Title Of More Awesomeness'],
+ ['page has no title'])
+
+ def testAboutVersion(self):
+ """Confirm about:version contains some expected content."""
+ self.NavigateToURL('about:version')
+ self._StringContentCheck(self.GetTabContents(),
+ ['User Agent', 'Command Line'],
+ ['odmomfodfm disfnodugdzuoufgbn ifdnf fif'])
+
+
+if __name__ == '__main__':
+ pyauto_functional.Main()