| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 common | 5 import common |
| 6 import time | 6 import time |
| 7 from common import TestDriver | 7 from common import TestDriver |
| 8 from common import IntegrationTest | 8 from common import IntegrationTest |
| 9 from common import NotAndroid | 9 from common import NotAndroid |
| 10 | 10 |
| 11 | 11 |
| 12 class Smoke(IntegrationTest): | 12 class Smoke(IntegrationTest): |
| 13 | 13 |
| 14 # Ensure Chrome does not use DataSaver in Incognito mode. | 14 # Ensure Chrome does not use DataSaver in Incognito mode. |
| 15 # Clank does not honor the --incognito flag. | 15 # Clank does not honor the --incognito flag. |
| 16 @NotAndroid | 16 @NotAndroid |
| 17 def testCheckPageWithIncognito(self): | 17 def testCheckPageWithIncognito(self): |
| 18 with TestDriver() as t: | 18 with TestDriver() as t: |
| 19 t.AddChromeArg('--enable-spdy-proxy-auth') | 19 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 20 t.AddChromeArg('--incognito') | 20 t.AddChromeArg('--incognito') |
| 21 t.LoadURL('http://check.googlezip.net/test.html') | 21 t.LoadURL('http://check.googlezip.net/test.html') |
| 22 for response in t.GetHTTPResponses(): | 22 for response in t.GetHTTPResponses(): |
| 23 self.assertNotHasChromeProxyViaHeader(response) | 23 self.assertNotHasChromeProxyViaHeader(response) |
| 24 | |
| 25 # Ensure Chrome uses DataSaver with QUIC enabled. | |
| 26 def testCheckPageWithQuicProxy(self): | |
| 27 with TestDriver() as t: | |
| 28 t.AddChromeArg('--enable-spdy-proxy-auth') | |
| 29 t.AddChromeArg('--enable-quic') | |
| 30 t.AddChromeArg('--data-reduction-proxy-http-proxies=https://proxy.googlezi
p.net:443') | |
| 31 t.AddChromeArg('--force-fieldtrials=DataReductionProxyUseQuic/Enabled') | |
| 32 t.LoadURL('http://check.googlezip.net/test.html') | |
| 33 responses = t.GetHTTPResponses() | |
| 34 self.assertEqual(2, len(responses)) | |
| 35 for response in responses: | |
| 36 self.assertHasChromeProxyViaHeader(response) | |
| 37 | |
| 38 # Verify that histogram DataReductionProxy.Quic.ProxyStatus has at least 1 | |
| 39 # sample. This sample must be in bucket 0 (QUIC_PROXY_STATUS_AVAILABLE). | |
| 40 proxy_status = t.GetHistogram('DataReductionProxy.Quic.ProxyStatus') | |
| 41 self.assertLessEqual(1, proxy_status['count']) | |
| 42 self.assertEqual(0, proxy_status['sum']) | |
| 43 | |
| 44 # Navigate to one more page to ensure that established QUIC connection | |
| 45 # is used for the next request. Give 3 seconds extra headroom for the QUIC | |
| 46 # connection to be established. | |
| 47 time.sleep(3) | |
| 48 t.LoadURL('http://check.googlezip.net/test.html') | |
| 49 proxy_usage = t.GetHistogram('Net.QuicAlternativeProxy.Usage') | |
| 50 # Bucket ALTERNATIVE_PROXY_USAGE_NO_RACE should have at least onesample. | |
| 51 self.assertLessEqual(1, proxy_usage['buckets'][0]['count']) | |
| 52 | 24 |
| 53 # Ensure Chrome uses DataSaver in normal mode. | 25 # Ensure Chrome uses DataSaver in normal mode. |
| 54 def testCheckPageWithNormalMode(self): | 26 def testCheckPageWithNormalMode(self): |
| 55 with TestDriver() as t: | 27 with TestDriver() as t: |
| 56 t.AddChromeArg('--enable-spdy-proxy-auth') | 28 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 57 t.LoadURL('http://check.googlezip.net/test.html') | 29 t.LoadURL('http://check.googlezip.net/test.html') |
| 58 responses = t.GetHTTPResponses() | 30 responses = t.GetHTTPResponses() |
| 59 self.assertNotEqual(0, len(responses)) | 31 self.assertNotEqual(0, len(responses)) |
| 60 for response in responses: | 32 for response in responses: |
| 61 self.assertHasChromeProxyViaHeader(response) | 33 self.assertHasChromeProxyViaHeader(response) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 t.LoadURL('http://check.googlezip.net/static') | 82 t.LoadURL('http://check.googlezip.net/static') |
| 111 # http://check.googlezip.net/static is a test page that has | 83 # http://check.googlezip.net/static is a test page that has |
| 112 # image/css/javascript resources. | 84 # image/css/javascript resources. |
| 113 responses = t.GetHTTPResponses() | 85 responses = t.GetHTTPResponses() |
| 114 self.assertNotEqual(0, len(responses)) | 86 self.assertNotEqual(0, len(responses)) |
| 115 for response in responses: | 87 for response in responses: |
| 116 self.assertHasChromeProxyViaHeader(response) | 88 self.assertHasChromeProxyViaHeader(response) |
| 117 | 89 |
| 118 if __name__ == '__main__': | 90 if __name__ == '__main__': |
| 119 IntegrationTest.RunAllTests() | 91 IntegrationTest.RunAllTests() |
| OLD | NEW |