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

Side by Side Diff: chrome/test/data/extensions/api_test/cast_streaming/bad_logging.js

Issue 170063006: Cast: Add JS API to get raw events logs from cast extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pass presubmit Created 6 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 rtpStream = chrome.cast.streaming.rtpStream; 5 var rtpStream = chrome.cast.streaming.rtpStream;
6 var tabCapture = chrome.tabCapture; 6 var tabCapture = chrome.tabCapture;
7 var udpTransport = chrome.cast.streaming.udpTransport; 7 var udpTransport = chrome.cast.streaming.udpTransport;
8 var createSession = chrome.cast.streaming.session.create; 8 var createSession = chrome.cast.streaming.session.create;
9 var pass = chrome.test.callbackPass; 9 var pass = chrome.test.callbackPass;
10 10
11 function TestStateMachine(stream, audioId, videoId, udpId) { 11 chrome.test.runTests([
12 this.stream = stream; 12 function emptyLogWithLoggingDisabled() {
13 this.audioId = audioId;
14 this.videoId = videoId;
15 this.udpId = udpId;
16 this.audioStarted = false;
17 this.videoStarted = false;
18 this.audioStopped = false;
19 this.videoStopped = false;
20 }
21 13
22 TestStateMachine.prototype.onStarted = function(id) { 14 console.log("[TEST] emptyLogWithLoggingDisabled");
23 if (id == this.audioId)
24 this.audioStarted = true;
25 if (id == this.videoId)
26 this.videoStarted = true;
27 if (this.audioStarted && this.videoStarted)
28 this.onAllStarted();
29 }
30
31 TestStateMachine.prototype.onStopped = function(id) {
32 if (id == this.audioId)
33 this.audioStopped = true;
34 if (id == this.videoId)
35 this.videoStopped = true;
36 if (this.audioStopped && this.videoStopped)
37 this.onAllStopped();
38 }
39
40 chrome.test.runTests([
41 function rtpStreamStart() {
42 console.log("[TEST] rtpStreamStart");
43 tabCapture.capture({audio: true, video: true}, 15 tabCapture.capture({audio: true, video: true},
44 pass(function(stream) { 16 pass(function(stream) {
45 console.log("Got MediaStream."); 17 console.log("Got MediaStream.");
46 chrome.test.assertTrue(!!stream); 18 chrome.test.assertTrue(!!stream);
47 createSession(stream.getAudioTracks()[0], 19 createSession(stream.getAudioTracks()[0],
48 stream.getVideoTracks()[0], 20 stream.getVideoTracks()[0],
49 pass(function(stream, audioId, videoId, udpId) { 21 pass(function(stream, audioId, videoId, udpId) {
50 console.log("Starting."); 22 console.log("Starting.");
51 var stateMachine = new TestStateMachine(stream, 23 var stateMachine = new TestStateMachine(stream,
52 audioId, 24 audioId,
53 videoId, 25 videoId,
54 udpId); 26 udpId);
55 var audioParams = rtpStream.getSupportedParams(audioId)[0]; 27 var audioParams = rtpStream.getSupportedParams(audioId)[0];
56 var videoParams = rtpStream.getSupportedParams(videoId)[0]; 28 var videoParams = rtpStream.getSupportedParams(videoId)[0];
29 var expectEmptyLogs = function(rawEvents) {
30 chrome.test.assertEq("", rawEvents);
31 }
57 chrome.test.assertEq(audioParams.payload.codecName, "OPUS"); 32 chrome.test.assertEq(audioParams.payload.codecName, "OPUS");
58 chrome.test.assertEq(videoParams.payload.codecName, "VP8"); 33 chrome.test.assertEq(videoParams.payload.codecName, "VP8");
59 udpTransport.setDestination(udpId, 34 udpTransport.setDestination(udpId,
60 {address: "127.0.0.1", port: 2344}); 35 {address: "127.0.0.1", port: 2344});
61 rtpStream.onStarted.addListener( 36 rtpStream.onStarted.addListener(
62 stateMachine.onStarted.bind(stateMachine)); 37 stateMachine.onStarted.bind(stateMachine));
63 stateMachine.onAllStarted = 38 stateMachine.onAllStarted =
64 pass(function(audioId, videoId) { 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);
65 console.log("Stopping."); 46 console.log("Stopping.");
66 rtpStream.stop(audioId); 47 rtpStream.stop(audioId);
67 rtpStream.stop(videoId); 48 rtpStream.stop(videoId);
68 }.bind(null, audioId, videoId)); 49 }.bind(null, audioId, videoId));
69 rtpStream.onStopped.addListener( 50 rtpStream.onStopped.addListener(
70 stateMachine.onStopped.bind(stateMachine)); 51 stateMachine.onStopped.bind(stateMachine));
71 stateMachine.onAllStopped = 52 stateMachine.onAllStopped =
72 pass(function(stream, audioId, videoId, udpId) { 53 pass(function(stream, audioId, videoId, udpId) {
73 console.log("Destroying."); 54 console.log("Destroying.");
74 rtpStream.destroy(audioId); 55 rtpStream.destroy(audioId);
75 rtpStream.destroy(videoId); 56 rtpStream.destroy(videoId);
76 udpTransport.destroy(udpId); 57 udpTransport.destroy(udpId);
77 chrome.test.assertEq(audioParams.payload.codecName, "OPUS"); 58 chrome.test.assertEq(audioParams.payload.codecName, "OPUS");
78 chrome.test.assertEq(videoParams.payload.codecName, "VP8"); 59 chrome.test.assertEq(videoParams.payload.codecName, "VP8");
79 chrome.test.succeed(); 60 chrome.test.succeed();
80 }.bind(null, stream, audioId, videoId, udpId)); 61 }.bind(null, stream, audioId, videoId, udpId));
81 rtpStream.start(audioId, audioParams); 62 rtpStream.start(audioId, audioParams);
82 rtpStream.start(videoId, videoParams); 63 rtpStream.start(videoId, videoParams);
83 }.bind(null, stream))); 64 }.bind(null, stream)));
84 })); 65 }));
85 }, 66 },
86 ]); 67 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698