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 | 4 |
5 var tabCapture = chrome.tabCapture; | 5 var tabCapture = chrome.tabCapture; |
6 | 6 |
7 chrome.test.runTests([ | 7 chrome.test.runTests([ |
8 function captureTabAndVerifyStateTransitions() { | 8 function captureTabAndVerifyStateTransitions() { |
9 // Tab capture events in the order they happen. | 9 // Tab capture events in the order they happen. |
10 var tabCaptureEvents = []; | 10 var tabCaptureEvents = []; |
(...skipping 11 matching lines...) Expand all Loading... | |
22 }; | 22 }; |
23 tabCapture.onStatusChanged.addListener(tabCaptureListener); | 23 tabCapture.onStatusChanged.addListener(tabCaptureListener); |
24 | 24 |
25 tabCapture.capture({audio: true, video: true}, function(stream) { | 25 tabCapture.capture({audio: true, video: true}, function(stream) { |
26 chrome.test.assertTrue(!!stream); | 26 chrome.test.assertTrue(!!stream); |
27 stream.stop(); | 27 stream.stop(); |
28 }); | 28 }); |
29 }, | 29 }, |
30 | 30 |
31 function getCapturedTabs() { | 31 function getCapturedTabs() { |
32 chrome.tabs.create({active:true}, function(secondTab) { | 32 chrome.tabs.create({active: true}, function(secondTab) { |
33 // chrome.tabCapture.capture() will only capture the active tab. | 33 // chrome.tabCapture.capture() will only capture the active tab. |
34 chrome.test.assertTrue(secondTab.active); | 34 chrome.test.assertTrue(secondTab.active); |
35 | 35 |
36 function checkInfoForSecondTabHasStatus(infos, status) { | 36 function checkInfoForSecondTabHasStatus(infos, status) { |
37 for (var i = 0; i < infos.length; ++i) { | 37 for (var i = 0; i < infos.length; ++i) { |
38 if (infos[i].tabId == secondTab) { | 38 if (infos[i].tabId == secondTab) { |
39 chrome.test.assertNe(null, status); | 39 chrome.test.assertNe(null, status); |
40 chrome.test.assertEq(status, infos[i].status); | 40 chrome.test.assertEq(status, infos[i].status); |
41 chrome.test.assertEq(false, infos[i].fullscreen); | 41 chrome.test.assertEq(false, infos[i].fullscreen); |
42 return; | 42 return; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 chrome.test.succeed(); | 90 chrome.test.succeed(); |
91 }; | 91 }; |
92 | 92 |
93 tabCapture.capture({audio: true, video: true}, function(stream) { | 93 tabCapture.capture({audio: true, video: true}, function(stream) { |
94 chrome.test.assertTrue(!!stream); | 94 chrome.test.assertTrue(!!stream); |
95 stream1 = stream; | 95 stream1 = stream; |
96 tabCapture.capture({audio: true, video: true}, tabMediaRequestCallback2); | 96 tabCapture.capture({audio: true, video: true}, tabMediaRequestCallback2); |
97 }); | 97 }); |
98 }, | 98 }, |
99 | 99 |
100 function tabIsUnmutedWhenTabCaptured() { | |
101 var stream1 = null; | |
102 | |
103 chrome.tabs.getCurrent(function(tab) { | |
104 chrome.test.listenForever(chrome.tabs.onUpdated, | |
not at google - send to devlin
2015/06/04 00:00:05
you should also stop listening to this,
var stopL
| |
105 function(tabId, changeInfo, updatedTab) { | |
106 var expectedMutedCause = "capture"; | |
107 var expectedMuted = false; | |
not at google - send to devlin
2015/06/04 00:00:05
I actually find these harder to read than just
if
| |
108 | |
109 if ((changeInfo["mutedCause"] == expectedMutedCause) && | |
110 (changeInfo["muted"] === expectedMuted)) { | |
111 chrome.test.assertEq(expectedMutedCause, updatedTab.mutedCause); | |
112 chrome.test.assertEq(expectedMuted, updatedTab.muted); | |
113 stream1.stop(); | |
114 chrome.test.succeed(); | |
115 } | |
116 }); | |
117 | |
118 chrome.tabs.update(tab.id, {muted: true}, function(newTab) { | |
119 setTimeout(function() { | |
120 tabCapture.capture({audio: true}, function(stream) { | |
121 stream1 = stream; | |
122 }); | |
123 }, 200); | |
124 }); | |
not at google - send to devlin
2015/06/04 00:00:05
Ok, I see your point. This is hard to fit into som
| |
125 }); | |
126 }, | |
127 | |
100 function onlyVideo() { | 128 function onlyVideo() { |
101 tabCapture.capture({video: true}, function(stream) { | 129 tabCapture.capture({video: true}, function(stream) { |
102 chrome.test.assertTrue(!!stream); | 130 chrome.test.assertTrue(!!stream); |
103 stream.stop(); | 131 stream.stop(); |
104 chrome.test.succeed(); | 132 chrome.test.succeed(); |
105 }); | 133 }); |
106 }, | 134 }, |
107 | 135 |
108 function onlyAudio() { | 136 function onlyAudio() { |
109 tabCapture.capture({audio: true}, function(stream) { | 137 tabCapture.capture({audio: true}, function(stream) { |
110 chrome.test.assertTrue(!!stream); | 138 chrome.test.assertTrue(!!stream); |
111 stream.stop(); | 139 stream.stop(); |
112 chrome.test.succeed(); | 140 chrome.test.succeed(); |
113 }); | 141 }); |
114 }, | 142 }, |
115 | 143 |
116 function noAudioOrVideoRequested() { | 144 function noAudioOrVideoRequested() { |
117 // If not specified, video is not requested. | 145 // If not specified, video is not requested. |
118 tabCapture.capture({audio: false}, function(stream) { | 146 tabCapture.capture({audio: false}, function(stream) { |
119 chrome.test.assertTrue(!stream); | 147 chrome.test.assertTrue(!stream); |
120 chrome.test.succeed(); | 148 chrome.test.succeed(); |
121 }); | 149 }); |
122 } | 150 } |
123 ]); | 151 ]); |
OLD | NEW |