spriteinfo_test.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2008 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.emoji.SpriteInfoTest');
  15. goog.setTestOnly('goog.ui.emoji.SpriteInfoTest');
  16. goog.require('goog.testing.jsunit');
  17. goog.require('goog.ui.emoji.SpriteInfo');
  18. function testGetCssValues() {
  19. var si = new goog.ui.emoji.SpriteInfo(null, 'im/s.png', 10, 10, 0, 128);
  20. assertEquals('10px', si.getWidthCssValue());
  21. assertEquals('10px', si.getHeightCssValue());
  22. assertEquals('0', si.getXOffsetCssValue());
  23. assertEquals('-128px', si.getYOffsetCssValue());
  24. }
  25. function testIncompletelySpecifiedSpriteInfoFails() {
  26. assertThrows(
  27. 'CSS class can\'t be null if the rest of the metadata ' +
  28. 'isn\'t specified',
  29. function() { new goog.ui.emoji.SpriteInfo(null) });
  30. assertThrows(
  31. 'Can\'t create an incompletely specified sprite info',
  32. function() { new goog.ui.emoji.SpriteInfo(null, 's.png', 10); });
  33. assertThrows(
  34. 'Can\'t create an incompletely specified sprite info',
  35. function() { new goog.ui.emoji.SpriteInfo(null, 's.png', 10, 10); });
  36. assertThrows(
  37. 'Can\'t create an incompletely specified sprite info',
  38. function() { new goog.ui.emoji.SpriteInfo(null, 's.png', 10, 10, 0); });
  39. }