Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/test/data/extensions/api_test/tab_capture/api_tests.js

Issue 987583004: Add audible, muted to Tab, c.t.query, c.t.update, and c.t.onUpdated where relevant (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@patch1
Patch Set: tests; also mutedCause is a part of the tab object and capture mutedCause changed to just 'capture' Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
8 function captureTabAndVerifyStateTransitions() { 9 function captureTabAndVerifyStateTransitions() {
9 // Tab capture events in the order they happen. 10 // Tab capture events in the order they happen.
10 var tabCaptureEvents = []; 11 var tabCaptureEvents = [];
11 12
12 var tabCaptureListener = function(info) { 13 var tabCaptureListener = function(info) {
13 console.log(info.status); 14 console.log(info.status);
14 if (info.status == 'stopped') { 15 if (info.status == 'stopped') {
15 chrome.test.assertEq('active', tabCaptureEvents.pop()); 16 chrome.test.assertEq('active', tabCaptureEvents.pop());
16 chrome.test.assertEq('pending', tabCaptureEvents.pop()); 17 chrome.test.assertEq('pending', tabCaptureEvents.pop());
17 tabCapture.onStatusChanged.removeListener(tabCaptureListener); 18 tabCapture.onStatusChanged.removeListener(tabCaptureListener);
18 chrome.test.succeed(); 19 chrome.test.succeed();
19 return; 20 return;
20 } 21 }
21 tabCaptureEvents.push(info.status); 22 tabCaptureEvents.push(info.status);
22 }; 23 };
23 tabCapture.onStatusChanged.addListener(tabCaptureListener); 24 tabCapture.onStatusChanged.addListener(tabCaptureListener);
24 25
25 tabCapture.capture({audio: true, video: true}, function(stream) { 26 tabCapture.capture({audio: true, video: true}, function(stream) {
26 chrome.test.assertTrue(!!stream); 27 chrome.test.assertTrue(!!stream);
27 stream.stop(); 28 stream.stop();
28 }); 29 });
29 }, 30 },
30 31
31 function getCapturedTabs() { 32 function getCapturedTabs() {
32 chrome.tabs.create({active:true}, function(secondTab) { 33 chrome.tabs.create({active: true}, function(secondTab) {
33 // chrome.tabCapture.capture() will only capture the active tab. 34 // chrome.tabCapture.capture() will only capture the active tab.
34 chrome.test.assertTrue(secondTab.active); 35 chrome.test.assertTrue(secondTab.active);
35 36
36 function checkInfoForSecondTabHasStatus(infos, status) { 37 function checkInfoForSecondTabHasStatus(infos, status) {
37 for (var i = 0; i < infos.length; ++i) { 38 for (var i = 0; i < infos.length; ++i) {
38 if (infos[i].tabId == secondTab) { 39 if (infos[i].tabId == secondTab) {
39 chrome.test.assertNe(null, status); 40 chrome.test.assertNe(null, status);
40 chrome.test.assertEq(status, infos[i].status); 41 chrome.test.assertEq(status, infos[i].status);
41 chrome.test.assertEq(false, infos[i].fullscreen); 42 chrome.test.assertEq(false, infos[i].fullscreen);
42 return; 43 return;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 chrome.test.succeed(); 91 chrome.test.succeed();
91 }; 92 };
92 93
93 tabCapture.capture({audio: true, video: true}, function(stream) { 94 tabCapture.capture({audio: true, video: true}, function(stream) {
94 chrome.test.assertTrue(!!stream); 95 chrome.test.assertTrue(!!stream);
95 stream1 = stream; 96 stream1 = stream;
96 tabCapture.capture({audio: true, video: true}, tabMediaRequestCallback2); 97 tabCapture.capture({audio: true, video: true}, tabMediaRequestCallback2);
97 }); 98 });
98 }, 99 },
99 100
101 function tabisUnmutedWhenTabCaptured() {
miu 2015/05/26 21:28:46 nit: Capitalize the 'i' in 'is'.
Jared Sohn 2015/05/27 14:52:02 done
102 var stream1 = null;
103
104 chrome.tabs.getCurrent(function(tab) {
105 chrome.test.listenForever(chrome.tabs.onUpdated,
106 function(tabId, changeInfo, updatedTab) {
107 var expectedMutedCause = "capture";
108 var expectedMuted = false;
109
110 if ((typeof changeInfo.mutedCause !== "undefined") &&
not at google - send to devlin 2015/05/26 23:09:46 can also use changeInfo.hasOwnProperty('mutedCause
Jared Sohn 2015/05/27 14:52:02 done
111 (changeInfo["mutedCause"] === expectedMutedCause) &&
miu 2015/05/26 21:28:46 nit: This line and the next should be two more spa
Jared Sohn 2015/05/27 14:52:02 done
112 (changeInfo["muted"] == expectedMuted))
not at google - send to devlin 2015/05/26 23:09:46 Also to the above: not much point using === when c
Jared Sohn 2015/05/27 14:52:02 done
113 {
114 chrome.test.assertEq(expectedMutedCause, updatedTab.mutedCause);
115 chrome.test.assertEq(expectedMuted, updatedTab.muted);
116 stream1.stop();
117 chrome.test.succeed();
118 }
119 });
120
121 chrome.tabs.update(tab.id, {muted: true}, function(newTab) {
122 setTimeout(function() {
123 tabCapture.capture({audio: true}, function(stream) {
124 stream1 = stream;
125 });
126 }, 200);
not at google - send to devlin 2015/05/26 23:09:46 Ideally you wouldn't need any timeout and the call
Jared Sohn 2015/05/27 14:52:02 Right; the test fails without the timeout. In prio
not at google - send to devlin 2015/05/28 23:04:42 Mm this is problematic then. Timeout is just going
miu 2015/05/28 23:36:59 Explanation: The content API events propagate thro
not at google - send to devlin 2015/06/01 20:33:56 Ok, thanks for the explanation. Would my suggestio
Jared Sohn 2015/06/02 08:54:38 miu: Are you saying that there is a delay before t
not at google - send to devlin 2015/06/02 18:26:43 Ok: should we just forget about this portion of th
127 });
128 });
129 },
130
100 function onlyVideo() { 131 function onlyVideo() {
101 tabCapture.capture({video: true}, function(stream) { 132 tabCapture.capture({video: true}, function(stream) {
102 chrome.test.assertTrue(!!stream); 133 chrome.test.assertTrue(!!stream);
103 stream.stop(); 134 stream.stop();
104 chrome.test.succeed(); 135 chrome.test.succeed();
105 }); 136 });
106 }, 137 },
107 138
108 function onlyAudio() { 139 function onlyAudio() {
109 tabCapture.capture({audio: true}, function(stream) { 140 tabCapture.capture({audio: true}, function(stream) {
110 chrome.test.assertTrue(!!stream); 141 chrome.test.assertTrue(!!stream);
111 stream.stop(); 142 stream.stop();
112 chrome.test.succeed(); 143 chrome.test.succeed();
113 }); 144 });
114 }, 145 },
115 146
116 function noAudioOrVideoRequested() { 147 function noAudioOrVideoRequested() {
117 // If not specified, video is not requested. 148 // If not specified, video is not requested.
118 tabCapture.capture({audio: false}, function(stream) { 149 tabCapture.capture({audio: false}, function(stream) {
119 chrome.test.assertTrue(!stream); 150 chrome.test.assertTrue(!stream);
120 chrome.test.succeed(); 151 chrome.test.succeed();
121 }); 152 });
122 } 153 }
123 ]); 154 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698