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

Unified Diff: tools/telemetry/telemetry/page/page.py

Issue 397793005: Add Page. TransferToPageSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move TransferToPageSetAPI(..) to page Created 6 years, 5 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 | « no previous file | tools/telemetry/telemetry/page/page_set_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/page/page.py
diff --git a/tools/telemetry/telemetry/page/page.py b/tools/telemetry/telemetry/page/page.py
index bde3dfb80a63e69daad82ff59c72940b710e9ac8..3af81964a355d65e1648172f92d126d442fbf34b 100644
--- a/tools/telemetry/telemetry/page/page.py
+++ b/tools/telemetry/telemetry/page/page.py
@@ -15,7 +15,7 @@ class Page(object):
self._url = url
self._page_set = page_set
# Default value of base_dir is the directory of the file that defines the
- # class of this page instace.
+ # class of this page instance.
if base_dir is None:
base_dir = os.path.dirname(inspect.getfile(self.__class__))
self._base_dir = base_dir
@@ -44,6 +44,26 @@ class Page(object):
if startup_url_scheme == 'file':
raise ValueError('startup_url with local file scheme is not supported')
+ def TransferToPageSet(self, another_page_set):
+ """ Transfer this page to another page set.
+ Args:
+ another_page_set: an instance of telemetry.page.PageSet to transfer this
+ page to.
+ Note:
+ This method removes this page instance from the pages list of its current
+ page_set, so one should be careful not to iterate through the list of
+ pages of a page_set and calling this method.
+ For example, the below loop is erroneous:
+ for p in page_set_A.pages:
+ p.TransferToPageSet(page_set_B.pages)
+ """
+ assert self._page_set
+ if another_page_set is self._page_set:
+ return
+ self._page_set.pages.remove(self)
+ self._page_set = another_page_set
+ self._page_set.AddPage(self)
+
def RunNavigateSteps(self, action_runner):
action_runner.NavigateToPage(self)
« no previous file with comments | « no previous file | tools/telemetry/telemetry/page/page_set_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698