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

Unified Diff: chrome/test/functional/tracing/tab_tracker.py

Issue 10736055: Smoke test for tracing infrastructure in PyAuto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Clean up js TimelineModel when the python TimelineModelProxy is deleted. Created 8 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 | « chrome/test/functional/tracing/pyauto_tracing.py ('k') | chrome/test/functional/tracing/timeline_model.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/functional/tracing/tab_tracker.py
diff --git a/chrome/test/functional/tracing/tab_tracker.py b/chrome/test/functional/tracing/tab_tracker.py
new file mode 100644
index 0000000000000000000000000000000000000000..db4da4a5fd33005504129ff7897a90768a836a1c
--- /dev/null
+++ b/chrome/test/functional/tracing/tab_tracker.py
@@ -0,0 +1,41 @@
+# 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.
+
+import uuid
+
+# The TabTracker class allows the creation of tabs whose indices can be
Nirnimesh 2012/07/30 18:57:19 This sounds like a docstring. Move inside the clas
+# determined even after lower indexed tabs have been closed, therefore changing
+# that tab's index.
+class TabTracker:
+ def __init__(self, browser, visible = False):
Nirnimesh 2012/07/30 18:57:19 remove parents around =
Nirnimesh 2012/07/30 18:58:03 err.. parents -> space
+ # A binary search tree would be faster, but this is easier to write.
+ # If this needs to become faster, understand that the important operations
+ # here are append, arbitrary deletion and searching.
+ self._uuids = [None]
+ self._window_idx = browser.GetBrowserWindowCount()
+ self._browser = browser
+ browser.OpenNewBrowserWindow(visible)
+ # We leave the 0'th tab empty to have something to close on __del__
+
+ def __del__(self):
+ self._browser.CloseBrowserWindow(self._window_idx)
+
+ def createTab(self, url="about:blank"):
Nirnimesh 2012/07/30 18:57:19 createTab -> CreateTab Please repeat for all meth
Nirnimesh 2012/07/30 18:57:19 use single quote char ' instead of " for consisten
Nirnimesh 2012/07/30 18:57:19 Add docstring, with an Args: section.
+ self._browser.AppendTab(url, self._window_idx)
+ # We use uuids here rather than a monotonic integer to prevent confusion
+ # with the tab index.
+ tab_uuid = uuid.uuid4()
+ self._uuids.append(tab_uuid)
+ return tab_uuid
+
+ def releaseTab(self, tab_uuid):
+ idx = self.getTabIndex(tab_uuid)
+ self._browser.GetBrowserWindow(self._window_idx).GetTab(idx).Close()
+ del self._uuids[idx]
+
+ def getTabIndex(self, tab_uuid):
+ return self._uuids.index(tab_uuid)
+
+ def getWindowIndex(self):
+ return self._window_idx
« no previous file with comments | « chrome/test/functional/tracing/pyauto_tracing.py ('k') | chrome/test/functional/tracing/timeline_model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698