Chromium Code Reviews| Index: tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py |
| diff --git a/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py |
| index d211b17a53fdffba3d07db52080206cdb6b5ce28..0b3e67e250ab9e5bf7a6a35033bc4ab95bb5c7a9 100644 |
| --- a/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py |
| +++ b/tools/chrome_proxy/integration_tests/chrome_proxy_metrics.py |
| @@ -227,6 +227,15 @@ class ChromeProxyMetric(network_metrics.NetworkMetric): |
| str(retry_time_high))) |
| return True |
| + def VerifyAllProxiesBypassed(self, tab): |
| + if tab: |
| + info = GetProxyInfoFromNetworkInternals(tab) |
| + if not info['enabled']: |
| + raise ChromeProxyMetricException, ( |
| + 'Chrome proxy should be enabled. proxy info: %s' % info) |
| + _, expected_bad_proxies = self.IsProxyBypassed(tab) |
|
bolian
2014/10/14 06:00:49
I think you want to verify the first return value
sclittle
2014/10/14 17:36:45
Done.
|
| + self.VerifyBadProxies(info['badProxies'], expected_bad_proxies) |
| + |
| def AddResultsForBypass(self, tab, results): |
| bypass_count = 0 |
| for resp in self.IterResponses(tab): |
| @@ -237,14 +246,7 @@ class ChromeProxyMetric(network_metrics.NetworkMetric): |
| r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) |
| bypass_count += 1 |
| - if tab: |
| - info = GetProxyInfoFromNetworkInternals(tab) |
| - if not info['enabled']: |
| - raise ChromeProxyMetricException, ( |
| - 'Chrome proxy should be enabled. proxy info: %s' % info) |
| - _, expected_bad_proxies = self.IsProxyBypassed(tab) |
| - self.VerifyBadProxies(info['badProxies'], expected_bad_proxies) |
| - |
| + self.VerifyAllProxiesBypassed(tab) |
| results.AddValue(scalar.ScalarValue( |
| results.current_page, 'bypass', 'count', bypass_count)) |
| @@ -282,14 +284,8 @@ class ChromeProxyMetric(network_metrics.NetworkMetric): |
| 'At least one response should be bypassed. ' |
| '(eligible_response_count=%d, bypass_count=%d)\n' % ( |
| eligible_response_count, bypass_count)) |
| - if tab: |
| - info = GetProxyInfoFromNetworkInternals(tab) |
| - if not info['enabled']: |
| - raise ChromeProxyMetricException, ( |
| - 'Chrome proxy should be enabled. proxy info: %s' % info) |
| - _, expected_bad_proxies = self.IsProxyBypassed(tab) |
| - self.VerifyBadProxies(info['badProxies'], expected_bad_proxies) |
| + self.VerifyAllProxiesBypassed(tab) |
| results.AddValue(scalar.ScalarValue( |
| results.current_page, 'cors_bypass', 'count', bypass_count)) |
| @@ -347,19 +343,12 @@ class ChromeProxyMetric(network_metrics.NetworkMetric): |
| 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % ( |
| count, safebrowsing_count)) |
| - def AddResultsForHTTPFallback( |
| - self, tab, results, expected_proxies=None, expected_bad_proxies=None): |
| + def VerifyProxyInfo(self, tab, expected_proxies, expected_bad_proxies): |
| info = GetProxyInfoFromNetworkInternals(tab) |
| if not 'enabled' in info or not info['enabled']: |
| raise ChromeProxyMetricException, ( |
| 'Chrome proxy should be enabled. proxy info: %s' % info) |
| - if not expected_proxies: |
| - expected_proxies = [self.effective_proxies['fallback'], |
| - self.effective_proxies['direct']] |
| - if not expected_bad_proxies: |
| - expected_bad_proxies = [] |
| - |
| proxies = info['proxies'] |
| if proxies != expected_proxies: |
| raise ChromeProxyMetricException, ( |
| @@ -374,5 +363,20 @@ class ChromeProxyMetric(network_metrics.NetworkMetric): |
| raise ChromeProxyMetricException, ( |
| 'Wrong bad proxies (%s). Expect: "%s"' % ( |
| str(bad_proxies), str(expected_bad_proxies))) |
| + |
| + def AddResultsForHTTPFallback( |
| + self, tab, results, expected_proxies=None, expected_bad_proxies=None): |
| + if not expected_proxies: |
| + expected_proxies = [self.effective_proxies['fallback'], |
| + self.effective_proxies['direct']] |
| + if not expected_bad_proxies: |
| + expected_bad_proxies = [] |
| + |
| + self.VerifyProxyInfo(tab, expected_proxies, expected_bad_proxies) |
| results.AddValue(scalar.ScalarValue( |
| results.current_page, 'http_fallback', 'boolean', True)) |
| + |
| + def AddResultsForHTTPToDirectFallback(self, tab, results): |
| + self.VerifyAllProxiesBypassed(tab) |
| + results.AddValue(scalar.ScalarValue( |
| + results.current_page, 'direct_fallback', 'boolean', True)) |