[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / test / data / media / webui / integration_test.html
blob63aee2431a4cc3f99e32f88ce86d5aa81e80561a
1 <!--
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.
5 -->
6 <!DOCTYPE html>
7 <html>
8 <body>
9 <script>
10 window.chrome = {};
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;
30 var TEST_PLAYER = 4;
31 var TEST_NAME = TEST_RENDERER + ':' + TEST_PLAYER;
33 // Correctly use the information from a media event.
34 window.testOnMediaEvent = function() {
35 var event = {
36 ticksMillis: 132,
37 renderer: TEST_RENDERER,
38 player: TEST_PLAYER,
39 params: {
40 fps: 60,
41 other: 'hi'
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);
53 // Remove a player.
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() {
62 var event = {
63 component_id: 1,
64 component_type: 0,
65 owner_id: 3,
66 status: 'created'
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]) {
81 var component =
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);
96 </script>
97 </body>
98 </html>