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

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

Issue 3477001: Add pyauto hook for getting and manipulating the data underneath the NTP.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months 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
« no previous file with comments | « chrome/test/pyautolib/ntp_model.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 print >>sys.stderr, "Could not locate built libraries. Did you build?" 73 print >>sys.stderr, "Could not locate built libraries. Did you build?"
74 # Mac requires python2.5 even when not the default 'python' (e.g. 10.6) 74 # Mac requires python2.5 even when not the default 'python' (e.g. 10.6)
75 if 'darwin' == sys.platform and sys.version_info[:2] != (2,5): 75 if 'darwin' == sys.platform and sys.version_info[:2] != (2,5):
76 print >>sys.stderr, "*\n* Perhaps use 'python2.5', not 'python' ?\n*" 76 print >>sys.stderr, "*\n* Perhaps use 'python2.5', not 'python' ?\n*"
77 raise 77 raise
78 78
79 # Should go after sys.path is set appropriately 79 # Should go after sys.path is set appropriately
80 import bookmark_model 80 import bookmark_model
81 import download_info 81 import download_info
82 import history_info 82 import history_info
83 import ntp_model
83 import omnibox_info 84 import omnibox_info
84 import plugins_info 85 import plugins_info
85 import prefs_info 86 import prefs_info
86 from pyauto_errors import JSONInterfaceError 87 from pyauto_errors import JSONInterfaceError
87 import simplejson as json # found in third_party 88 import simplejson as json # found in third_party
88 89
89 90
90 class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): 91 class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
91 """Base class for UI Test Cases in Python. 92 """Base class for UI Test Cases in Python.
92 93
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 # Don't quote the ':' in drive letter ( say, C: ) on win. 180 # Don't quote the ':' in drive letter ( say, C: ) on win.
180 # Also, replace '\' with '/' as expected in a file:/// url. 181 # Also, replace '\' with '/' as expected in a file:/// url.
181 drive, rest = os.path.splitdrive(abs_path) 182 drive, rest = os.path.splitdrive(abs_path)
182 quoted_path = drive.upper() + urllib.quote((rest.replace('\\', '/'))) 183 quoted_path = drive.upper() + urllib.quote((rest.replace('\\', '/')))
183 return 'file:///' + quoted_path 184 return 'file:///' + quoted_path
184 else: 185 else:
185 quoted_path = urllib.quote(abs_path) 186 quoted_path = urllib.quote(abs_path)
186 return 'file://' + quoted_path 187 return 'file://' + quoted_path
187 188
188 @staticmethod 189 @staticmethod
190 def GetFileURLForDataPath(relative_path):
191 """Get file:// url for the given path relative to the chrome test data dir.
192
193 Also quotes the url using urllib.quote().
194 """
195 return PyUITest.GetFileURLForPath(
196 os.path.join(PyUITest.DataDir(), relative_path))
197
198 @staticmethod
189 def IsMac(): 199 def IsMac():
190 """Are we on Mac?""" 200 """Are we on Mac?"""
191 return 'darwin' == sys.platform 201 return 'darwin' == sys.platform
192 202
193 @staticmethod 203 @staticmethod
194 def IsLinux(): 204 def IsLinux():
195 """Are we on Linux? ChromeOS is linux too.""" 205 """Are we on Linux? ChromeOS is linux too."""
196 return 'linux2' == sys.platform 206 return 'linux2' == sys.platform
197 207
198 @staticmethod 208 @staticmethod
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 u'tints': {u'buttons': [0.33000000000000002, 0.5, 0.46999999999999997]}} 1386 u'tints': {u'buttons': [0.33000000000000002, 0.5, 0.46999999999999997]}}
1377 1387
1378 Raises: 1388 Raises:
1379 pyauto_errors.JSONInterfaceError if the automation call returns an error. 1389 pyauto_errors.JSONInterfaceError if the automation call returns an error.
1380 """ 1390 """
1381 cmd_dict = { 1391 cmd_dict = {
1382 'command': 'GetThemeInfo', 1392 'command': 'GetThemeInfo',
1383 } 1393 }
1384 return self._GetResultFromJSONRequest(cmd_dict) 1394 return self._GetResultFromJSONRequest(cmd_dict)
1385 1395
1396 def GetNTPModel(self):
1397 """Returns the NTPModel."""
1398 return ntp_model.NTPModel(self)
1386 1399
1387 class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite): 1400 class PyUITestSuite(pyautolib.PyUITestSuiteBase, unittest.TestSuite):
1388 """Base TestSuite for PyAuto UI tests.""" 1401 """Base TestSuite for PyAuto UI tests."""
1389 1402
1390 def __init__(self, args): 1403 def __init__(self, args):
1391 pyautolib.PyUITestSuiteBase.__init__(self, args) 1404 pyautolib.PyUITestSuiteBase.__init__(self, args)
1392 1405
1393 # Figure out path to chromium binaries 1406 # Figure out path to chromium binaries
1394 browser_dir = os.path.normpath(os.path.dirname(pyautolib.__file__)) 1407 browser_dir = os.path.normpath(os.path.dirname(pyautolib.__file__))
1395 logging.debug('Loading pyauto libs from %s', browser_dir) 1408 logging.debug('Loading pyauto libs from %s', browser_dir)
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1685 if self._options.verbose: 1698 if self._options.verbose:
1686 verbosity = 2 1699 verbosity = 2
1687 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) 1700 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite)
1688 del loaded_tests # Need to destroy test cases before the suite 1701 del loaded_tests # Need to destroy test cases before the suite
1689 del pyauto_suite 1702 del pyauto_suite
1690 sys.exit(not result.wasSuccessful()) 1703 sys.exit(not result.wasSuccessful())
1691 1704
1692 1705
1693 if __name__ == '__main__': 1706 if __name__ == '__main__':
1694 Main() 1707 Main()
OLDNEW
« no previous file with comments | « chrome/test/pyautolib/ntp_model.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698