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

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

Issue 2696793003: Add video frames and volume tests (Closed)
Patch Set: rm unused imports 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
6
5 import common 7 import common
6 from common import TestDriver 8 from common import TestDriver
7 from common import IntegrationTest 9 from common import IntegrationTest
8 10
9 11
10 class Video(IntegrationTest): 12 class Video(IntegrationTest):
11 13
12 # Check videos are proxied. 14 # Check videos are proxied.
13 def testCheckVideoHasViaHeader(self): 15 def testCheckVideoHasViaHeader(self):
14 with TestDriver() as t: 16 with TestDriver() as t:
(...skipping 18 matching lines...) Expand all
33 ) 35 )
34 saw_video_response = False 36 saw_video_response = False
35 for response in t.GetHTTPResponses(): 37 for response in t.GetHTTPResponses():
36 if 'video' in response.response_headers['content-type']: 38 if 'video' in response.response_headers['content-type']:
37 self.assertNotHasChromeProxyViaHeader(response) 39 self.assertNotHasChromeProxyViaHeader(response)
38 saw_video_response = True 40 saw_video_response = True
39 else: 41 else:
40 self.assertHasChromeProxyViaHeader(response) 42 self.assertHasChromeProxyViaHeader(response)
41 self.assertTrue(saw_video_response, 'No video request seen in test!') 43 self.assertTrue(saw_video_response, 'No video request seen in test!')
42 44
45 # Check the frames of a compressed video.
46 def testVideoFrames(self):
47 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_video.html')
48
49 # Check the audio volume of a compressed video.
50 def testVideoAudio(self):
51 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_audio.html')
52
53 def instrumentedVideoTest(self, url):
54 """Run an instrumented video test. The given page is reloaded up to some
55 maximum number of times until a compressed video is seen by ChromeDriver by
56 inspecting the network logs. Once that happens, test.ready is set and that
57 will signal the Javascript test on the page to begin. Once it is complete,
58 check the results.
59 """
60 # The maximum number of times to attempt to reload the page for a compressed
61 # video.
62 max_attempts = 10
Tom Bergan 2017/02/14 18:27:18 Hopefully 10 attempts aren't actually necessary in
Robert Ogden 2017/02/14 18:57:32 Of the numerous times I've run it on my machine, i
63 with TestDriver() as t:
64 t.AddChromeArg('--enable-spdy-proxy-auth')
65 loaded_compressed_video = False
66 attempts = 0
67 while not loaded_compressed_video and attempts < max_attempts:
68 t.LoadURL(url)
69 attempts += 1
70 for resp in t.GetHTTPResponses():
71 self.assertHasChromeProxyViaHeader(resp)
Tom Bergan 2017/02/14 18:27:18 Will this assertion fail (and crash the test) on a
Robert Ogden 2017/02/14 18:57:32 Done.
72 if ('content-type' in resp.response_headers
73 and resp.response_headers['content-type'] == 'video/webm'):
74 loaded_compressed_video = True
75 else:
76 # Take a breath before requesting again.
77 time.sleep(1)
78 if attempts >= max_attempts:
79 self.fail('Could not get a compressed video after %d tries' % attempts)
80 t.ExecuteJavascriptStatement('test.ready = true')
81 wait_time = int(t.ExecuteJavascriptStatement('test.waitTime'))
82 t.WaitForJavascriptExpression('test.metrics.complete', wait_time)
83 metrics = t.ExecuteJavascriptStatement('test.metrics')
84 if not metrics['complete']:
85 raise Exception('Test not complete after %d seconds.' % wait_time)
86 if metrics['failed']:
87 raise Exception('Test failed!')
88
43 if __name__ == '__main__': 89 if __name__ == '__main__':
44 IntegrationTest.RunAllTests() 90 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