OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 function TestStateMachine(stream, audioId, videoId, udpId) { | 5 function TestStateMachine(stream, audioId, videoId, udpId) { |
6 this.stream = stream; | 6 this.stream = stream; |
7 this.audioId = audioId; | 7 this.audioId = audioId; |
8 this.videoId = videoId; | 8 this.videoId = videoId; |
9 this.udpId = udpId; | 9 this.udpId = udpId; |
10 this.audioStarted = false; | 10 this.audioStarted = false; |
11 this.videoStarted = false; | 11 this.videoStarted = false; |
12 this.audioStopped = false; | 12 this.audioStopped = false; |
13 this.videoStopped = false; | 13 this.videoStopped = false; |
14 this.gotAudioRawEvents = false; | 14 this.gotAudioRawEvents = false; |
15 this.gotVideoRawEvents = false; | 15 this.gotVideoRawEvents = false; |
| 16 this.gotAudioStats = false; |
| 17 this.gotVideoStats = false; |
16 } | 18 } |
17 | 19 |
18 TestStateMachine.prototype.onStarted = function(id) { | 20 TestStateMachine.prototype.onStarted = function(id) { |
19 if (id == this.audioId) | 21 if (id == this.audioId) |
20 this.audioStarted = true; | 22 this.audioStarted = true; |
21 if (id == this.videoId) | 23 if (id == this.videoId) |
22 this.videoStarted = true; | 24 this.videoStarted = true; |
23 if (this.audioStarted && this.videoStarted) | 25 if (this.audioStarted && this.videoStarted) |
24 this.onAllStarted(); | 26 this.onAllStarted(); |
25 } | 27 } |
26 | 28 |
27 TestStateMachine.prototype.onStopped = function(id) { | 29 TestStateMachine.prototype.onStopped = function(id) { |
28 if (id == this.audioId) | 30 if (id == this.audioId) |
29 this.audioStopped = true; | 31 this.audioStopped = true; |
30 if (id == this.videoId) | 32 if (id == this.videoId) |
31 this.videoStopped = true; | 33 this.videoStopped = true; |
32 if (this.audioStopped && this.videoStopped) | 34 if (this.audioStopped && this.videoStopped) |
33 this.onAllStopped(); | 35 this.onAllStopped(); |
34 } | 36 } |
35 | 37 |
36 TestStateMachine.prototype.onGotRawEvents = function(id, rawEvents) { | 38 TestStateMachine.prototype.onGotLogs = function(id, isStats, data) { |
37 chrome.test.assertTrue(rawEvents.length > 0); | 39 chrome.test.assertTrue(data.length > 0); |
38 if (id == this.audioId) { | 40 if (id == this.audioId) { |
39 this.gotAudioRawEvents = true; | 41 if (isStats) |
| 42 this.gotAudioStats = true; |
| 43 else |
| 44 this.gotAudioRawEvents = true; |
40 } | 45 } |
41 if (id == this.videoId) { | 46 if (id == this.videoId) { |
42 this.gotVideoRawEvents = true; | 47 if (isStats) |
| 48 this.gotVideoStats = true; |
| 49 else |
| 50 this.gotVideoRawEvents = true; |
43 } | 51 } |
44 if (this.gotAudioRawEvents && this.gotVideoRawEvents) | 52 if (this.gotAudioRawEvents && this.gotVideoRawEvents && |
45 this.onGotAllRawEvents(); | 53 this.gotAudioStats && this.gotVideoStats) { |
| 54 this.onGotAllLogs(); |
| 55 } |
46 } | 56 } |
47 | 57 |
OLD | NEW |