[Android WebViewShell] Add inclusion test for webview exposed stable interfaces.
[chromium-blink-merge.git] / tools / perf / page_sets / webrtc_cases.py
blob88e476f9ba45263510f158bb5760269241885475
1 # Copyright 2014 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.
4 import os
6 from telemetry.page import page as page_module
7 from telemetry import story
10 WEBRTC_GITHUB_SAMPLES_URL = 'http://webrtc.github.io/samples/src/content/'
13 class WebrtcCasesPage(page_module.Page):
15 def __init__(self, url, page_set, name):
16 super(WebrtcCasesPage, self).__init__(
17 url=url, page_set=page_set, name=name)
19 with open(os.path.join(os.path.dirname(__file__),
20 'webrtc_track_peerconnections.js')) as javascript:
21 self.script_to_evaluate_on_commit = javascript.read()
24 class Page1(WebrtcCasesPage):
26 """ Why: Acquires a vga local stream. """
28 def __init__(self, page_set):
29 super(Page1, self).__init__(
30 url=WEBRTC_GITHUB_SAMPLES_URL + 'getusermedia/gum/',
31 name='vga_local_stream_10s',
32 page_set=page_set)
34 def RunPageInteractions(self, action_runner):
35 action_runner.Wait(10)
38 class Page2(WebrtcCasesPage):
40 """ Why: Sets up a local WebRTC call. """
42 def __init__(self, page_set):
43 super(Page2, self).__init__(
44 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/pc1/',
45 name='vga_call_10s',
46 page_set=page_set)
48 def RunPageInteractions(self, action_runner):
49 action_runner.ClickElement('button[id="startButton"]')
50 action_runner.Wait(2)
51 action_runner.ClickElement('button[id="callButton"]')
52 action_runner.Wait(10)
53 action_runner.ClickElement('button[id="hangupButton"]')
56 class Page3(WebrtcCasesPage):
58 """ Why: Acquires a high definition local stream. """
60 def __init__(self, page_set):
61 super(Page3, self).__init__(
62 url=WEBRTC_GITHUB_SAMPLES_URL + 'getusermedia/resolution/',
63 name='hd_local_stream_10s',
64 page_set=page_set)
66 def RunPageInteractions(self, action_runner):
67 action_runner.ClickElement('button[id="hd"]')
68 action_runner.Wait(10)
71 class Page4(WebrtcCasesPage):
73 """ Why: Sets up a WebRTC audio call with Opus. """
75 def __init__(self, page_set):
76 super(Page4, self).__init__(
77 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/audio/?codec=OPUS',
78 name='audio_call_opus_10s',
79 page_set=page_set)
81 def RunPageInteractions(self, action_runner):
82 action_runner.ExecuteJavaScript('codecSelector.value="OPUS";')
83 action_runner.ClickElement('button[id="callButton"]')
84 action_runner.Wait(10)
87 class Page5(WebrtcCasesPage):
89 """ Why: Sets up a WebRTC audio call with G722. """
91 def __init__(self, page_set):
92 super(Page5, self).__init__(
93 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/audio/?codec=G722',
94 name='audio_call_g722_10s',
95 page_set=page_set)
97 def RunPageInteractions(self, action_runner):
98 action_runner.ExecuteJavaScript('codecSelector.value="G722";')
99 action_runner.ClickElement('button[id="callButton"]')
100 action_runner.Wait(10)
103 class Page6(WebrtcCasesPage):
105 """ Why: Sets up a WebRTC audio call with PCMU. """
107 def __init__(self, page_set):
108 super(Page6, self).__init__(
109 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/audio/?codec=PCMU',
110 name='audio_call_pcmu_10s',
111 page_set=page_set)
113 def RunPageInteractions(self, action_runner):
114 action_runner.ExecuteJavaScript('codecSelector.value="PCMU";')
115 action_runner.ClickElement('button[id="callButton"]')
116 action_runner.Wait(10)
119 class Page7(WebrtcCasesPage):
121 """ Why: Sets up a WebRTC audio call with iSAC 16K. """
123 def __init__(self, page_set):
124 super(Page7, self).__init__(
125 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/audio/?codec=ISAC_16K',
126 name='audio_call_isac16k_10s',
127 page_set=page_set)
129 def RunPageInteractions(self, action_runner):
130 action_runner.ExecuteJavaScript('codecSelector.value="ISAC/16000";')
131 action_runner.ClickElement('button[id="callButton"]')
132 action_runner.Wait(10)
135 class Page8(WebrtcCasesPage):
137 """ Why: Sets up a WebRTC 720p call for 45 seconds. """
139 def __init__(self, page_set):
140 super(Page8, self).__init__(
141 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/constraints/',
142 name='720p_call_45s',
143 page_set=page_set)
145 def RunPageInteractions(self, action_runner):
146 action_runner.ExecuteJavaScript('minWidthInput.value = 1280')
147 action_runner.ExecuteJavaScript('maxWidthInput.value = 1280')
148 action_runner.ExecuteJavaScript('minHeightInput.value = 720')
149 action_runner.ExecuteJavaScript('maxHeightInput.value = 720')
150 action_runner.ClickElement('button[id="getMedia"]')
151 action_runner.Wait(2)
152 action_runner.ClickElement('button[id="connect"]')
153 action_runner.Wait(45)
155 class Page9(WebrtcCasesPage):
157 """ Why: Transfer as much data as possible through a data channel in 20s. """
159 def __init__(self, page_set):
160 super(Page9, self).__init__(
161 url=WEBRTC_GITHUB_SAMPLES_URL + 'datachannel/datatransfer',
162 name="30s_datachannel_transfer",
163 page_set=page_set)
165 def RunPageInteractions(self, action_runner):
166 # It won't have time to finish the 512 MB, but we're only interested in
167 # cpu + memory anyway rather than how much data we manage to transfer.
168 action_runner.ExecuteJavaScript('megsToSend.value = 512;')
169 action_runner.ClickElement('button[id="sendTheData"]')
170 action_runner.Wait(30)
173 class WebrtcCasesPageSet(story.StorySet):
175 """ WebRTC tests for Real-time audio and video communication. """
177 def __init__(self):
178 super(WebrtcCasesPageSet, self).__init__(
179 archive_data_file='data/webrtc_cases.json',
180 cloud_storage_bucket=story.PUBLIC_BUCKET)
182 self.AddStory(Page1(self))
183 self.AddStory(Page2(self))
184 self.AddStory(Page3(self))
185 # Disable page 4-7 until we can implement http://crbug.com/468732. We can
186 # get data out from the tests, but it's not very useful yet.
187 self.AddStory(Page8(self))
188 self.AddStory(Page9(self))