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

Unified Diff: tools/chrome_proxy/webdriver/common.py

Issue 2714003002: Adding a probe fallback to HTTP test (Closed)
Patch Set: tbansal nit Created 3 years, 10 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/chrome_proxy/webdriver/fallback.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/chrome_proxy/webdriver/common.py
diff --git a/tools/chrome_proxy/webdriver/common.py b/tools/chrome_proxy/webdriver/common.py
index 2572a64a9253049576e6d5b6364a950ce18c46c3..47917bf87b868e6dfcf4c339ac97c63129a6d8c6 100644
--- a/tools/chrome_proxy/webdriver/common.py
+++ b/tools/chrome_proxy/webdriver/common.py
@@ -327,9 +327,18 @@ class TestDriver:
"""
return self.ExecuteJavascript("return " + script, timeout)
- def GetHistogram(self, histogram):
+ def GetHistogram(self, histogram, timeout=30):
+ """Gets a Chrome histogram as a dictionary object.
+
+ Args:
+ histogram: the name of the histogram to fetch
+ timeout: timeout for the underlying Javascript query.
+
+ Returns:
+ A dictionary object containing information about the histogram.
+ """
js_query = 'statsCollectionController.getBrowserHistogram("%s")' % histogram
- string_response = self.ExecuteJavascriptStatement(js_query)
+ string_response = self.ExecuteJavascriptStatement(js_query, timeout)
self._logger.debug('Got %s histogram=%s', histogram, string_response)
return json.loads(string_response)
@@ -382,6 +391,27 @@ class TestDriver:
self._has_logs = False
return all_messages
+ def SleepUntilHistogramHasEntry(self, histogram_name, sleep_intervals=10):
+ """Polls if a histogram exists in 1-6 second intervals for 10 intervals.
+ Allows script to run with a timeout of 5 seconds, so the default behavior
+ allows up to 60 seconds until timeout.
+
+ Args:
+ histogram_name: The name of the histogram to wait for
+ sleep_intervals: The number of polling intervals, each polling cycle takes
+ no more than 6 seconds.
+ Returns:
+ Whether the histogram exists
+ """
+ histogram = {}
+ while(not histogram and sleep_intervals > 0):
+ histogram = self.GetHistogram(histogram_name, 5)
+ if (not histogram):
+ time.sleep(1)
+ sleep_intervals -= 1
+
+ return bool(histogram)
+
def GetHTTPResponses(self, include_favicon=False, skip_domainless_pages=True):
"""Parses the Performance Logs and returns a list of HTTPResponse objects.
« no previous file with comments | « no previous file | tools/chrome_proxy/webdriver/fallback.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698