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

Unified Diff: chrome/test/pyautolib/bookmark_model.py

Issue 222873002: Remove pyauto tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/pyautolib/asan_stub.c ('k') | chrome/test/pyautolib/chrome_driver_factory.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/pyautolib/bookmark_model.py
===================================================================
--- chrome/test/pyautolib/bookmark_model.py (revision 261231)
+++ chrome/test/pyautolib/bookmark_model.py (working copy)
@@ -1,99 +0,0 @@
-# Copyright (c) 2011 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.
-
-"""BookmarkModel: python representation of the bookmark model.
-
-Obtain one of these from PyUITestSuite::GetBookmarkModel() call.
-"""
-
-import os
-import simplejson as json
-import sys
-
-class BookmarkModel(object):
-
- def __init__(self, json_string):
- """Initialize a BookmarkModel from a string of json.
-
- The JSON representation is the same as used by the bookmark model
- to save to disk.
-
- Args:
- json_string: a string of JSON.
- """
- self.bookdict = json.loads(json_string)
-
- def BookmarkBar(self):
- """Return the bookmark bar node as a dict."""
- return self.bookdict['roots']['bookmark_bar']
-
- def Other(self):
- """Return the 'other' node (e.g. parent of "Other Bookmarks")"""
- return self.bookdict['roots']['other']
-
- def NodeCount(self, node=None):
- """Return a count of bookmark nodes, including folders.
-
- The root node itself is included in the count.
-
- Args:
- node: the root to start with. If not specified, count all."""
- if node == None:
- return reduce(lambda x, y: x + y,
- [self.NodeCount(x)
- for x in self.bookdict['roots'].values()])
- total = 1
- children = node.get('children', None)
- if children:
- total = total + reduce(lambda x,y: x + y,
- [self.NodeCount(x) for x in children])
- return total
-
- def FindByID(self, id, nodes=None):
- """Find the bookmark by id. Return the dict or None.
-
- Args:
- id: the id to look for.
- nodes: an iterable of nodes to start with. If not specified, search all.
- 'Not specified' means None, not [].
- """
- # Careful; we may get an empty list which is different than not
- # having specified a list.
- if nodes == None:
- nodes = self.bookdict['roots'].values()
- # Check each item. If it matches, return. If not, check each of
- # their kids.
- for node in nodes:
- if node['id'] == id:
- return node
- for child in node.get('children', []):
- found_node = self.FindByID(id, [child])
- if found_node:
- return found_node
- # Not found at all.
- return None
-
- def FindByTitle(self, title, nodes=None):
- """Return a tuple of all nodes which have |title| in their title.
-
- Args:
- title: the title to look for.
- node: an iterable of nodes to start with. If not specified, search all.
- 'Not specified' means None, not [].
- """
- # Careful; we may get an empty list which is different than not
- # having specified a list.
- if nodes == None:
- nodes = self.bookdict['roots'].values()
- # Check each item. If it matches, return. If not, check each of
- # their kids.
- results = []
- for node in nodes:
- node_title = node.get('title', None) or node.get('name', None)
- if title == node_title:
- results.append(node)
- # Note we check everything; unlike the FindByID, we do not stop early.
- for child in node.get('children', []):
- results += self.FindByTitle(title, [child])
- return results
« no previous file with comments | « chrome/test/pyautolib/asan_stub.c ('k') | chrome/test/pyautolib/chrome_driver_factory.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698