summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authormegjablon <megjablon@chromium.org>2015-05-14 18:15:52 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-15 01:16:49 +0000
commitf2ba95e366d3dba58ee697f2a2ca7394b79cc645 (patch)
tree4476925c35690f6e8ed482035b7c213a9be4d9fe /tools
parent55dae7df996493abc81e6b9e435f69f1c23aa9f4 (diff)
downloadchromium_src-f2ba95e366d3dba58ee697f2a2ca7394b79cc645.zip
chromium_src-f2ba95e366d3dba58ee697f2a2ca7394b79cc645.tar.gz
chromium_src-f2ba95e366d3dba58ee697f2a2ca7394b79cc645.tar.bz2
Integration test for Lo-Fi directives in the Chrome-Proxy response header
Lo-Fi directives were added to the Chrome-Proxy response header. Adding testing of these responses in the Lo-Fi integration test. BUG=487879 Review URL: https://codereview.chromium.org/1131063005 Cr-Commit-Position: refs/heads/master@{#330006}
Diffstat (limited to 'tools')
-rw-r--r--tools/chrome_proxy/common/chrome_proxy_metrics.py14
-rw-r--r--tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py23
2 files changed, 27 insertions, 10 deletions
diff --git a/tools/chrome_proxy/common/chrome_proxy_metrics.py b/tools/chrome_proxy/common/chrome_proxy_metrics.py
index f28cbb8..46c7ed8 100644
--- a/tools/chrome_proxy/common/chrome_proxy_metrics.py
+++ b/tools/chrome_proxy/common/chrome_proxy_metrics.py
@@ -78,12 +78,16 @@ class ChromeProxyResponse(network_metrics.HTTPResponse):
return kvp[1].strip()
return None
- def HasChromeProxyLoFi(self):
+ def HasChromeProxyLoFiRequest(self):
if 'Chrome-Proxy' not in self.response.request_headers:
return False
chrome_proxy_request_header = self.response.request_headers['Chrome-Proxy']
values = [v.strip() for v in chrome_proxy_request_header.split(',')]
- for value in values:
- if len(value) == 5 and value == 'q=low':
- return True
- return False
+ return any(v == "q=low" for v in values)
+
+ def HasChromeProxyLoFiResponse(self):
+ chrome_proxy_response_header = self.response.GetHeader('Chrome-Proxy')
+ if not chrome_proxy_response_header:
+ return False
+ values = [v.strip() for v in chrome_proxy_response_header.split(',')]
+ return any(v == "q=low" for v in values)
diff --git a/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
index d03bda9..793aceb 100644
--- a/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
+++ b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py
@@ -225,27 +225,40 @@ class ChromeProxyMetric(network_metrics.NetworkMetric):
results.current_page, 'bypass', 'count', bypass_count))
def AddResultsForLoFi(self, tab, results):
- lo_fi_count = 0
+ lo_fi_request_count = 0
+ lo_fi_response_count = 0
for resp in self.IterResponses(tab):
- if resp.HasChromeProxyLoFi():
- lo_fi_count += 1
+ if resp.HasChromeProxyLoFiRequest():
+ lo_fi_request_count += 1
else:
raise ChromeProxyMetricException, (
'%s: LoFi not in request header.' % (resp.response.url))
+ if resp.HasChromeProxyLoFiResponse():
+ lo_fi_response_count += 1
+ else:
+ raise ChromeProxyMetricException, (
+ '%s: LoFi not in response header.' % (resp.response.url))
+
if resp.content_length > 100:
raise ChromeProxyMetricException, (
'Image %s is %d bytes. Expecting less than 100 bytes.' %
(resp.response.url, resp.content_length))
- if lo_fi_count == 0:
+ if lo_fi_request_count == 0:
+ raise ChromeProxyMetricException, (
+ 'Expected at least one LoFi request, but zero such requests were '
+ 'sent.')
+ if lo_fi_response_count == 0:
raise ChromeProxyMetricException, (
'Expected at least one LoFi response, but zero such responses were '
'received.')
results.AddValue(scalar.ScalarValue(
- results.current_page, 'lo_fi', 'count', lo_fi_count))
+ results.current_page, 'lo_fi_request', 'count', lo_fi_request_count))
+ results.AddValue(scalar.ScalarValue(
+ results.current_page, 'lo_fi_response', 'count', lo_fi_response_count))
super(ChromeProxyMetric, self).AddResults(tab, results)
def AddResultsForBypass(self, tab, results):