Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: tools/chrome_proxy/webdriver/video.py

Issue 2702753002: Add video metrics integration test (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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,
Tom Bergan 2017/02/17 18:20:48 I haven't done the math, but at first glance, this
Robert Ogden 2017/02/17 18:49:28 Done.
RyanSturm 2017/02/17 19:24:10 As a nit on a nit, delta=0.25 is way, way bigger t
Robert Ogden 2017/02/17 19:28:18 Done.
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)
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.assertEqual(expected[metric], actual, "Compressed video metric "
72 "doesn't match expected! Metric=%s Expected=%f Actual=%f"
73 % (metric, expected[metric], actual))
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
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()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698