2 Copyright 2013 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
12 window
.setUp = function() {
13 var doNothing = function() {};
14 var mockClientRenderer
= {
15 playerUpdated
: doNothing
,
16 playerRemoved
: doNothing
,
17 playerAdded
: doNothing
,
18 audioComponentAdded
: doNothing
,
19 audioComponentRemoved
: doNothing
22 var manager
= new Manager(mockClientRenderer
);
23 media
.initialize(manager
);
25 window
.manager
= manager
;
28 // The renderer and player ids are completely arbitrarily.
29 var TEST_RENDERER
= 12;
31 var TEST_NAME
= TEST_RENDERER
+ ':' + TEST_PLAYER
;
33 // Correctly use the information from a media event.
34 window
.testOnMediaEvent = function() {
37 renderer
: TEST_RENDERER
,
45 window
.media
.onMediaEvent(event
);
46 var info
= window
.manager
.players_
[TEST_NAME
];
48 assertEquals(event
.ticksMillis
, info
.firstTimestamp_
);
49 assertEquals(TEST_NAME
, info
.id
);
50 assertEquals(event
.params
.fps
, info
.properties
.fps
);
54 window
.testOnRenderTerminated = function() {
55 window
.testOnMediaEvent();
57 window
.media
.onRendererTerminated(TEST_RENDERER
);
58 assertEquals(undefined, window
.manager
.players_
[TEST_NAME
]);
61 window
.testAudioComponents = function() {
69 // Ensure no components are currently present.
70 assertEquals(0, window
.manager
.audioComponents_
.length
);
72 // Test adding an audio component.
73 window
.media
.updateAudioComponent(event
);
74 assertEquals(1, window
.manager
.audioComponents_
.length
);
76 // The key format is an implementation detail we don't care about, so
77 // just ensure there's only one key and then use it directly.
78 assertEquals(1, Object
.keys(
79 window
.manager
.audioComponents_
[event
.component_type
]).length
);
80 for (key
in window
.manager
.audioComponents_
[event
.component_type
]) {
82 window
.manager
.audioComponents_
[event
.component_type
][key
];
83 assertEquals(event
.component_id
, component
['component_id']);
84 assertEquals(event
.component_type
, component
['component_type']);
85 assertEquals(event
.owner_id
, component
['owner_id']);
86 assertEquals(event
.status
, component
['status']);
89 // Test removing an audio component.
90 event
.status
= 'closed';
91 window
.media
.updateAudioComponent(event
);
92 assertEquals(1, window
.manager
.audioComponents_
.length
);
93 assertEquals(0, Object
.keys(
94 window
.manager
.audioComponents_
[event
.component_type
]).length
);