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

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

Issue 2886893010: Add Video.testVideoSeeking test. (Closed)
Patch Set: Created 3 years, 7 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 | « tools/chrome_proxy/webdriver/common.py ('k') | 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 from common import ParseFlags 10 from common import ParseFlags
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 # Wait for the video to finish playing, plus some headroom. 76 # Wait for the video to finish playing, plus some headroom.
77 time.sleep(5) 77 time.sleep(5)
78 # Check each metric against its expected value. 78 # Check each metric against its expected value.
79 for metric in expected: 79 for metric in expected:
80 actual = float(t.ExecuteJavascriptStatement( 80 actual = float(t.ExecuteJavascriptStatement(
81 'document.querySelectorAll("video")[0].%s' % metric)) 81 'document.querySelectorAll("video")[0].%s' % metric))
82 self.assertAlmostEqual(expected[metric], actual, msg="Compressed video " 82 self.assertAlmostEqual(expected[metric], actual, msg="Compressed video "
83 "metric doesn't match expected! Metric=%s Expected=%f Actual=%f" 83 "metric doesn't match expected! Metric=%s Expected=%f Actual=%f"
84 % (metric, expected[metric], actual), places=None, delta=0.001) 84 % (metric, expected[metric], actual), places=None, delta=0.001)
85 85
86 # Check that the compressed video can be seeked. Use a slow network to ensure
87 # the entire video isn't downloaded before we have a chance to seek.
88 @Slow
89 @NotAndroid
RyanSturm 2017/05/22 21:32:01 t.FindElement(By.ID, 'video').click() might work o
Robert Ogden 2017/05/22 21:34:53 this test can't be android because ` with TestDriv
Tom Bergan 2017/05/22 22:18:36 I added a comment explaining why I added control_n
Robert Ogden 2017/05/22 23:00:27 From what I came across implementing the feature,
RyanSturm 2017/05/22 23:09:16 Thanks for the comment. Let's land as is.
90 def testVideoSeeking(self):
91 with TestDriver(control_network_connection=True) as t:
92 t.SetNetworkConnection("3G")
93 t.AddChromeArg('--enable-spdy-proxy-auth')
94 t.LoadURL('http://check.googlezip.net/cacheable/video/buck_bunny_640x360_2 4fps.html')
RyanSturm 2017/05/22 21:32:02 nit: can you split this over 2 lines (80 char limi
Tom Bergan 2017/05/22 22:18:36 Done.
RyanSturm 2017/05/22 23:09:16 Not seeing the change here.
Tom Bergan 2017/05/22 23:15:14 Done for real.
Tom Bergan 2017/05/22 23:16:47 Err, I fixed the wrong one. Now fixed for real.
95 # Play, pause, seek to 1s before the end, play again.
96 t.ExecuteJavascript(
97 '''
98 window.testDone = false;
99 const v = document.getElementsByTagName("video")[0];
100 let first = true;
101 v.onplaying = function() {
102 if (first) {
103 v.pause();
104 first = false;
105 } else {
106 window.testDone = true;
107 }
108 };
109 v.onpause = function() {
110 if (v.currentTime < v.duration) {
111 v.currentTime = v.duration-1;
112 v.play();
113 }
114 };
115 v.play();
116 ''')
117 t.WaitForJavascriptExpression('window.testDone', 10)
118 # Check request was proxied and we got a compressed video back.
119 # We expect to make multiple requests for the video: ensure they
120 # all have the same ETag.
121 video_etag = None
122 num_range_requests = 0
123 for response in t.GetHTTPResponses():
124 self.assertHasChromeProxyViaHeader(response)
125 rh = response.response_headers
126 if ('content-type' in rh and 'video' in rh['content-type']):
127 self.assertTrue('etag' in rh),
128 self.assertEqual('video/webm', rh['content-type'])
129 if video_etag == None:
130 video_etag = rh['etag']
131 else:
132 self.assertEqual(video_etag, rh['etag'])
133 if ('range' in response.request_headers and
134 response.request_headers['range'] != 'bytes=0-'):
RyanSturm 2017/05/22 21:32:01 Are all the range requests of the form 0-? I thoug
Tom Bergan 2017/05/22 22:18:36 s/num_range_requests/num_partial_requests/ When t
RyanSturm 2017/05/22 23:09:16 Ah I see. I read the condition wrong. Thanks for r
135 num_range_requests += 1
136 # Also make sure that we had at least one Range request.
137 self.assertGreaterEqual(num_range_requests, 1)
138
86 # Check the frames of a compressed video. 139 # Check the frames of a compressed video.
87 @Slow 140 @Slow
88 def testVideoFrames(self): 141 def testVideoFrames(self):
89 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_video.html') 142 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_video.html')
90 143
91 # Check the audio volume of a compressed video. 144 # Check the audio volume of a compressed video.
92 @NotAndroid 145 @NotAndroid
93 @Slow 146 @Slow
94 def testVideoAudio(self): 147 def testVideoAudio(self):
95 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_audio.html') 148 self.instrumentedVideoTest('http://check.googlezip.net/cacheable/video/buck_ bunny_640x360_24fps_audio.html')
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 # Video won't auto play on Android, so give it a click. 195 # Video won't auto play on Android, so give it a click.
143 t.FindElement(By.ID, 'player').click() 196 t.FindElement(By.ID, 'player').click()
144 t.WaitForJavascriptExpression( 197 t.WaitForJavascriptExpression(
145 'window.playerState == YT.PlayerState.PLAYING', 30) 198 'window.playerState == YT.PlayerState.PLAYING', 30)
146 for response in t.GetHTTPResponses(): 199 for response in t.GetHTTPResponses():
147 if not response.url.startswith('https'): 200 if not response.url.startswith('https'):
148 self.assertHasChromeProxyViaHeader(response) 201 self.assertHasChromeProxyViaHeader(response)
149 202
150 if __name__ == '__main__': 203 if __name__ == '__main__':
151 IntegrationTest.RunAllTests() 204 IntegrationTest.RunAllTests()
OLDNEW
« no previous file with comments | « tools/chrome_proxy/webdriver/common.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698