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

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

Issue 10050016: Removes pinning code from TopSites as we no longer need it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove printfs Created 8 years, 8 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/functional/ntp.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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """PyAuto: Python Interface to Chromium's Automation Proxy. 6 """PyAuto: Python Interface to Chromium's Automation Proxy.
7 7
8 PyAuto uses swig to expose Automation Proxy interfaces to Python. 8 PyAuto uses swig to expose Automation Proxy interfaces to Python.
9 For complete documentation on the functionality available, 9 For complete documentation on the functionality available,
10 run pydoc on this file. 10 run pydoc on this file.
(...skipping 3313 matching lines...) Expand 10 before | Expand all | Expand 10 after
3324 'reason': reason, 3324 'reason': reason,
3325 } 3325 }
3326 self._GetResultFromJSONRequest(cmd_dict) 3326 self._GetResultFromJSONRequest(cmd_dict)
3327 else: 3327 else:
3328 logging.warn('Heap-profiling is not supported in this OS.') 3328 logging.warn('Heap-profiling is not supported in this OS.')
3329 3329
3330 def GetNTPThumbnails(self): 3330 def GetNTPThumbnails(self):
3331 """Return a list of info about the sites in the NTP most visited section. 3331 """Return a list of info about the sites in the NTP most visited section.
3332 SAMPLE: 3332 SAMPLE:
3333 [{ u'title': u'Google', 3333 [{ u'title': u'Google',
3334 u'url': u'http://www.google.com', 3334 u'url': u'http://www.google.com'},
3335 u'is_pinned': False},
3336 { 3335 {
3337 u'title': u'Yahoo', 3336 u'title': u'Yahoo',
3338 u'url': u'http://www.yahoo.com', 3337 u'url': u'http://www.yahoo.com'}]
3339 u'is_pinned': True}]
3340 """ 3338 """
3341 return self._GetNTPInfo()['most_visited'] 3339 return self._GetNTPInfo()['most_visited']
3342 3340
3343 def GetNTPThumbnailIndex(self, thumbnail): 3341 def GetNTPThumbnailIndex(self, thumbnail):
3344 """Returns the index of the given NTP thumbnail, or -1 if it is not shown. 3342 """Returns the index of the given NTP thumbnail, or -1 if it is not shown.
3345 3343
3346 Args: 3344 Args:
3347 thumbnail: a thumbnail dict received from |GetNTPThumbnails| 3345 thumbnail: a thumbnail dict received from |GetNTPThumbnails|
3348 """ 3346 """
3349 thumbnails = self.GetNTPThumbnails() 3347 thumbnails = self.GetNTPThumbnails()
3350 for i in range(len(thumbnails)): 3348 for i in range(len(thumbnails)):
3351 if thumbnails[i]['url'] == thumbnail['url']: 3349 if thumbnails[i]['url'] == thumbnail['url']:
3352 return i 3350 return i
3353 return -1 3351 return -1
3354 3352
3355 def MoveNTPThumbnail(self, thumbnail, new_index): 3353 def MoveNTPThumbnail(self, thumbnail, new_index):
3356 """Moves the given thumbnail to a new index. The indices in the NTP Most 3354 """Moves the given thumbnail to a new index. The indices in the NTP Most
3357 Visited sites section look like: 3355 Visited sites section look like:
3358 0 1 2 3 3356 0 1 2 3
3359 4 5 6 7 3357 4 5 6 7
3360 3358
3361 When a thumbnail is moved, it is automatically pinned.
3362
3363 Args: 3359 Args:
3364 thumbnail: a thumbnail dict received from |GetNTPThumbnails| 3360 thumbnail: a thumbnail dict received from |GetNTPThumbnails|
3365 new_index: the index to be moved to in the Most Visited sites section 3361 new_index: the index to be moved to in the Most Visited sites section
3366 3362
3367 Raises: 3363 Raises:
3368 IndexError if there is no thumbnail at the index 3364 IndexError if there is no thumbnail at the index
3369 """ 3365 """
3370 if new_index < 0 or new_index >= len(self.GetNTPThumbnails()): 3366 if new_index < 0 or new_index >= len(self.GetNTPThumbnails()):
3371 raise IndexError() 3367 raise IndexError()
3372 self._CheckNTPThumbnailShown(thumbnail) 3368 self._CheckNTPThumbnailShown(thumbnail)
(...skipping 11 matching lines...) Expand all
3384 Args: 3380 Args:
3385 thumbnail: a thumbnail dict received from |GetNTPThumbnails| 3381 thumbnail: a thumbnail dict received from |GetNTPThumbnails|
3386 """ 3382 """
3387 self._CheckNTPThumbnailShown(thumbnail) 3383 self._CheckNTPThumbnailShown(thumbnail)
3388 cmd_dict = { 3384 cmd_dict = {
3389 'command': 'RemoveNTPMostVisitedThumbnail', 3385 'command': 'RemoveNTPMostVisitedThumbnail',
3390 'url': thumbnail['url'] 3386 'url': thumbnail['url']
3391 } 3387 }
3392 self._GetResultFromJSONRequest(cmd_dict) 3388 self._GetResultFromJSONRequest(cmd_dict)
3393 3389
3394 def PinNTPThumbnail(self, thumbnail):
3395 """Pins the NTP thumbnail.
3396
3397 Args:
3398 thumbnail: a thumbnail dict received from |GetNTPThumbnails|
3399 """
3400 self._CheckNTPThumbnailShown(thumbnail)
3401 self.MoveNTPThumbnail(thumbnail, self.GetNTPThumbnailIndex(thumbnail))
3402
3403 def UnpinNTPThumbnail(self, thumbnail):
3404 """Unpins the NTP thumbnail and returns true on success.
3405
3406 Args:
3407 thumbnail: a thumbnail dict received from |GetNTPThumbnails|
3408 """
3409 self._CheckNTPThumbnailShown(thumbnail)
3410 cmd_dict = {
3411 'command': 'UnpinNTPMostVisitedThumbnail',
3412 'url': thumbnail['url']
3413 }
3414 self._GetResultFromJSONRequest(cmd_dict)
3415
3416 def IsNTPThumbnailPinned(self, thumbnail):
3417 """Returns whether the NTP thumbnail is pinned.
3418
3419 Args:
3420 thumbnail: a thumbnail dict received from |GetNTPThumbnails|
3421 """
3422 self._CheckNTPThumbnailShown(thumbnail)
3423 index = self.GetNTPThumbnailIndex(thumbnail)
3424 return self.GetNTPThumbnails()[index]['is_pinned']
3425
3426 def RestoreAllNTPThumbnails(self): 3390 def RestoreAllNTPThumbnails(self):
3427 """Restores all the removed NTP thumbnails. 3391 """Restores all the removed NTP thumbnails.
3428 Note: 3392 Note:
3429 the default thumbnails may come back into the Most Visited sites 3393 the default thumbnails may come back into the Most Visited sites
3430 section after doing this 3394 section after doing this
3431 """ 3395 """
3432 cmd_dict = { 3396 cmd_dict = {
3433 'command': 'RestoreAllNTPMostVisitedThumbnails' 3397 'command': 'RestoreAllNTPMostVisitedThumbnails'
3434 } 3398 }
3435 self._GetResultFromJSONRequest(cmd_dict) 3399 self._GetResultFromJSONRequest(cmd_dict)
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after
5289 successful = result.wasSuccessful() 5253 successful = result.wasSuccessful()
5290 if not successful: 5254 if not successful:
5291 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 5255 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
5292 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 5256 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
5293 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 5257 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
5294 sys.exit(not successful) 5258 sys.exit(not successful)
5295 5259
5296 5260
5297 if __name__ == '__main__': 5261 if __name__ == '__main__':
5298 Main() 5262 Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/ntp.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698