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

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

Issue 11038021: Implement Chrome Extension TabCapture API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/extensions/api_test/tab_capture/experimental/manifest.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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.
4
5 var tabCapture = chrome.tabCapture;
6
7 chrome.test.runTests([
8
9 function captureInvalidTab() {
10 var tabMediaRequestCallback = function(stream) {
11 chrome.test.assertEq(undefined, stream);
12 chrome.test.assertLastError('Could not find the specified tab.');
13 chrome.test.succeed();
14 };
15
16 tabCapture.capture(-1, {audio: true, video: true},
17 tabMediaRequestCallback);
18 },
19
20 function captureTabAndVerifyStateTransitions() {
21 var tabId = -1;
22 // Tab capture events in the order they happen.
23 var tabCaptureEvents = [];
24
25 var tabMediaRequestCallback = function(stream) {
26 chrome.test.assertTrue(stream !== undefined);
27 stream.stop();
28 };
29
30 var tabCaptureListener = function(info) {
31 chrome.test.assertEq(tabId, info.tabId);
32 console.log(info.status);
33 if (info.status == 'stopped') {
34 chrome.test.assertEq('active', tabCaptureEvents.pop());
35 chrome.test.assertEq('pending', tabCaptureEvents.pop());
36 chrome.test.assertEq('requested', tabCaptureEvents.pop());
37 tabCapture.onStatusChanged.removeListener(tabCaptureListener);
38 chrome.test.succeed();
39 return;
40 }
41 tabCaptureEvents.push(info.status);
42 }
43
44 tabCapture.onStatusChanged.addListener(tabCaptureListener);
45
46 var gotTabId = function(tab) {
47 tabId = tab[0].id;
48 console.log('using tab: ' + tabId);
49 tabCapture.capture(tabId, {audio: true, video: true},
50 tabMediaRequestCallback);
51 };
52 chrome.tabs.query({active: true}, gotTabId);
53 },
54
55 function getCapturedTabs() {
56 var tabId = -1;
57 var activeStream = null;
58
59 var capturedTabsAfterClose = function(infos) {
60 chrome.test.assertEq(1, infos.length);
61 chrome.test.assertEq(tabId, infos[0].tabId);
62 chrome.test.assertEq('stopped', infos[0].status);
63 chrome.test.succeed();
64 }
65
66 var capturedTabsAfterOpen = function(infos) {
67 chrome.test.assertEq(1, infos.length);
68 chrome.test.assertEq(tabId, infos[0].tabId);
69 chrome.test.assertEq('active', infos[0].status);
70 activeStream.stop();
71 tabCapture.getCapturedTabs(capturedTabsAfterClose);
72 }
73
74 var tabMediaRequestCallback = function(stream) {
75 chrome.test.assertTrue(stream !== undefined);
76 activeStream = stream;
77 tabCapture.getCapturedTabs(capturedTabsAfterOpen);
78 };
79
80 var gotTabId = function(tab) {
81 tabId = tab[0].id;
82 console.log('using tab: ' + tabId);
83 tabCapture.capture(tabId, {audio: true, video: true},
84 tabMediaRequestCallback);
85 };
86 chrome.tabs.query({active: true}, gotTabId);
87 },
88
89 function captureSameTab() {
90 var tabId = -1;
91 var stream1 = null;
92
93 var tabMediaRequestCallback2 = function(stream) {
94 chrome.test.assertLastError(
95 'Cannot capture a tab with an active stream.');
96 chrome.test.assertTrue(stream === undefined);
97 stream1.stop();
98 chrome.test.succeed();
99 };
100
101 var tabMediaRequestCallback = function(stream) {
102 chrome.test.assertTrue(stream !== undefined);
103 stream1 = stream;
104 tabCapture.capture(tabId, {audio: true, video: true},
105 tabMediaRequestCallback2);
106 };
107
108 var gotTabId = function(tab) {
109 tabId = tab[0].id;
110 console.log('using tab: ' + tabId);
111 tabCapture.capture(tabId, {audio: true, video: true},
112 tabMediaRequestCallback);
113 };
114 chrome.tabs.query({active: true}, gotTabId);
115 },
116
117 ]);
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/tab_capture/experimental/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698