Debian Codegraph @

closure-library/closure/goog/ui/media/mp3_test.js

raw
1 // Copyright 2009 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 goog.provide('goog.ui.media.Mp3Test');
16 goog.setTestOnly('goog.ui.media.Mp3Test');
17
18 goog.require('goog.dom');
19 goog.require('goog.dom.TagName');
20 goog.require('goog.html.testing');
21 goog.require('goog.testing.jsunit');
22 goog.require('goog.ui.media.FlashObject');
23 goog.require('goog.ui.media.Media');
24 goog.require('goog.ui.media.MediaModel');
25 goog.require('goog.ui.media.Mp3');
26 var mp3;
27 var control;
28 var MP3_URL = 'http://www.shellworld.net/~davidsky/surf-oxy.mp3';
29 var parent = goog.dom.createElement(goog.dom.TagName.DIV);
30
31 function setUp() {
32 mp3 = goog.ui.media.Mp3.getInstance();
33 var flashUrl = goog.ui.media.Mp3.buildFlashUrl(MP3_URL);
34 var model = new goog.ui.media.MediaModel(MP3_URL, 'mp3 caption', '');
35 model.setPlayer(new goog.ui.media.MediaModel.Player(
36 goog.html.testing.newTrustedResourceUrlForTest(flashUrl)));
37 control = new goog.ui.media.Media(model, mp3);
38 control.setSelected(true);
39 }
40
41 function tearDown() {
42 control.dispose();
43 }
44
45 function testBasicRendering() {
46 control.render(parent);
47 var el = goog.dom.getElementsByTagNameAndClass(
48 goog.dom.TagName.DIV, goog.ui.media.Mp3.CSS_CLASS, parent);
49 assertEquals(1, el.length);
50 }
51
52 function testParsingUrl() {
53 assertTrue(goog.ui.media.Mp3.MATCHER.test(MP3_URL));
54 assertFalse(goog.ui.media.Mp3.MATCHER.test('http://invalidUrl/filename.doc'));
55 }
56
57 function testCreatingDomOnInitialState() {
58 control.render(parent);
59 var caption = goog.dom.getElementsByTagNameAndClass(
60 goog.dom.TagName.DIV, goog.ui.media.Mp3.CSS_CLASS + '-caption', parent);
61 assertEquals(1, caption.length);
62
63 var flash = goog.dom.getElementsByTagNameAndClass(
64 undefined, goog.ui.media.FlashObject.CSS_CLASS, parent);
65 assertEquals(1, flash.length);
66 }