Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / cast_streaming / bad_logging.js
blob632df0d1a9278d605633c464e74e22b800b6ec78
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 emptyLogWithLoggingDisabled() {
14     console.log("[TEST] emptyLogWithLoggingDisabled");
15     tabCapture.capture({audio: true, video: true},
16                        pass(function(stream) {
17       console.log("Got MediaStream.");
18       chrome.test.assertTrue(!!stream);
19       createSession(stream.getAudioTracks()[0],
20                     stream.getVideoTracks()[0],
21                     pass(function(stream, audioId, videoId, udpId) {
22         console.log("Starting.");
23         var stateMachine = new TestStateMachine(stream,
24                                                 audioId,
25                                                 videoId,
26                                                 udpId);
27         var audioParams = rtpStream.getSupportedParams(audioId)[0];
28         var videoParams = rtpStream.getSupportedParams(videoId)[0];
29         var expectEmptyLogs = function(rawEvents) {
30           chrome.test.assertEq(0, rawEvents.byteLength);
31         }
32         chrome.test.assertTrue(!!audioParams.payload.codecName);
33         chrome.test.assertTrue(!!videoParams.payload.codecName);
34         udpTransport.setDestination(udpId,
35                                     {address: "127.0.0.1", port: 2344});
36         rtpStream.onStarted.addListener(
37             stateMachine.onStarted.bind(stateMachine));
38         stateMachine.onAllStarted =
39             pass(function(audioId, videoId) {
40           console.log("Getting logs without enabling logging.");
41           rtpStream.getRawEvents(audioId, expectEmptyLogs);
42           rtpStream.getRawEvents(videoId, expectEmptyLogs);
43           console.log("Disabling logging that is already disabled.");
44           rtpStream.toggleLogging(audioId, false);
45           rtpStream.toggleLogging(videoId, false);
46           console.log("Stopping.");
47           rtpStream.stop(audioId);
48           rtpStream.stop(videoId);
49         }.bind(null, audioId, videoId));
50         rtpStream.onStopped.addListener(
51             stateMachine.onStopped.bind(stateMachine));
52         stateMachine.onAllStopped =
53             pass(function(stream, audioId, videoId, udpId) {
54           console.log("Destroying.");
55           rtpStream.destroy(audioId);
56           rtpStream.destroy(videoId);
57           udpTransport.destroy(udpId);
58           chrome.test.assertTrue(!!audioParams.payload.codecName);
59           chrome.test.assertTrue(!!videoParams.payload.codecName);
60           chrome.test.succeed();
61         }.bind(null, stream, audioId, videoId, udpId));
62         rtpStream.start(audioId, audioParams);
63         rtpStream.start(videoId, videoParams);
64       }.bind(null, stream)));
65     }));
66   },
67 ]);