| Index: tools/chrome_proxy/webdriver/video.py
|
| diff --git a/tools/chrome_proxy/webdriver/video.py b/tools/chrome_proxy/webdriver/video.py
|
| index 32e9aa3a7e576ba84d2a3da4b664f04be96fd408..ec0f6487a014f099041b8ed92b8678447aeaee29 100644
|
| --- a/tools/chrome_proxy/webdriver/video.py
|
| +++ b/tools/chrome_proxy/webdriver/video.py
|
| @@ -60,7 +60,8 @@ class Video(IntegrationTest):
|
| }
|
| with TestDriver() as t:
|
| t.AddChromeArg('--enable-spdy-proxy-auth')
|
| - t.LoadURL('http://check.googlezip.net/cacheable/video/buck_bunny_tiny.html')
|
| + t.LoadURL(
|
| + 'http://check.googlezip.net/cacheable/video/buck_bunny_tiny.html')
|
| # Check request was proxied and we got a compressed video back.
|
| for response in t.GetHTTPResponses():
|
| self.assertHasChromeProxyViaHeader(response)
|
| @@ -83,6 +84,68 @@ class Video(IntegrationTest):
|
| "metric doesn't match expected! Metric=%s Expected=%f Actual=%f"
|
| % (metric, expected[metric], actual), places=None, delta=0.001)
|
|
|
| + # Check that the compressed video can be seeked. Use a slow network to ensure
|
| + # the entire video isn't downloaded before we have a chance to seek.
|
| + #
|
| + # This test cannot run on android because of control_network_connection=True.
|
| + # That option is used to reduce flakes that might happen on fast networks,
|
| + # where the video is completely downloaded before a seeking request can be
|
| + # sent. The test can be manually simulated by the following steps: set network
|
| + # emulation in DevTools on Android (via device inspector), load a video, pause
|
| + # the video, then seek and verify the seek continues to play the video.
|
| + @Slow
|
| + @NotAndroid
|
| + def testVideoSeeking(self):
|
| + with TestDriver(control_network_connection=True) as t:
|
| + t.SetNetworkConnection("3G")
|
| + t.AddChromeArg('--enable-spdy-proxy-auth')
|
| + t.LoadURL(
|
| + 'http://check.googlezip.net/cacheable/video/'+
|
| + 'buck_bunny_640x360_24fps.html')
|
| + # Play, pause, seek to 1s before the end, play again.
|
| + t.ExecuteJavascript(
|
| + '''
|
| + window.testDone = false;
|
| + const v = document.getElementsByTagName("video")[0];
|
| + let first = true;
|
| + v.onplaying = function() {
|
| + if (first) {
|
| + v.pause();
|
| + first = false;
|
| + } else {
|
| + window.testDone = true;
|
| + }
|
| + };
|
| + v.onpause = function() {
|
| + if (v.currentTime < v.duration) {
|
| + v.currentTime = v.duration-1;
|
| + v.play();
|
| + }
|
| + };
|
| + v.play();
|
| + ''')
|
| + t.WaitForJavascriptExpression('window.testDone', 10)
|
| + # Check request was proxied and we got a compressed video back.
|
| + # We expect to make multiple requests for the video: ensure they
|
| + # all have the same ETag.
|
| + video_etag = None
|
| + num_partial_requests = 0
|
| + for response in t.GetHTTPResponses():
|
| + self.assertHasChromeProxyViaHeader(response)
|
| + rh = response.response_headers
|
| + if ('content-type' in rh and 'video' in rh['content-type']):
|
| + self.assertTrue('etag' in rh),
|
| + self.assertEqual('video/webm', rh['content-type'])
|
| + if video_etag == None:
|
| + video_etag = rh['etag']
|
| + else:
|
| + self.assertEqual(video_etag, rh['etag'])
|
| + if ('range' in response.request_headers and
|
| + response.request_headers['range'] != 'bytes=0-'):
|
| + num_partial_requests += 1
|
| + # Also make sure that we had at least one partial Range request.
|
| + self.assertGreaterEqual(num_partial_requests, 1)
|
| +
|
| # Check the frames of a compressed video.
|
| @Slow
|
| def testVideoFrames(self):
|
|
|