Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: chrome/test/pyautolib/pyauto.py

Issue 5088001: Add pyauto hook for getting and manipulating the data underneath the NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/test/functional
Patch Set: Clean up Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """PyAuto: Python Interface to Chromium's Automation Proxy. 7 """PyAuto: Python Interface to Chromium's Automation Proxy.
8 8
9 PyAuto uses swig to expose Automation Proxy interfaces to Python. 9 PyAuto uses swig to expose Automation Proxy interfaces to Python.
10 For complete documentation on the functionality available, 10 For complete documentation on the functionality available,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 print >>sys.stderr, "Could not locate built libraries. Did you build?" 75 print >>sys.stderr, "Could not locate built libraries. Did you build?"
76 # Mac requires python2.5 even when not the default 'python' (e.g. 10.6) 76 # Mac requires python2.5 even when not the default 'python' (e.g. 10.6)
77 if 'darwin' == sys.platform and sys.version_info[:2] != (2,5): 77 if 'darwin' == sys.platform and sys.version_info[:2] != (2,5):
78 print >>sys.stderr, "*\n* Perhaps use 'python2.5', not 'python' ?\n*" 78 print >>sys.stderr, "*\n* Perhaps use 'python2.5', not 'python' ?\n*"
79 raise 79 raise
80 80
81 # Should go after sys.path is set appropriately 81 # Should go after sys.path is set appropriately
82 import bookmark_model 82 import bookmark_model
83 import download_info 83 import download_info
84 import history_info 84 import history_info
85 import ntp_model
85 import omnibox_info 86 import omnibox_info
86 import plugins_info 87 import plugins_info
87 import prefs_info 88 import prefs_info
88 from pyauto_errors import JSONInterfaceError 89 from pyauto_errors import JSONInterfaceError
89 import simplejson as json # found in third_party 90 import simplejson as json # found in third_party
90 91
91 92
92 class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): 93 class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
93 """Base class for UI Test Cases in Python. 94 """Base class for UI Test Cases in Python.
94 95
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 @staticmethod 191 @staticmethod
191 def GetFileURLForDataPath(relative_path): 192 def GetFileURLForDataPath(relative_path):
192 """Get file:// url for the given path relative to the chrome test data dir. 193 """Get file:// url for the given path relative to the chrome test data dir.
193 194
194 Also quotes the url using urllib.quote(). 195 Also quotes the url using urllib.quote().
195 """ 196 """
196 return PyUITest.GetFileURLForPath( 197 return PyUITest.GetFileURLForPath(
197 os.path.join(PyUITest.DataDir(), relative_path)) 198 os.path.join(PyUITest.DataDir(), relative_path))
198 199
199 @staticmethod 200 @staticmethod
201 def GetFileURLForDataPath(relative_path):
Nirnimesh 2010/11/16 22:25:05 this function is duplicate
202 """Get file:// url for the given path relative to the chrome test data dir.
203
204 Also quotes the url using urllib.quote().
205 """
206 return PyUITest.GetFileURLForPath(
207 os.path.join(PyUITest.DataDir(), relative_path))
208
209 @staticmethod
200 def IsMac(): 210 def IsMac():
201 """Are we on Mac?""" 211 """Are we on Mac?"""
202 return 'darwin' == sys.platform 212 return 'darwin' == sys.platform
203 213
204 @staticmethod 214 @staticmethod
205 def IsLinux(): 215 def IsLinux():
206 """Are we on Linux? ChromeOS is linux too.""" 216 """Are we on Linux? ChromeOS is linux too."""
207 return 'linux2' == sys.platform 217 return 'linux2' == sys.platform
208 218
209 @staticmethod 219 @staticmethod
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 1779
1770 Raises: 1780 Raises:
1771 pyauto_errors.JSONInterfaceError if the automation call returns an error. 1781 pyauto_errors.JSONInterfaceError if the automation call returns an error.
1772 """ 1782 """
1773 cmd_dict = { 1783 cmd_dict = {
1774 'command': 'DisableSyncForDatatypes', 1784 'command': 'DisableSyncForDatatypes',
1775 'datatypes': datatypes, 1785 'datatypes': datatypes,
1776 } 1786 }
1777 return self._GetResultFromJSONRequest(cmd_dict)['success'] 1787 return self._GetResultFromJSONRequest(cmd_dict)['success']
1778 1788
1789 def GetNTPModel(self):
1790 """Returns the NTPModel."""
1791 return ntp_model.NTPModel(self)
1792
1793
1779 class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite): 1794 class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite):
1780 """Base TestSuite for PyAuto UI tests.""" 1795 """Base TestSuite for PyAuto UI tests."""
1781 1796
1782 def __init__(self, args): 1797 def __init__(self, args):
1783 pyautolib.PyUITestSuiteBase.__init__(self, args) 1798 pyautolib.PyUITestSuiteBase.__init__(self, args)
1784 1799
1785 # Figure out path to chromium binaries 1800 # Figure out path to chromium binaries
1786 browser_dir = os.path.normpath(os.path.dirname(pyautolib.__file__)) 1801 browser_dir = os.path.normpath(os.path.dirname(pyautolib.__file__))
1787 logging.debug('Loading pyauto libs from %s', browser_dir) 1802 logging.debug('Loading pyauto libs from %s', browser_dir)
1788 self.Initialize(pyautolib.FilePath(browser_dir)) 1803 self.Initialize(pyautolib.FilePath(browser_dir))
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 if self._options.verbose: 2092 if self._options.verbose:
2078 verbosity = 2 2093 verbosity = 2
2079 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) 2094 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite)
2080 del loaded_tests # Need to destroy test cases before the suite 2095 del loaded_tests # Need to destroy test cases before the suite
2081 del pyauto_suite 2096 del pyauto_suite
2082 sys.exit(not result.wasSuccessful()) 2097 sys.exit(not result.wasSuccessful())
2083 2098
2084 2099
2085 if __name__ == '__main__': 2100 if __name__ == '__main__':
2086 Main() 2101 Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698