Chromium Code Reviews| Index: tools/chrome_proxy/webdriver/lofi.py |
| diff --git a/tools/chrome_proxy/webdriver/lofi.py b/tools/chrome_proxy/webdriver/lofi.py |
| index 18935a068c2dff47ae1ebb8b436988340ca39042..386ed36f35b0e57af4355374fa92a5aebcc98ebd 100644 |
| --- a/tools/chrome_proxy/webdriver/lofi.py |
| +++ b/tools/chrome_proxy/webdriver/lofi.py |
| @@ -34,6 +34,74 @@ class LoFi(IntegrationTest): |
| # Verify that Lo-Fi responses were seen. |
| self.assertNotEqual(0, lofi_responses) |
| + # Checks that LoFi images are served when LoFi slow connections are used and |
| + # the network quality estimator returns Slow2G. |
| + def testLoFiSlowConnection(self): |
| + with TestDriver() as test_driver: |
| + test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| + test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=slow-connections-' |
| + 'only') |
| + # Disable server experiments such as tamper detection. |
| + test_driver.AddChromeArg('--data-reduction-proxy-server-experiments-' |
| + 'disabled') |
| + |
| + test_driver.AddChromeArg('--force-fieldtrial-params=' |
| + 'NetworkQualityEstimator.Enabled:' |
| + 'force_effective_connection_type/Slow2G') |
| + test_driver.AddChromeArg('--force-fieldtrials=NetworkQualityEstimator/' |
| + 'Enabled') |
| + |
| + test_driver.LoadURL('http://check.googlezip.net/static/index.html') |
| + |
| + lofi_responses = 0 |
| + for response in test_driver.GetHTTPResponses(): |
| + if not response.url.endswith('png'): |
| + continue |
| + if not response.request_headers: |
| + continue |
| + if (self.checkLoFiResponse(response, True)): |
| + lofi_responses = lofi_responses + 1 |
| + |
| + # Verify that Lo-Fi responses were seen. |
| + self.assertNotEqual(0, lofi_responses) |
| + |
| + # Checks that LoFi images are not served, but the if-heavy CPAT header is |
| + # added when LoFi slow connections are used and the network quality estimator |
| + # returns 4G. |
| + def testLoFiIfHeavyFastConnection(self): |
| + with TestDriver() as test_driver: |
| + test_driver.AddChromeArg('--enable-spdy-proxy-auth') |
| + test_driver.AddChromeArg('--data-reduction-proxy-lo-fi=slow-connections-' |
| + 'only') |
| + # Disable server experiments such as tamper detection. |
| + test_driver.AddChromeArg('--data-reduction-proxy-server-experiments-' |
| + 'disabled') |
| + |
| + test_driver.AddChromeArg('--force-fieldtrial-params=' |
| + 'NetworkQualityEstimator.Enabled:' |
| + 'force_effective_connection_type/4G') |
| + test_driver.AddChromeArg('--force-fieldtrials=NetworkQualityEstimator/' |
| + 'Enabled') |
| + |
| + test_driver.LoadURL('http://check.googlezip.net/static/index.html') |
| + |
| + non_lofi_responses = 0 |
| + for response in test_driver.GetHTTPResponses(): |
| + if not response.url.endswith('png'): |
| + continue |
| + if not response.request_headers: |
| + continue |
| + self.assertIn('chrome-proxy-accept-transform', response.request_headers) |
| + actual_cpat_headers = \ |
| + response.request_headers['chrome-proxy-accept-transform'].split(';') |
| + self.assertIn('empty-image', actual_cpat_headers) |
| + self.assertIn('if-heavy', actual_cpat_headers) |
| + if (not self.checkLoFiResponse(response, False)): |
| + non_lofi_responses = non_lofi_responses + 1 |
| + |
| + # Verify that Lo-Fi responses were seen. |
|
Robert Ogden
2017/04/25 19:22:40
s/were/were not/
RyanSturm
2017/04/25 19:27:58
Done.
|
| + self.assertNotEqual(0, non_lofi_responses) |
|
Robert Ogden
2017/04/25 19:22:39
Wouldn't checking there were no lofi responses mak
RyanSturm
2017/04/25 19:27:58
self.checkLoFiResponse(response, False) checks tha
|
| + |
| # Checks that Lo-Fi placeholder images are not loaded from cache on page |
| # reloads when Lo-Fi mode is disabled or data reduction proxy is disabled. |
| # First a test page is opened with Lo-Fi and chrome proxy enabled. This allows |