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