OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 import os | 4 import os |
5 | 5 |
6 from telemetry import story | 6 from telemetry import story |
7 from telemetry.page import page as page_module | 7 from telemetry.page import page as page_module |
8 | 8 |
9 | 9 |
10 WEBRTC_TEST_PAGES_URL = 'https://test.webrtc.org/manual/' | |
11 WEBRTC_GITHUB_SAMPLES_URL = 'https://webrtc.github.io/samples/src/content/' | |
12 MEDIARECORDER_GITHUB_URL = 'https://rawgit.com/cricdecyan/mediarecorder/master/' | |
13 | |
14 | |
15 class WebrtcPage(page_module.Page): | 10 class WebrtcPage(page_module.Page): |
16 | 11 |
17 def __init__(self, url, page_set, name): | 12 def __init__(self, url, page_set, name): |
| 13 assert url.startswith('file://webrtc_cases/') |
18 super(WebrtcPage, self).__init__( | 14 super(WebrtcPage, self).__init__( |
19 url=url, page_set=page_set, name=name) | 15 url=url, page_set=page_set, name=name) |
20 | 16 |
21 with open(os.path.join(os.path.dirname(__file__), | 17 with open(os.path.join(os.path.dirname(__file__), |
22 'webrtc_track_peerconnections.js')) as javascript: | 18 'webrtc_track_peerconnections.js')) as javascript: |
23 self.script_to_evaluate_on_commit = javascript.read() | 19 self.script_to_evaluate_on_commit = javascript.read() |
24 | 20 |
25 | 21 |
26 class Page1(WebrtcPage): | 22 class Page1(WebrtcPage): |
27 """Why: Acquires a high definition (720p) local stream.""" | 23 """Why: Acquires a high definition (720p) local stream.""" |
28 | 24 |
29 def __init__(self, page_set): | 25 def __init__(self, page_set): |
30 super(Page1, self).__init__( | 26 super(Page1, self).__init__( |
31 url=WEBRTC_GITHUB_SAMPLES_URL + 'getusermedia/resolution/', | 27 url='file://webrtc_cases/resolution.html', |
32 name='hd_local_stream_10s', | 28 name='hd_local_stream_10s', |
33 page_set=page_set) | 29 page_set=page_set) |
34 | 30 |
35 def RunPageInteractions(self, action_runner): | 31 def RunPageInteractions(self, action_runner): |
36 action_runner.ClickElement('button[id="hd"]') | 32 action_runner.ClickElement('button[id="hd"]') |
37 action_runner.Wait(10) | 33 action_runner.Wait(10) |
38 | 34 |
39 | 35 |
40 class Page2(WebrtcPage): | 36 class Page2(WebrtcPage): |
41 """Why: Sets up a local video-only WebRTC 720p call for 45 seconds.""" | 37 """Why: Sets up a local video-only WebRTC 720p call for 45 seconds.""" |
42 | 38 |
43 def __init__(self, page_set): | 39 def __init__(self, page_set): |
44 super(Page2, self).__init__( | 40 super(Page2, self).__init__( |
45 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/constraints/', | 41 url='file://webrtc_cases/constraints.html', |
46 name='720p_call_45s', | 42 name='720p_call_45s', |
47 page_set=page_set) | 43 page_set=page_set) |
48 | 44 |
49 def RunPageInteractions(self, action_runner): | 45 def RunPageInteractions(self, action_runner): |
50 with action_runner.CreateInteraction('Action_Create_PeerConnection', | 46 with action_runner.CreateInteraction('Action_Create_PeerConnection', |
51 repeatable=False): | 47 repeatable=False): |
52 action_runner.ExecuteJavaScript('minWidthInput.value = 1280') | 48 action_runner.ExecuteJavaScript('minWidthInput.value = 1280') |
53 action_runner.ExecuteJavaScript('maxWidthInput.value = 1280') | 49 action_runner.ExecuteJavaScript('maxWidthInput.value = 1280') |
54 action_runner.ExecuteJavaScript('minHeightInput.value = 720') | 50 action_runner.ExecuteJavaScript('minHeightInput.value = 720') |
55 action_runner.ExecuteJavaScript('maxHeightInput.value = 720') | 51 action_runner.ExecuteJavaScript('maxHeightInput.value = 720') |
56 action_runner.ClickElement('button[id="getMedia"]') | 52 action_runner.ClickElement('button[id="getMedia"]') |
57 action_runner.Wait(2) | 53 action_runner.Wait(2) |
58 action_runner.ClickElement('button[id="connect"]') | 54 action_runner.ClickElement('button[id="connect"]') |
59 action_runner.Wait(45) | 55 action_runner.Wait(45) |
60 | 56 |
61 | 57 |
62 class Page3(WebrtcPage): | 58 class Page3(WebrtcPage): |
63 """Why: Transfer as much data as possible through a data channel in 20s.""" | 59 """Why: Transfer as much data as possible through a data channel in 20s.""" |
64 | 60 |
65 def __init__(self, page_set): | 61 def __init__(self, page_set): |
66 super(Page3, self).__init__( | 62 super(Page3, self).__init__( |
67 url=WEBRTC_GITHUB_SAMPLES_URL + 'datachannel/datatransfer', | 63 url='file://webrtc_cases/datatransfer.html', |
68 name='30s_datachannel_transfer', | 64 name='30s_datachannel_transfer', |
69 page_set=page_set) | 65 page_set=page_set) |
70 | 66 |
71 def RunPageInteractions(self, action_runner): | 67 def RunPageInteractions(self, action_runner): |
72 # It won't have time to finish the 512 MB, but we're only interested in | 68 # It won't have time to finish the 512 MB, but we're only interested in |
73 # cpu + memory anyway rather than how much data we manage to transfer. | 69 # cpu + memory anyway rather than how much data we manage to transfer. |
74 action_runner.ExecuteJavaScript('megsToSend.value = 512;') | 70 action_runner.ExecuteJavaScript('megsToSend.value = 512;') |
75 action_runner.ClickElement('button[id="sendTheData"]') | 71 action_runner.ClickElement('button[id="sendTheData"]') |
76 action_runner.Wait(30) | 72 action_runner.Wait(30) |
77 | 73 |
78 | 74 |
79 class Page4(WebrtcPage): | 75 class Page4(WebrtcPage): |
80 """Why: Sets up a WebRTC audio call with Opus.""" | 76 """Why: Sets up a WebRTC audio call with Opus.""" |
81 | 77 |
82 def __init__(self, page_set): | 78 def __init__(self, page_set): |
83 super(Page4, self).__init__( | 79 super(Page4, self).__init__( |
84 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/audio/?codec=OPUS', | 80 url='file://webrtc_cases/audio.html?codec=OPUS', |
85 name='audio_call_opus_10s', | 81 name='audio_call_opus_10s', |
86 page_set=page_set) | 82 page_set=page_set) |
87 | 83 |
88 def RunPageInteractions(self, action_runner): | 84 def RunPageInteractions(self, action_runner): |
89 action_runner.ExecuteJavaScript('codecSelector.value="OPUS";') | 85 action_runner.ExecuteJavaScript('codecSelector.value="OPUS";') |
90 action_runner.ClickElement('button[id="callButton"]') | 86 action_runner.ClickElement('button[id="callButton"]') |
91 action_runner.Wait(10) | 87 action_runner.Wait(10) |
92 | 88 |
93 | 89 |
94 class Page5(WebrtcPage): | 90 class Page5(WebrtcPage): |
95 """Why: Sets up a WebRTC audio call with G722.""" | 91 """Why: Sets up a WebRTC audio call with G722.""" |
96 | 92 |
97 def __init__(self, page_set): | 93 def __init__(self, page_set): |
98 super(Page5, self).__init__( | 94 super(Page5, self).__init__( |
99 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/audio/?codec=G722', | 95 url='file://webrtc_cases/audio.html?codec=G722', |
100 name='audio_call_g722_10s', | 96 name='audio_call_g722_10s', |
101 page_set=page_set) | 97 page_set=page_set) |
102 | 98 |
103 def RunPageInteractions(self, action_runner): | 99 def RunPageInteractions(self, action_runner): |
104 action_runner.ExecuteJavaScript('codecSelector.value="G722";') | 100 action_runner.ExecuteJavaScript('codecSelector.value="G722";') |
105 action_runner.ClickElement('button[id="callButton"]') | 101 action_runner.ClickElement('button[id="callButton"]') |
106 action_runner.Wait(10) | 102 action_runner.Wait(10) |
107 | 103 |
108 | 104 |
109 class Page6(WebrtcPage): | 105 class Page6(WebrtcPage): |
110 """Why: Sets up a WebRTC audio call with PCMU.""" | 106 """Why: Sets up a WebRTC audio call with PCMU.""" |
111 | 107 |
112 def __init__(self, page_set): | 108 def __init__(self, page_set): |
113 super(Page6, self).__init__( | 109 super(Page6, self).__init__( |
114 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/audio/?codec=PCMU', | 110 url='file://webrtc_cases/audio.html?codec=PCMU', |
115 name='audio_call_pcmu_10s', | 111 name='audio_call_pcmu_10s', |
116 page_set=page_set) | 112 page_set=page_set) |
117 | 113 |
118 def RunPageInteractions(self, action_runner): | 114 def RunPageInteractions(self, action_runner): |
119 action_runner.ExecuteJavaScript('codecSelector.value="PCMU";') | 115 action_runner.ExecuteJavaScript('codecSelector.value="PCMU";') |
120 action_runner.ClickElement('button[id="callButton"]') | 116 action_runner.ClickElement('button[id="callButton"]') |
121 action_runner.Wait(10) | 117 action_runner.Wait(10) |
122 | 118 |
123 | 119 |
124 class Page7(WebrtcPage): | 120 class Page7(WebrtcPage): |
125 """Why: Sets up a WebRTC audio call with iSAC 16K.""" | 121 """Why: Sets up a WebRTC audio call with iSAC 16K.""" |
126 | 122 |
127 def __init__(self, page_set): | 123 def __init__(self, page_set): |
128 super(Page7, self).__init__( | 124 super(Page7, self).__init__( |
129 url=WEBRTC_GITHUB_SAMPLES_URL + 'peerconnection/audio/?codec=ISAC_16K', | 125 url='file://webrtc_cases/audio.html?codec=ISAC_16K', |
130 name='audio_call_isac16k_10s', | 126 name='audio_call_isac16k_10s', |
131 page_set=page_set) | 127 page_set=page_set) |
132 | 128 |
133 def RunPageInteractions(self, action_runner): | 129 def RunPageInteractions(self, action_runner): |
134 action_runner.ExecuteJavaScript('codecSelector.value="ISAC/16000";') | 130 action_runner.ExecuteJavaScript('codecSelector.value="ISAC/16000";') |
135 action_runner.ClickElement('button[id="callButton"]') | 131 action_runner.ClickElement('button[id="callButton"]') |
136 action_runner.Wait(10) | 132 action_runner.Wait(10) |
137 | 133 |
138 | 134 |
139 class Page8(WebrtcPage): | 135 class Page8(WebrtcPage): |
140 """Why: Sets up a canvas capture stream connection to a peer connection.""" | 136 """Why: Sets up a canvas capture stream connection to a peer connection.""" |
141 | 137 |
142 def __init__(self, page_set): | 138 def __init__(self, page_set): |
143 canvas_capure_html = 'canvascapture/canvas_capture_peerconnection.html' | |
144 super(Page8, self).__init__( | 139 super(Page8, self).__init__( |
145 url=MEDIARECORDER_GITHUB_URL + canvas_capure_html, | 140 url='file://webrtc_cases/canvas-capture.html', |
146 name='canvas_capture_peer_connection', | 141 name='canvas_capture_peer_connection', |
147 page_set=page_set) | 142 page_set=page_set) |
148 | 143 |
149 def RunPageInteractions(self, action_runner): | 144 def RunPageInteractions(self, action_runner): |
150 with action_runner.CreateInteraction('Action_Canvas_PeerConnection', | 145 with action_runner.CreateInteraction('Action_Canvas_PeerConnection', |
151 repeatable=False): | 146 repeatable=False): |
152 action_runner.WaitForJavaScriptCondition('typeof draw !== "undefined"') | 147 action_runner.ClickElement('button[id="startButton"]') |
153 action_runner.ExecuteJavaScript('draw();') | |
154 action_runner.ExecuteJavaScript('doCanvasCaptureAndPeerConnection();') | |
155 action_runner.Wait(10) | 148 action_runner.Wait(10) |
156 | 149 |
157 | 150 |
158 class Page9(WebrtcPage): | 151 class Page9(WebrtcPage): |
159 """Why: Sets up several peerconnections in the same page.""" | 152 """Why: Sets up several peerconnections in the same page.""" |
160 | 153 |
161 def __init__(self, page_set): | 154 def __init__(self, page_set): |
162 super(Page9, self).__init__( | 155 super(Page9, self).__init__( |
163 url= WEBRTC_TEST_PAGES_URL + 'multiple-peerconnections/', | 156 url='file://webrtc_cases/multiple-peerconnections.html', |
164 name='multiple_peerconnections', | 157 name='multiple_peerconnections', |
165 page_set=page_set) | 158 page_set=page_set) |
166 | 159 |
167 def RunPageInteractions(self, action_runner): | 160 def RunPageInteractions(self, action_runner): |
168 with action_runner.CreateInteraction('Action_Create_PeerConnection', | 161 with action_runner.CreateInteraction('Action_Create_PeerConnection', |
169 repeatable=False): | 162 repeatable=False): |
170 # Set the number of peer connections to create to 15. | 163 # Set the number of peer connections to create to 15. |
171 action_runner.ExecuteJavaScript( | 164 action_runner.ExecuteJavaScript( |
172 'document.getElementById("num-peerconnections").value=15') | 165 'document.getElementById("num-peerconnections").value=15') |
173 action_runner.ExecuteJavaScript( | 166 action_runner.ExecuteJavaScript( |
174 'document.getElementById("cpuoveruse-detection").checked=false') | 167 'document.getElementById("cpuoveruse-detection").checked=false') |
175 action_runner.ClickElement('button[id="start-test"]') | 168 action_runner.ClickElement('button[id="start-test"]') |
176 action_runner.Wait(45) | 169 action_runner.Wait(45) |
177 | 170 |
178 | 171 |
179 class WebrtcGetusermediaPageSet(story.StorySet): | 172 class WebrtcGetusermediaPageSet(story.StorySet): |
180 """WebRTC tests for local getUserMedia: video capture and playback.""" | 173 """WebRTC tests for local getUserMedia: video capture and playback.""" |
181 | 174 |
182 def __init__(self): | 175 def __init__(self): |
183 super(WebrtcGetusermediaPageSet, self).__init__( | 176 super(WebrtcGetusermediaPageSet, self).__init__( |
184 archive_data_file='data/webrtc_getusermedia_cases.json', | |
185 cloud_storage_bucket=story.PUBLIC_BUCKET) | 177 cloud_storage_bucket=story.PUBLIC_BUCKET) |
186 | 178 |
187 self.AddStory(Page1(self)) | 179 self.AddStory(Page1(self)) |
188 | 180 |
189 | 181 |
190 class WebrtcStresstestPageSet(story.StorySet): | 182 class WebrtcStresstestPageSet(story.StorySet): |
191 """WebRTC stress-testing with multiple peer connections.""" | 183 """WebRTC stress-testing with multiple peer connections.""" |
192 | 184 |
193 def __init__(self): | 185 def __init__(self): |
194 super(WebrtcStresstestPageSet, self).__init__( | 186 super(WebrtcStresstestPageSet, self).__init__( |
195 archive_data_file='data/webrtc_stresstest_cases.json', | |
196 cloud_storage_bucket=story.PUBLIC_BUCKET) | 187 cloud_storage_bucket=story.PUBLIC_BUCKET) |
197 | 188 |
198 self.AddStory(Page9(self)) | 189 self.AddStory(Page9(self)) |
199 | 190 |
200 | 191 |
201 class WebrtcPeerconnectionPageSet(story.StorySet): | 192 class WebrtcPeerconnectionPageSet(story.StorySet): |
202 """WebRTC tests for Real-time video and audio communication.""" | 193 """WebRTC tests for Real-time video and audio communication.""" |
203 | 194 |
204 def __init__(self): | 195 def __init__(self): |
205 super(WebrtcPeerconnectionPageSet, self).__init__( | 196 super(WebrtcPeerconnectionPageSet, self).__init__( |
206 archive_data_file='data/webrtc_peerconnection_cases.json', | |
207 cloud_storage_bucket=story.PUBLIC_BUCKET) | 197 cloud_storage_bucket=story.PUBLIC_BUCKET) |
208 | 198 |
209 self.AddStory(Page2(self)) | 199 self.AddStory(Page2(self)) |
210 | 200 |
211 | 201 |
212 class WebrtcDatachannelPageSet(story.StorySet): | 202 class WebrtcDatachannelPageSet(story.StorySet): |
213 """WebRTC tests for Real-time communication via the data channel.""" | 203 """WebRTC tests for Real-time communication via the data channel.""" |
214 | 204 |
215 def __init__(self): | 205 def __init__(self): |
216 super(WebrtcDatachannelPageSet, self).__init__( | 206 super(WebrtcDatachannelPageSet, self).__init__( |
217 archive_data_file='data/webrtc_datachannel_cases.json', | |
218 cloud_storage_bucket=story.PUBLIC_BUCKET) | 207 cloud_storage_bucket=story.PUBLIC_BUCKET) |
219 | 208 |
220 self.AddStory(Page3(self)) | 209 self.AddStory(Page3(self)) |
221 | 210 |
222 | 211 |
223 class WebrtcAudioPageSet(story.StorySet): | 212 class WebrtcAudioPageSet(story.StorySet): |
224 """WebRTC tests for Real-time audio communication.""" | 213 """WebRTC tests for Real-time audio communication.""" |
225 | 214 |
226 def __init__(self): | 215 def __init__(self): |
227 super(WebrtcAudioPageSet, self).__init__( | 216 super(WebrtcAudioPageSet, self).__init__( |
228 archive_data_file='data/webrtc_audio_cases.json', | |
229 cloud_storage_bucket=story.PUBLIC_BUCKET) | 217 cloud_storage_bucket=story.PUBLIC_BUCKET) |
230 | 218 |
231 self.AddStory(Page4(self)) | 219 self.AddStory(Page4(self)) |
232 self.AddStory(Page5(self)) | 220 self.AddStory(Page5(self)) |
233 self.AddStory(Page6(self)) | 221 self.AddStory(Page6(self)) |
234 self.AddStory(Page7(self)) | 222 self.AddStory(Page7(self)) |
235 | 223 |
236 | 224 |
237 class WebrtcRenderingPageSet(story.StorySet): | 225 class WebrtcRenderingPageSet(story.StorySet): |
238 """WebRTC tests for video rendering.""" | 226 """WebRTC tests for video rendering.""" |
239 | 227 |
240 def __init__(self): | 228 def __init__(self): |
241 super(WebrtcRenderingPageSet, self).__init__( | 229 super(WebrtcRenderingPageSet, self).__init__( |
242 archive_data_file='data/webrtc_smoothness_cases.json', | |
243 cloud_storage_bucket=story.PARTNER_BUCKET) | 230 cloud_storage_bucket=story.PARTNER_BUCKET) |
244 | 231 |
245 self.AddStory(Page2(self)) | 232 self.AddStory(Page2(self)) |
246 self.AddStory(Page8(self)) | 233 self.AddStory(Page8(self)) |
OLD | NEW |