Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / cast_streaming / null_stream.js
blob7974954ebd05e5259c3e25ab70d05ac7d5ea308c
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.
5 var rtpStream = chrome.cast.streaming.rtpStream;
6 var tabCapture = chrome.tabCapture;
7 var udpTransport = chrome.cast.streaming.udpTransport;
8 var createSession = chrome.cast.streaming.session.create;
9 var pass = chrome.test.callbackPass;
11 chrome.test.runTests([
12   function noVideo() {
13     console.log("[TEST] noVideo");
14     chrome.tabs.create({"url": "about:blank"}, pass(function(tab) {
15       tabCapture.capture({audio: true, video: false},
16                          pass(function(stream) {
17         chrome.test.assertTrue(!!stream);
18         createSession(stream.getAudioTracks()[0],
19                       null,
20                       pass(function(stream, audioId, videoId, udpId) {
21           chrome.test.assertTrue(audioId > 0);
22           chrome.test.assertTrue(videoId == null);
23           chrome.test.assertTrue(udpId > 0);
24           rtpStream.destroy(audioId);
25           udpTransport.destroy(udpId);
26         }.bind(null, stream)));
27       }));
28     }));
29   },
30   function noAudio() {
31     console.log("[TEST] noAudio");
32     chrome.tabs.create({"url": "about:blank"}, pass(function(tab) {
33       tabCapture.capture({audio: false, video: true},
34                          pass(function(stream) {
35         chrome.test.assertTrue(!!stream);
36         createSession(null,
37                       stream.getVideoTracks()[0],
38                       pass(function(stream, audioId, videoId, udpId) {
39           chrome.test.assertTrue(audioId == null);
40           chrome.test.assertTrue(videoId > 0);
41           chrome.test.assertTrue(udpId > 0);
42           rtpStream.destroy(videoId);
43           udpTransport.destroy(udpId);
44         }.bind(null, stream)));
45       }));
46     }));
47   },
48   function noStream() {
49     console.log("[TEST] noAudio");
50     chrome.tabs.create({"url": "about:blank"}, pass(function(tab) {
51       try {
52         createSession(null, null, function(a, b, c) {});
53         chrome.test.fail();
54       } catch (e) {
55         // Success.
56       }
57     }));
58   },
59 ]);