| 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.PhotoTest'); |
| 16 |
goog.setTestOnly('goog.ui.media.PhotoTest'); |
| 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.MediaModel'); |
| 23 |
goog.require('goog.ui.media.Photo'); |
| 24 |
var control; |
| 25 |
var PHOTO_URL = goog.html.testing.newTrustedResourceUrlForTest( |
| 26 |
'http://foo/bar.jpg'); |
| 27 |
|
| 28 |
function setUp() { |
| 29 |
var photo = new goog.ui.media.MediaModel(PHOTO_URL, 'title', 'description'); |
| 30 |
photo.setPlayer(new goog.ui.media.MediaModel.Player(PHOTO_URL)); |
| 31 |
control = goog.ui.media.Photo.newControl(photo); |
| 32 |
} |
| 33 |
|
| 34 |
function tearDown() { |
| 35 |
control.dispose(); |
| 36 |
} |
| 37 |
|
| 38 |
function testBasicRendering() { |
| 39 |
control.render(); |
| 40 |
var el = goog.dom.getElementsByTagNameAndClass( |
| 41 |
goog.dom.TagName.DIV, goog.ui.media.Photo.CSS_CLASS); |
| 42 |
assertEquals(1, el.length); |
| 43 |
var img = goog.dom.getElementsByTagNameAndClass( |
| 44 |
goog.dom.TagName.IMG, goog.ui.media.Photo.CSS_CLASS + '-image'); |
| 45 |
assertEquals(1, img.length); |
| 46 |
var caption = goog.dom.getElementsByTagNameAndClass( |
| 47 |
goog.dom.TagName.DIV, goog.ui.media.Photo.CSS_CLASS + '-caption'); |
| 48 |
assertEquals(1, caption.length); |
| 49 |
var content = goog.dom.getElementsByTagNameAndClass( |
| 50 |
goog.dom.TagName.DIV, goog.ui.media.Photo.CSS_CLASS + '-description'); |
| 51 |
assertEquals(1, content.length); |
| 52 |
} |