1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 from telemetry
.page
import page
as page_module
6 from telemetry
.page
import shared_page_state
7 from telemetry
import story
10 class ControllableProxySharedState(shared_page_state
.SharedPageState
):
12 def WillRunStory(self
, page
):
13 if page
.use_chrome_proxy
:
14 self
._finder
_options
.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
15 super(ControllableProxySharedState
, self
).WillRunStory(page
)
18 class VideoPage(page_module
.Page
):
19 """A test page containing a video.
22 use_chrome_proxy: If true, fetches use the data reduction proxy.
23 Otherwise, fetches are sent directly to the origin.
26 def __init__(self
, url
, page_set
, use_chrome_proxy
):
27 super(VideoPage
, self
).__init
__(
28 url
=url
, page_set
=page_set
,
29 shared_page_state_class
=ControllableProxySharedState
)
30 self
.use_chrome_proxy
= use_chrome_proxy
33 class VideoStorySet(story
.StorySet
):
34 """Base class for Chrome proxy video tests."""
36 def __init__(self
, mode
):
37 super(VideoStorySet
, self
).__init
__()
39 'http://check.googlezip.net/cacheable/video/buck_bunny_tiny.html',
42 self
._AddStoryForURL
(url
)
44 def _AddStoryForURL(self
, url
):
45 raise NotImplementedError
48 class VideoDirectStorySet(VideoStorySet
):
49 """Chrome proxy video tests: direct fetch."""
51 super(VideoDirectStorySet
, self
).__init
__('direct')
53 def _AddStoryForURL(self
, url
):
54 self
.AddStory(VideoPage(url
, self
, False))
57 class VideoProxiedStorySet(VideoStorySet
):
58 """Chrome proxy video tests: proxied fetch."""
60 super(VideoProxiedStorySet
, self
).__init
__('proxied')
62 def _AddStoryForURL(self
, url
):
63 self
.AddStory(VideoPage(url
, self
, True))
66 class VideoCompareStorySet(VideoStorySet
):
67 """Chrome proxy video tests: compare direct and proxied fetches."""
69 super(VideoCompareStorySet
, self
).__init
__('compare')
71 def _AddStoryForURL(self
, url
):
72 self
.AddStory(VideoPage(url
, self
, False))
73 self
.AddStory(VideoPage(url
, self
, True))