| 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): |
| 32 action_runner.ClickElement('button[id="hd"]') | 27 action_runner.ClickElement('button[id="hd"]') |
| 33 action_runner.Wait(10) | 28 action_runner.Wait(10) |
| 34 | 29 |
| 35 | 30 |
| 36 class Page2(WebrtcPage): | 31 class VideoCall(WebrtcPage): |
| 37 """Why: Sets up a local video-only WebRTC 720p call for 45 seconds.""" | 32 """Why: Sets up a local video-only WebRTC 720p call for 45 seconds.""" |
| 38 | 33 |
| 39 def __init__(self, page_set): | 34 def __init__(self, page_set, tags): |
| 40 super(Page2, self).__init__( | 35 super(VideoCall, self).__init__( |
| 41 url='file://webrtc_cases/constraints.html', | 36 url='file://webrtc_cases/constraints.html', |
| 42 name='720p_call_45s', | 37 name='720p_call_45s', |
| 43 page_set=page_set) | 38 page_set=page_set, tags=tags) |
| 44 | 39 |
| 45 def RunPageInteractions(self, action_runner): | 40 def RunPageInteractions(self, action_runner): |
| 46 with action_runner.CreateInteraction('Action_Create_PeerConnection', | 41 with action_runner.CreateInteraction('Action_Create_PeerConnection', |
| 47 repeatable=False): | 42 repeatable=False): |
| 48 action_runner.ExecuteJavaScript('minWidthInput.value = 1280') | 43 action_runner.ExecuteJavaScript('minWidthInput.value = 1280') |
| 49 action_runner.ExecuteJavaScript('maxWidthInput.value = 1280') | 44 action_runner.ExecuteJavaScript('maxWidthInput.value = 1280') |
| 50 action_runner.ExecuteJavaScript('minHeightInput.value = 720') | 45 action_runner.ExecuteJavaScript('minHeightInput.value = 720') |
| 51 action_runner.ExecuteJavaScript('maxHeightInput.value = 720') | 46 action_runner.ExecuteJavaScript('maxHeightInput.value = 720') |
| 52 action_runner.ClickElement('button[id="getMedia"]') | 47 action_runner.ClickElement('button[id="getMedia"]') |
| 53 action_runner.Wait(2) | 48 action_runner.Wait(2) |
| 54 action_runner.ClickElement('button[id="connect"]') | 49 action_runner.ClickElement('button[id="connect"]') |
| 55 action_runner.Wait(45) | 50 action_runner.Wait(45) |
| 56 | 51 |
| 57 | 52 |
| 58 class Page3(WebrtcPage): | 53 class DataChannel(WebrtcPage): |
| 59 """Why: Transfer as much data as possible through a data channel in 20s.""" | 54 """Why: Transfer as much data as possible through a data channel in 20s.""" |
| 60 | 55 |
| 61 def __init__(self, page_set): | 56 def __init__(self, page_set, tags): |
| 62 super(Page3, self).__init__( | 57 super(DataChannel, self).__init__( |
| 63 url='file://webrtc_cases/datatransfer.html', | 58 url='file://webrtc_cases/datatransfer.html', |
| 64 name='30s_datachannel_transfer', | 59 name='30s_datachannel_transfer', |
| 65 page_set=page_set) | 60 page_set=page_set, tags=tags) |
| 66 | 61 |
| 67 def RunPageInteractions(self, action_runner): | 62 def RunPageInteractions(self, action_runner): |
| 68 # It won't have time to finish the 512 MB, but we're only interested in | 63 # 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. | 64 # cpu + memory anyway rather than how much data we manage to transfer. |
| 70 action_runner.ExecuteJavaScript('megsToSend.value = 512;') | 65 action_runner.ExecuteJavaScript('megsToSend.value = 512;') |
| 71 action_runner.ClickElement('button[id="sendTheData"]') | 66 action_runner.ClickElement('button[id="sendTheData"]') |
| 72 action_runner.Wait(30) | 67 action_runner.Wait(30) |
| 73 | 68 |
| 74 | 69 |
| 75 class Page4(WebrtcPage): | 70 class AudioCall(WebrtcPage): |
| 76 """Why: Sets up a WebRTC audio call with Opus.""" | 71 """Why: Sets up a WebRTC audio call.""" |
| 77 | 72 |
| 78 def __init__(self, page_set): | 73 def __init__(self, page_set, codec, tags): |
| 79 super(Page4, self).__init__( | 74 super(AudioCall, self).__init__( |
| 80 url='file://webrtc_cases/audio.html?codec=OPUS', | 75 url='file://webrtc_cases/audio.html?codec=%s' % codec, |
| 81 name='audio_call_opus_10s', | 76 name='audio_call_%s_10s' % codec.lower(), |
| 82 page_set=page_set) | 77 page_set=page_set, tags=tags) |
| 78 self.codec = codec |
| 83 | 79 |
| 84 def RunPageInteractions(self, action_runner): | 80 def RunPageInteractions(self, action_runner): |
| 85 action_runner.ExecuteJavaScript('codecSelector.value="OPUS";') | 81 action_runner.ExecuteJavaScript('codecSelector.value="%s";' % self.codec) |
| 86 action_runner.ClickElement('button[id="callButton"]') | 82 action_runner.ClickElement('button[id="callButton"]') |
| 87 action_runner.Wait(10) | 83 action_runner.Wait(10) |
| 88 | 84 |
| 89 | 85 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.""" | 86 """Why: Sets up a canvas capture stream connection to a peer connection.""" |
| 137 | 87 |
| 138 def __init__(self, page_set): | 88 def __init__(self, page_set, tags): |
| 139 super(Page8, self).__init__( | 89 super(CanvasCapturePeerConnection, self).__init__( |
| 140 url='file://webrtc_cases/canvas-capture.html', | 90 url='file://webrtc_cases/canvas-capture.html', |
| 141 name='canvas_capture_peer_connection', | 91 name='canvas_capture_peer_connection', |
| 142 page_set=page_set) | 92 page_set=page_set, tags=tags) |
| 143 | 93 |
| 144 def RunPageInteractions(self, action_runner): | 94 def RunPageInteractions(self, action_runner): |
| 145 with action_runner.CreateInteraction('Action_Canvas_PeerConnection', | 95 with action_runner.CreateInteraction('Action_Canvas_PeerConnection', |
| 146 repeatable=False): | 96 repeatable=False): |
| 147 action_runner.ClickElement('button[id="startButton"]') | 97 action_runner.ClickElement('button[id="startButton"]') |
| 148 action_runner.Wait(10) | 98 action_runner.Wait(10) |
| 149 | 99 |
| 150 | 100 |
| 151 class Page9(WebrtcPage): | 101 class MultiplePeerConnections(WebrtcPage): |
| 152 """Why: Sets up several peerconnections in the same page.""" | 102 """Why: Sets up several peer connections in the same page.""" |
| 153 | 103 |
| 154 def __init__(self, page_set): | 104 def __init__(self, page_set, tags): |
| 155 super(Page9, self).__init__( | 105 super(MultiplePeerConnections, self).__init__( |
| 156 url='file://webrtc_cases/multiple-peerconnections.html', | 106 url='file://webrtc_cases/multiple-peerconnections.html', |
| 157 name='multiple_peerconnections', | 107 name='multiple_peerconnections', |
| 158 page_set=page_set) | 108 page_set=page_set, tags=tags) |
| 159 | 109 |
| 160 def RunPageInteractions(self, action_runner): | 110 def RunPageInteractions(self, action_runner): |
| 161 with action_runner.CreateInteraction('Action_Create_PeerConnection', | 111 with action_runner.CreateInteraction('Action_Create_PeerConnection', |
| 162 repeatable=False): | 112 repeatable=False): |
| 163 # Set the number of peer connections to create to 15. | 113 # Set the number of peer connections to create to 15. |
| 164 action_runner.ExecuteJavaScript( | 114 action_runner.ExecuteJavaScript( |
| 165 'document.getElementById("num-peerconnections").value=15') | 115 'document.getElementById("num-peerconnections").value=15') |
| 166 action_runner.ExecuteJavaScript( | 116 action_runner.ExecuteJavaScript( |
| 167 'document.getElementById("cpuoveruse-detection").checked=false') | 117 'document.getElementById("cpuoveruse-detection").checked=false') |
| 168 action_runner.ClickElement('button[id="start-test"]') | 118 action_runner.ClickElement('button[id="start-test"]') |
| 169 action_runner.Wait(45) | 119 action_runner.Wait(45) |
| 170 | 120 |
| 171 | 121 |
| 172 class WebrtcGetusermediaPageSet(story.StorySet): | 122 class WebrtcPageSet(story.StorySet): |
| 173 """WebRTC tests for local getUserMedia: video capture and playback.""" | |
| 174 | |
| 175 def __init__(self): | 123 def __init__(self): |
| 176 super(WebrtcGetusermediaPageSet, self).__init__( | 124 super(WebrtcPageSet, self).__init__( |
| 177 cloud_storage_bucket=story.PUBLIC_BUCKET) | 125 cloud_storage_bucket=story.PUBLIC_BUCKET) |
| 178 | 126 |
| 179 self.AddStory(Page1(self)) | 127 self.AddStory(GetUserMedia(self, tags=['getusermedia'])) |
| 180 | 128 self.AddStory(MultiplePeerConnections(self, tags=['stress'])) |
| 181 | 129 self.AddStory(VideoCall(self, tags=['peerconnection', 'smoothness'])) |
| 182 class WebrtcStresstestPageSet(story.StorySet): | 130 self.AddStory(DataChannel(self, tags=['datachannel'])) |
| 183 """WebRTC stress-testing with multiple peer connections.""" | 131 self.AddStory(CanvasCapturePeerConnection(self, tags=['smoothness'])) |
| 184 | 132 # TODO(qyearsley, mcasas): Add webrtc.audio when http://crbug.com/468732 |
| 185 def __init__(self): | 133 # is fixed, or revert https://codereview.chromium.org/1544573002/ when |
| 186 super(WebrtcStresstestPageSet, self).__init__( | 134 # http://crbug.com/568333 is fixed. |
| 187 cloud_storage_bucket=story.PUBLIC_BUCKET) | 135 # self.AddStory(AudioCall(self, 'OPUS')) |
| 188 | 136 # self.AddStory(AudioCall(self, 'G772')) |
| 189 self.AddStory(Page9(self)) | 137 # self.AddStory(AudioCall(self, 'PCMU')) |
| 190 | 138 # 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 |