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

Side by Side Diff: tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py

Issue 820093002: Integration tests for desktop platforms and safebrowsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed test names. Add @classmethod. Created 5 years, 11 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import base64 5 import base64
6 import logging 6 import logging
7 import urlparse 7 import urlparse
8 8
9 from integration_tests import chrome_proxy_metrics as metrics 9 from integration_tests import chrome_proxy_metrics as metrics
10 from metrics import loading 10 from metrics import loading
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 78 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613
79 if hasattr(page, 'restart_after') and page.restart_after: 79 if hasattr(page, 'restart_after') and page.restart_after:
80 return True 80 return True
81 return False 81 return False
82 82
83 def RunNavigateSteps(self, page, tab): 83 def RunNavigateSteps(self, page, tab):
84 # The redirect from safebrowsing causes a timeout. Ignore that. 84 # The redirect from safebrowsing causes a timeout. Ignore that.
85 try: 85 try:
86 super(ChromeProxyValidation, self).RunNavigateSteps(page, tab) 86 super(ChromeProxyValidation, self).RunNavigateSteps(page, tab)
87 if self._expect_timeout:
88 raise metrics.ChromeProxyMetricException, (
89 'Timeout was expected, but did not occur')
87 except exceptions.DevtoolsTargetCrashException, e: 90 except exceptions.DevtoolsTargetCrashException, e:
88 if self._expect_timeout: 91 if self._expect_timeout:
89 logging.warning('Navigation timeout on page %s', 92 logging.warning('Navigation timeout on page %s',
90 page.name if page.name else page.url) 93 page.name if page.name else page.url)
91 else: 94 else:
92 raise e 95 raise e
93 96
94 97
95 class ChromeProxyHeaders(ChromeProxyValidation): 98 class ChromeProxyHeaders(ChromeProxyValidation):
96 """Correctness measurement for response headers.""" 99 """Correctness measurement for response headers."""
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 class ChromeProxyBlockOnce(ChromeProxyValidation): 135 class ChromeProxyBlockOnce(ChromeProxyValidation):
133 """Correctness measurement for block-once responses.""" 136 """Correctness measurement for block-once responses."""
134 137
135 def __init__(self): 138 def __init__(self):
136 super(ChromeProxyBlockOnce, self).__init__(restart_after_each_page=True) 139 super(ChromeProxyBlockOnce, self).__init__(restart_after_each_page=True)
137 140
138 def AddResults(self, tab, results): 141 def AddResults(self, tab, results):
139 self._metrics.AddResultsForBlockOnce(tab, results) 142 self._metrics.AddResultsForBlockOnce(tab, results)
140 143
141 144
142 class ChromeProxySafebrowsing(ChromeProxyValidation): 145 class ChromeProxySafebrowsingOn(ChromeProxyValidation):
143 """Correctness measurement for safebrowsing.""" 146 """Correctness measurement for safebrowsing."""
144 147
145 def __init__(self): 148 def __init__(self):
146 super(ChromeProxySafebrowsing, self).__init__() 149 super(ChromeProxySafebrowsingOn, self).__init__()
147 150
148 def WillNavigateToPage(self, page, tab): 151 def WillNavigateToPage(self, page, tab):
149 super(ChromeProxySafebrowsing, self).WillNavigateToPage(page, tab) 152 super(ChromeProxySafebrowsingOn, self).WillNavigateToPage(page, tab)
150 self._expect_timeout = True 153 self._expect_timeout = True
151 154
152 def AddResults(self, tab, results): 155 def AddResults(self, tab, results):
153 self._metrics.AddResultsForSafebrowsing(tab, results) 156 self._metrics.AddResultsForSafebrowsingOn(tab, results)
154 157
158 class ChromeProxySafebrowsingOff(ChromeProxyValidation):
159 """Correctness measurement for safebrowsing."""
160
161 def __init__(self):
162 super(ChromeProxySafebrowsingOff, self).__init__()
163
164 def AddResults(self, tab, results):
165 self._metrics.AddResultsForSafebrowsingOff(tab, results)
155 166
156 _FAKE_PROXY_AUTH_VALUE = 'aabbccdd3b7579186c1b0620614fdb1f0000ffff' 167 _FAKE_PROXY_AUTH_VALUE = 'aabbccdd3b7579186c1b0620614fdb1f0000ffff'
157 _TEST_SERVER = 'chromeproxy-test.appspot.com' 168 _TEST_SERVER = 'chromeproxy-test.appspot.com'
158 _TEST_SERVER_DEFAULT_URL = 'http://' + _TEST_SERVER + '/default' 169 _TEST_SERVER_DEFAULT_URL = 'http://' + _TEST_SERVER + '/default'
159 170
160 171
161 # We rely on the chromeproxy-test server to facilitate some of the tests. 172 # We rely on the chromeproxy-test server to facilitate some of the tests.
162 # The test server code is at <TBD location> and runs at _TEST_SERVER 173 # The test server code is at <TBD location> and runs at _TEST_SERVER
163 # 174 #
164 # The test server allow request to override response status, headers, and 175 # The test server allow request to override response status, headers, and
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 333
323 334
324 class ChromeProxySmoke(ChromeProxyValidation): 335 class ChromeProxySmoke(ChromeProxyValidation):
325 """Smoke measurement for basic chrome proxy correctness.""" 336 """Smoke measurement for basic chrome proxy correctness."""
326 337
327 def __init__(self): 338 def __init__(self):
328 super(ChromeProxySmoke, self).__init__() 339 super(ChromeProxySmoke, self).__init__()
329 340
330 def WillNavigateToPage(self, page, tab): 341 def WillNavigateToPage(self, page, tab):
331 super(ChromeProxySmoke, self).WillNavigateToPage(page, tab) 342 super(ChromeProxySmoke, self).WillNavigateToPage(page, tab)
332 if page.name == 'safebrowsing':
333 self._expect_timeout = True
334 343
335 def AddResults(self, tab, results): 344 def AddResults(self, tab, results):
336 # Map a page name to its AddResults func. 345 # Map a page name to its AddResults func.
337 page_to_metrics = { 346 page_to_metrics = {
338 'header validation': [self._metrics.AddResultsForHeaderValidation], 347 'header validation': [self._metrics.AddResultsForHeaderValidation],
339 'compression: image': [ 348 'compression: image': [
340 self._metrics.AddResultsForHeaderValidation, 349 self._metrics.AddResultsForHeaderValidation,
341 self._metrics.AddResultsForDataSaving, 350 self._metrics.AddResultsForDataSaving,
342 ], 351 ],
343 'compression: javascript': [ 352 'compression: javascript': [
344 self._metrics.AddResultsForHeaderValidation, 353 self._metrics.AddResultsForHeaderValidation,
345 self._metrics.AddResultsForDataSaving, 354 self._metrics.AddResultsForDataSaving,
346 ], 355 ],
347 'compression: css': [ 356 'compression: css': [
348 self._metrics.AddResultsForHeaderValidation, 357 self._metrics.AddResultsForHeaderValidation,
349 self._metrics.AddResultsForDataSaving, 358 self._metrics.AddResultsForDataSaving,
350 ], 359 ],
351 'bypass': [self._metrics.AddResultsForBypass], 360 'bypass': [self._metrics.AddResultsForBypass],
352 'safebrowsing': [self._metrics.AddResultsForSafebrowsing],
353 } 361 }
354 if not self._page.name in page_to_metrics: 362 if not self._page.name in page_to_metrics:
355 raise page_test.MeasurementFailure( 363 raise page_test.MeasurementFailure(
356 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % ( 364 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % (
357 self._page.name, page_to_metrics.keys())) 365 self._page.name, page_to_metrics.keys()))
358 for add_result in page_to_metrics[self._page.name]: 366 for add_result in page_to_metrics[self._page.name]:
359 add_result(tab, results) 367 add_result(tab, results)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698