photo_test.js 1.9 KB

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