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