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 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
5 from telemetry.page import page_set as page_set_module | 5 from telemetry.page import page_set as page_set_module |
6 | 6 |
7 | 7 |
8 TRACK_CREATED_PEER_CONNECTIONS = ''' | |
tonyg
2014/09/29 16:45:22
This looks significant enough to warrant pulling o
phoglund_chromium
2014/09/30 13:37:48
Done.
| |
9 function getReportsAsDicts(getStatsResult) { | |
10 var result = []; | |
11 getStatsResult.forEach(function(report) { | |
12 var values = {}; | |
13 report.names().forEach(function(name) { | |
14 values[name] = report.stat(name); | |
15 }); | |
16 result.push(values); | |
17 }); | |
18 return result; | |
19 } | |
20 | |
21 window.peerConnectionReports = []; | |
tonyg
2014/09/29 16:45:22
Looks like everything besides this should go into
phoglund_chromium
2014/09/30 13:37:48
Done.
| |
22 function gatherStatsFromOneConnection(peerConnection) { | |
23 var connectionId = window.peerConnectionReports.length; | |
24 window.peerConnectionReports.push([]); | |
25 var pollIntervalMs = 1000; | |
26 | |
27 setInterval(function() { | |
28 peerConnection.getStats(function(response) { | |
29 var reports = getReportsAsDicts(response.result()); | |
30 window.peerConnectionReports[connectionId].push(reports); | |
31 }); | |
32 }, pollIntervalMs); | |
33 } | |
34 | |
35 webkitRTCPeerConnection = (function() { | |
36 var originalConstructor = webkitRTCPeerConnection; | |
37 return function() { | |
38 // Bind the incoming arguments to the original constructor. | |
39 var args = [null].concat(Array.prototype.slice.call(arguments)); | |
40 var factoryFunction = originalConstructor.bind.apply( | |
41 originalConstructor, args); | |
42 | |
43 // Create the object and track it. | |
44 var peerConnection = new factoryFunction(); | |
45 gatherStatsFromOneConnection(peerConnection); | |
46 return peerConnection; | |
47 } | |
48 })(); | |
49 ''' | |
50 | |
51 | |
8 class WebrtcCasesPage(page_module.Page): | 52 class WebrtcCasesPage(page_module.Page): |
9 | 53 |
10 def __init__(self, url, page_set): | 54 def __init__(self, url, page_set): |
11 super(WebrtcCasesPage, self).__init__(url=url, page_set=page_set) | 55 super(WebrtcCasesPage, self).__init__(url=url, page_set=page_set) |
12 | 56 |
13 | |
14 class Page1(WebrtcCasesPage): | 57 class Page1(WebrtcCasesPage): |
15 | 58 |
16 """ Why: Simple test page only showing a local video stream """ | 59 """ Why: Simple test page only showing a local video stream """ |
17 | 60 |
18 def __init__(self, page_set): | 61 def __init__(self, page_set): |
19 super(Page1, self).__init__( | 62 super(Page1, self).__init__( |
20 url='file://webrtc/local-video.html', | 63 url='file://webrtc/local-video.html', |
21 page_set=page_set) | 64 page_set=page_set) |
22 | 65 |
23 def RunWebrtc(self, action_runner): | 66 def RunWebrtc(self, action_runner): |
24 action_runner.NavigateToPage(self) | 67 action_runner.NavigateToPage(self) |
25 action_runner.Wait(10) | 68 action_runner.Wait(10) |
26 action_runner.ExecuteJavaScript('checkForErrors();') | 69 action_runner.ExecuteJavaScript('checkForErrors();') |
27 | 70 |
28 | 71 |
29 class Page2(WebrtcCasesPage): | 72 class Page2(WebrtcCasesPage): |
30 | 73 |
31 """ Why: Loopback video call using the PeerConnection API. """ | 74 """ Why: Loopback video call using the PeerConnection API. """ |
32 | 75 |
33 def __init__(self, page_set): | 76 def __init__(self, page_set): |
34 super(Page2, self).__init__( | 77 super(Page2, self).__init__( |
35 url='file://third_party/webrtc/samples/js/demos/html/pc1.html', | 78 url='file://third_party/webrtc/samples/js/demos/html/pc1.html', |
36 page_set=page_set) | 79 page_set=page_set) |
80 self.script_to_evaluate_on_commit = TRACK_CREATED_PEER_CONNECTIONS | |
tonyg
2014/09/29 16:45:22
Why is this on page2 but not page1? If that's a mi
phoglund_chromium
2014/09/30 13:37:48
The first test page only does a getUserMedia and p
| |
37 | 81 |
38 def RunEndure(self, action_runner): | 82 def RunEndure(self, action_runner): |
tonyg
2014/09/29 16:45:22
Unrelated: Endure is gone. I think this can be rem
phoglund_chromium
2014/09/30 13:37:48
Done.
| |
39 action_runner.ClickElement('button[id="btn1"]') | 83 action_runner.ClickElement('button[id="btn1"]') |
40 action_runner.Wait(2) | 84 action_runner.Wait(2) |
41 action_runner.ClickElement('button[id="btn2"]') | 85 action_runner.ClickElement('button[id="btn2"]') |
42 action_runner.Wait(10) | 86 action_runner.Wait(10) |
43 action_runner.ClickElement('button[id="btn3"]') | 87 action_runner.ClickElement('button[id="btn3"]') |
44 | 88 |
45 def RunWebrtc(self, action_runner): | 89 def RunWebrtc(self, action_runner): |
46 action_runner.ClickElement('button[id="btn1"]') | 90 action_runner.ClickElement('button[id="btn1"]') |
47 action_runner.Wait(2) | 91 action_runner.Wait(2) |
48 action_runner.ClickElement('button[id="btn2"]') | 92 action_runner.ClickElement('button[id="btn2"]') |
49 action_runner.Wait(10) | 93 action_runner.Wait(10) |
50 action_runner.ClickElement('button[id="btn3"]') | 94 action_runner.ClickElement('button[id="btn3"]') |
51 | 95 |
52 | 96 |
53 class WebrtcCasesPageSet(page_set_module.PageSet): | 97 class WebrtcCasesPageSet(page_set_module.PageSet): |
54 | 98 |
55 """ WebRTC tests for Real-time audio and video communication. """ | 99 """ WebRTC tests for Real-time audio and video communication. """ |
56 | 100 |
57 def __init__(self): | 101 def __init__(self): |
58 super(WebrtcCasesPageSet, self).__init__( | 102 super(WebrtcCasesPageSet, self).__init__( |
59 serving_dirs=['third_party/webrtc/samples/js']) | 103 serving_dirs=['third_party/webrtc/samples/js']) |
60 | 104 |
61 self.AddPage(Page1(self)) | 105 self.AddPage(Page1(self)) |
62 self.AddPage(Page2(self)) | 106 self.AddPage(Page2(self)) |
OLD | NEW |