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.
6 from telemetry
.page
import page
as page_module
7 from telemetry
.page
import page_set
as page_set_module
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',
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/',
48 def RunPageInteractions(self
, action_runner
):
49 action_runner
.ClickElement('button[id="startButton"]')
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',
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',
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',
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',
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',
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',
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 WebrtcCasesPageSet(page_set_module
.PageSet
):
157 """ WebRTC tests for Real-time audio and video communication. """
160 super(WebrtcCasesPageSet
, self
).__init
__(
161 archive_data_file
='data/webrtc_cases.json',
162 bucket
=page_set_module
.PUBLIC_BUCKET
)
164 self
.AddUserStory(Page1(self
))
165 self
.AddUserStory(Page2(self
))
166 self
.AddUserStory(Page3(self
))
167 # Disable page 4-7 until we can implement http://crbug.com/468732. We can
168 # get data out from the tests, but it's not very useful yet.
169 self
.AddUserStory(Page8(self
))