| 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 time | 5 import time |
| 6 | 6 |
| 7 import common | 7 import common |
| 8 from common import TestDriver | 8 from common import TestDriver |
| 9 from common import IntegrationTest | 9 from common import IntegrationTest |
| 10 from common import NotAndroid |
| 10 | 11 |
| 11 | 12 |
| 12 class Video(IntegrationTest): | 13 class Video(IntegrationTest): |
| 13 | 14 |
| 14 # Check videos are proxied. | 15 # Check videos are proxied. |
| 15 def testCheckVideoHasViaHeader(self): | 16 def testCheckVideoHasViaHeader(self): |
| 16 with TestDriver() as t: | 17 with TestDriver() as t: |
| 17 t.AddChromeArg('--enable-spdy-proxy-auth') | 18 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 18 t.LoadURL( | 19 t.LoadURL( |
| 19 'http://check.googlezip.net/cacheable/video/buck_bunny_tiny.html') | 20 'http://check.googlezip.net/cacheable/video/buck_bunny_tiny.html') |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 self.fail('Could not get a compressed video after %d tries' % attempts) | 111 self.fail('Could not get a compressed video after %d tries' % attempts) |
| 111 t.ExecuteJavascriptStatement('test.ready = true') | 112 t.ExecuteJavascriptStatement('test.ready = true') |
| 112 wait_time = int(t.ExecuteJavascriptStatement('test.waitTime')) | 113 wait_time = int(t.ExecuteJavascriptStatement('test.waitTime')) |
| 113 t.WaitForJavascriptExpression('test.metrics.complete', wait_time) | 114 t.WaitForJavascriptExpression('test.metrics.complete', wait_time) |
| 114 metrics = t.ExecuteJavascriptStatement('test.metrics') | 115 metrics = t.ExecuteJavascriptStatement('test.metrics') |
| 115 if not metrics['complete']: | 116 if not metrics['complete']: |
| 116 raise Exception('Test not complete after %d seconds.' % wait_time) | 117 raise Exception('Test not complete after %d seconds.' % wait_time) |
| 117 if metrics['failed']: | 118 if metrics['failed']: |
| 118 raise Exception('Test failed!') | 119 raise Exception('Test failed!') |
| 119 | 120 |
| 121 # Make sure YouTube autoplays. |
| 122 @NotAndroid |
| 123 def testYoutube(self): |
| 124 with TestDriver() as t: |
| 125 t.AddChromeArg('--enable-spdy-proxy-auth') |
| 126 t.LoadURL('http://data-saver-test.appspot.com/youtube') |
| 127 t.WaitForJavascriptExpression( |
| 128 'window.playerState == YT.PlayerState.PLAYING', 30) |
| 129 for response in t.GetHTTPResponses(): |
| 130 if not response.url.startswith('https'): |
| 131 self.assertHasChromeProxyViaHeader(response) |
| 132 |
| 120 if __name__ == '__main__': | 133 if __name__ == '__main__': |
| 121 IntegrationTest.RunAllTests() | 134 IntegrationTest.RunAllTests() |
| OLD | NEW |