Index: tools/chrome_proxy/integration_tests/chrome_proxy_metrics_unittest.py |
diff --git a/tools/perf/metrics/chrome_proxy_unittest.py b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics_unittest.py |
similarity index 87% |
rename from tools/perf/metrics/chrome_proxy_unittest.py |
rename to tools/chrome_proxy/integration_tests/chrome_proxy_metrics_unittest.py |
index a4d2cabc9d574ec532674613f917b8ef201a932b..09d9286868863fcb5b66152a75f7975d9c8cca53 100644 |
--- a/tools/perf/metrics/chrome_proxy_unittest.py |
+++ b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics_unittest.py |
@@ -5,8 +5,8 @@ |
import base64 |
import unittest |
-from metrics import chrome_proxy |
-from metrics import network_unittest |
+from integration_tests import chrome_proxy_metrics as metrics |
+from integration_tests import network_metrics_unittest as network_unittest |
from metrics import test_page_measurement_results |
@@ -28,7 +28,7 @@ EVENT_HTML_PROXY_DEPRECATED_VIA = ( |
'Content-Type': 'text/html', |
'Content-Encoding': 'gzip', |
'X-Original-Content-Length': str(len(network_unittest.HTML_BODY)), |
- 'Via': (chrome_proxy.CHROME_PROXY_VIA_HEADER_DEPRECATED + |
+ 'Via': (metrics.CHROME_PROXY_VIA_HEADER_DEPRECATED + |
',other-via'), |
}, |
body=network_unittest.HTML_BODY)) |
@@ -41,7 +41,7 @@ EVENT_IMAGE_PROXY_CACHED = ( |
'Content-Type': 'image/jpeg', |
'Content-Encoding': 'gzip', |
'X-Original-Content-Length': str(network_unittest.IMAGE_OCL), |
- 'Via': '1.1 ' + chrome_proxy.CHROME_PROXY_VIA_HEADER, |
+ 'Via': '1.1 ' + metrics.CHROME_PROXY_VIA_HEADER, |
}, |
body=base64.b64encode(network_unittest.IMAGE_BODY), |
base64_encoded_body=True, |
@@ -64,7 +64,7 @@ EVENT_MALWARE_PROXY = ( |
url='http://test.malware', |
response_headers={ |
'X-Malware-Url': '1', |
- 'Via': '1.1 ' + chrome_proxy.CHROME_PROXY_VIA_HEADER, |
+ 'Via': '1.1 ' + metrics.CHROME_PROXY_VIA_HEADER, |
'Location': 'http://test.malware', |
}, |
status=307)) |
@@ -77,12 +77,12 @@ class ChromeProxyMetricTest(unittest.TestCase): |
def _StubGetProxyInfo(self, info): |
def stub(unused_tab, unused_url=''): # pylint: disable=W0613 |
return ChromeProxyMetricTest._test_proxy_info |
- chrome_proxy.GetProxyInfoFromNetworkInternals = stub |
+ metrics.GetProxyInfoFromNetworkInternals = stub |
ChromeProxyMetricTest._test_proxy_info = info |
def testChromeProxyResponse(self): |
# An https non-proxy response. |
- resp = chrome_proxy.ChromeProxyResponse( |
+ resp = metrics.ChromeProxyResponse( |
network_unittest.NetworkMetricTest.MakeNetworkTimelineEvent( |
url='https://test.url', |
response_headers={ |
@@ -96,13 +96,13 @@ class ChromeProxyMetricTest(unittest.TestCase): |
self.assertTrue(resp.IsValidByViaHeader()) |
# A proxied JPEG image response |
- resp = chrome_proxy.ChromeProxyResponse( |
+ resp = metrics.ChromeProxyResponse( |
network_unittest.NetworkMetricTest.MakeNetworkTimelineEvent( |
url='http://test.image', |
response_headers={ |
'Content-Type': 'image/jpeg', |
'Content-Encoding': 'gzip', |
- 'Via': '1.1 ' + chrome_proxy.CHROME_PROXY_VIA_HEADER, |
+ 'Via': '1.1 ' + metrics.CHROME_PROXY_VIA_HEADER, |
'X-Original-Content-Length': str(network_unittest.IMAGE_OCL), |
}, |
body=base64.b64encode(network_unittest.IMAGE_BODY), |
@@ -112,7 +112,7 @@ class ChromeProxyMetricTest(unittest.TestCase): |
self.assertTrue(resp.IsValidByViaHeader()) |
def testChromeProxyMetricForDataSaving(self): |
- metric = chrome_proxy.ChromeProxyMetric() |
+ metric = metrics.ChromeProxyMetric() |
events = [ |
EVENT_HTML_PROXY, |
EVENT_HTML_PROXY_DEPRECATED_VIA, |
@@ -129,7 +129,7 @@ class ChromeProxyMetricTest(unittest.TestCase): |
results.AssertHasPageSpecificScalarValue('resources_direct', 'count', 2) |
def testChromeProxyMetricForHeaderValidation(self): |
- metric = chrome_proxy.ChromeProxyMetric() |
+ metric = metrics.ChromeProxyMetric() |
metric.SetEvents([ |
EVENT_HTML_PROXY, |
EVENT_HTML_PROXY_DEPRECATED_VIA, |
@@ -141,7 +141,7 @@ class ChromeProxyMetricTest(unittest.TestCase): |
missing_via_exception = False |
try: |
metric.AddResultsForHeaderValidation(None, results) |
- except chrome_proxy.ChromeProxyMetricException: |
+ except metrics.ChromeProxyMetricException: |
missing_via_exception = True |
# Only the HTTP image response does not have a valid Via header. |
self.assertTrue(missing_via_exception) |
@@ -154,7 +154,7 @@ class ChromeProxyMetricTest(unittest.TestCase): |
results.AssertHasPageSpecificScalarValue('checked_via_header', 'count', 2) |
def testChromeProxyMetricForBypass(self): |
- metric = chrome_proxy.ChromeProxyMetric() |
+ metric = metrics.ChromeProxyMetric() |
metric.SetEvents([ |
EVENT_HTML_PROXY, |
EVENT_HTML_PROXY_DEPRECATED_VIA, |
@@ -165,7 +165,7 @@ class ChromeProxyMetricTest(unittest.TestCase): |
bypass_exception = False |
try: |
metric.AddResultsForBypass(None, results) |
- except chrome_proxy.ChromeProxyMetricException: |
+ except metrics.ChromeProxyMetricException: |
bypass_exception = True |
# Two of the first three events have Via headers. |
self.assertTrue(bypass_exception) |
@@ -176,7 +176,7 @@ class ChromeProxyMetricTest(unittest.TestCase): |
results.AssertHasPageSpecificScalarValue('bypass', 'count', 1) |
def testChromeProxyMetricForHTTPFallback(self): |
- metric = chrome_proxy.ChromeProxyMetric() |
+ metric = metrics.ChromeProxyMetric() |
metric.SetEvents([ |
EVENT_HTML_PROXY, |
EVENT_HTML_PROXY_DEPRECATED_VIA]) |
@@ -188,7 +188,7 @@ class ChromeProxyMetricTest(unittest.TestCase): |
self._StubGetProxyInfo(info) |
try: |
metric.AddResultsForBypass(None, results) |
- except chrome_proxy.ChromeProxyMetricException: |
+ except metrics.ChromeProxyMetricException: |
fallback_exception = True |
self.assertTrue(fallback_exception) |
@@ -196,25 +196,25 @@ class ChromeProxyMetricTest(unittest.TestCase): |
info['enabled'] = True |
info['proxies'] = [ |
'something.else.com:80', |
- chrome_proxy.PROXY_SETTING_DIRECT |
+ metrics.PROXY_SETTING_DIRECT |
] |
self._StubGetProxyInfo(info) |
try: |
metric.AddResultsForBypass(None, results) |
- except chrome_proxy.ChromeProxyMetricException: |
+ except metrics.ChromeProxyMetricException: |
fallback_exception = True |
self.assertTrue(fallback_exception) |
info['enabled'] = True |
info['proxies'] = [ |
- chrome_proxy.PROXY_SETTING_HTTP, |
- chrome_proxy.PROXY_SETTING_DIRECT |
+ metrics.PROXY_SETTING_HTTP, |
+ metrics.PROXY_SETTING_DIRECT |
] |
self._StubGetProxyInfo(info) |
metric.AddResultsForHTTPFallback(None, results) |
def testChromeProxyMetricForSafebrowsing(self): |
- metric = chrome_proxy.ChromeProxyMetric() |
+ metric = metrics.ChromeProxyMetric() |
metric.SetEvents([EVENT_MALWARE_PROXY]) |
results = test_page_measurement_results.TestPageMeasurementResults(self) |