Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / cast_streaming / common.js
blob76f41116131b2663706183e05d78b8665ca4f990
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 function TestStateMachine(stream, audioId, videoId, udpId) {
6   this.stream = stream;
7   this.audioId = audioId;
8   this.videoId = videoId;
9   this.udpId = udpId;
10   this.audioStarted = false;
11   this.videoStarted = false;
12   this.audioStopped = false;
13   this.videoStopped = false;
14   this.gotAudioLogs = false;
15   this.gotVideoLogs = false;
18 TestStateMachine.prototype.onStarted = function(id) {
19   if (id == this.audioId)
20     this.audioStarted = true;
21   if (id == this.videoId)
22     this.videoStarted = true;
23   if (this.audioStarted && this.videoStarted)
24     this.onAllStarted();
27 TestStateMachine.prototype.onStopped = function(id) {
28   if (id == this.audioId)
29     this.audioStopped = true;
30   if (id == this.videoId)
31     this.videoStopped = true;
32   if (this.audioStopped && this.videoStopped)
33     this.onAllStopped();
36 TestStateMachine.prototype.onGotLogs = function(id) {
37   if (id == this.audioId)
38     this.gotAudioLogs = true;
39   if (id == this.videoId)
40     this.gotVideoLogs = true;
41   if (this.gotAudioLogs && this.gotVideoLogs)
42     this.onGotAllLogs();
45 TestStateMachine.prototype.onGotRawEvents = function(id, data) {
46   chrome.test.assertTrue(data.byteLength > 0);
47   this.onGotLogs(id);
49 TestStateMachine.prototype.onGotStats = function(id, data) {
50   chrome.test.assertTrue(!!data);
51   this.onGotLogs(id);