Chromium Code Reviews| 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 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 ) | 35 ) |
| 36 saw_video_response = False | 36 saw_video_response = False |
| 37 for response in t.GetHTTPResponses(): | 37 for response in t.GetHTTPResponses(): |
| 38 if 'video' in response.response_headers['content-type']: | 38 if 'video' in response.response_headers['content-type']: |
| 39 self.assertNotHasChromeProxyViaHeader(response) | 39 self.assertNotHasChromeProxyViaHeader(response) |
| 40 saw_video_response = True | 40 saw_video_response = True |
| 41 else: | 41 else: |
| 42 self.assertHasChromeProxyViaHeader(response) | 42 self.assertHasChromeProxyViaHeader(response) |
| 43 self.assertTrue(saw_video_response, 'No video request seen in test!') | 43 self.assertTrue(saw_video_response, 'No video request seen in test!') |
| 44 | 44 |
| 45 # Check the compressed video has the same frame count, width, height, and | |
| 46 # duration as uncompressed. | |
| 47 def testVideoMetrics(self): | |
| 48 expected = { | |
| 49 'duration': 60.127, | |
| 50 'webkitDecodedFrameCount': 1080.0, | |
| 51 'videoWidth': 640.0, | |
| 52 'videoHeight': 360.0 | |
| 53 } | |
| 54 with TestDriver() as t: | |
| 55 t.AddChromeArg('--enable-spdy-proxy-auth') | |
| 56 t.LoadURL('http://check.googlezip.net/cacheable/video/buck_bunny_640x360_2 4fps_video.html') | |
| 57 # Check request vwas proxied and we got a compressed video back. | |
| 58 for response in t.GetHTTPResponses(): | |
| 59 self.assertHasChromeProxyViaHeader(response) | |
| 60 if ('content-type' in response.response_headers | |
| 61 and 'video' in response.response_headers['content-type']): | |
| 62 self.assertEqual('video/webm', | |
| 63 response.response_headers['content-type']) | |
| 64 t.ExecuteJavascriptStatement('document.getElementById("video").play()') | |
| 65 # Wait for the video to finish playing, plus some headroom. | |
| 66 time.sleep(80) | |
|
RyanSturm
2017/02/17 19:24:10
What is the impact of having a test that takes 80
Robert Ogden
2017/02/17 19:28:18
The test harness itself it happy to wait, but yes
Tom Bergan
2017/02/17 20:10:56
We should be able to use a shorter video. No reaso
bolian
2017/02/17 20:21:57
I am not sure how the test works internally. At le
| |
| 67 # Check each metric against its expected value. | |
| 68 for metric in expected: | |
| 69 actual = float(t.ExecuteJavascriptStatement( | |
| 70 'document.getElementById("video").%s' % metric)) | |
| 71 self.assertAlmostEqual(expected[metric], actual, msg="Compressed video " | |
| 72 "metric doesn't match expected! Metric=%s Expected=%f Actual=%f" | |
| 73 % (metric, expected[metric], actual), places=None, delta=0.25) | |
| 74 | |
| 45 # Check the frames of a compressed video. | 75 # Check the frames of a compressed video. |
| 46 def testVideoFrames(self): | 76 def testVideoFrames(self): |
| 47 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_video.html') | 77 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_video.html') |
| 48 | 78 |
| 49 # Check the audio volume of a compressed video. | 79 # Check the audio volume of a compressed video. |
| 50 def testVideoAudio(self): | 80 def testVideoAudio(self): |
| 51 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_audio.html') | 81 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_audio.html') |
| 52 | 82 |
| 53 def instrumentedVideoTest(self, url): | 83 def instrumentedVideoTest(self, url): |
| 54 """Run an instrumented video test. The given page is reloaded up to some | 84 """Run an instrumented video test. The given page is reloaded up to some |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 81 wait_time = int(t.ExecuteJavascriptStatement('test.waitTime')) | 111 wait_time = int(t.ExecuteJavascriptStatement('test.waitTime')) |
| 82 t.WaitForJavascriptExpression('test.metrics.complete', wait_time) | 112 t.WaitForJavascriptExpression('test.metrics.complete', wait_time) |
| 83 metrics = t.ExecuteJavascriptStatement('test.metrics') | 113 metrics = t.ExecuteJavascriptStatement('test.metrics') |
| 84 if not metrics['complete']: | 114 if not metrics['complete']: |
| 85 raise Exception('Test not complete after %d seconds.' % wait_time) | 115 raise Exception('Test not complete after %d seconds.' % wait_time) |
| 86 if metrics['failed']: | 116 if metrics['failed']: |
| 87 raise Exception('Test failed!') | 117 raise Exception('Test failed!') |
| 88 | 118 |
| 89 if __name__ == '__main__': | 119 if __name__ == '__main__': |
| 90 IntegrationTest.RunAllTests() | 120 IntegrationTest.RunAllTests() |
| OLD | NEW |