| 1 |
// Copyright 2007 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.PopupEmojiPickerTest'); |
| 16 |
goog.setTestOnly('goog.ui.emoji.PopupEmojiPickerTest'); |
| 17 |
|
| 18 |
goog.require('goog.dom'); |
| 19 |
goog.require('goog.testing.jsunit'); |
| 20 |
goog.require('goog.ui.emoji.PopupEmojiPicker'); |
| 21 |
var emojiGroup1 = [ |
| 22 |
'Emoji 1', |
| 23 |
[ |
| 24 |
['../../demos/emoji/200.gif', 'std.200'], |
| 25 |
['../../demos/emoji/201.gif', 'std.201'] |
| 26 |
] |
| 27 |
]; |
| 28 |
|
| 29 |
var emojiGroup2 = [ |
| 30 |
'Emoji 2', |
| 31 |
[ |
| 32 |
['../../demos/emoji/2D0.gif', 'std.2D0'], |
| 33 |
['../../demos/emoji/2D1.gif', 'std.2D1'] |
| 34 |
] |
| 35 |
]; |
| 36 |
|
| 37 |
var emojiGroup3 = [ |
| 38 |
'Emoji 3', |
| 39 |
[ |
| 40 |
['../../demos/emoji/2E4.gif', 'std.2E4'], |
| 41 |
['../../demos/emoji/2E5.gif', 'std.2E5'] |
| 42 |
] |
| 43 |
]; |
| 44 |
|
| 45 |
function testConstructAndRenderPopupEmojiPicker() { |
| 46 |
var picker = new goog.ui.emoji.PopupEmojiPicker('../../demos/emoji/none.gif'); |
| 47 |
picker.addEmojiGroup(emojiGroup1[0], emojiGroup1[1]); |
| 48 |
picker.addEmojiGroup(emojiGroup2[0], emojiGroup2[1]); |
| 49 |
picker.addEmojiGroup(emojiGroup3[0], emojiGroup3[1]); |
| 50 |
picker.render(); |
| 51 |
picker.attach(document.getElementById('button1')); |
| 52 |
picker.dispose(); |
| 53 |
} |
| 54 |
|
| 55 |
// Unittest to ensure that the popup gets created in createDom(). |
| 56 |
function testPopupCreation() { |
| 57 |
var picker = new goog.ui.emoji.PopupEmojiPicker(); |
| 58 |
picker.addEmojiGroup(emojiGroup1[0], emojiGroup1[1]); |
| 59 |
picker.createDom(); |
| 60 |
assertNotNull(picker.getPopup()); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
function testAutoHideIsSetProperly() { |
| 65 |
var picker = new goog.ui.emoji.PopupEmojiPicker(); |
| 66 |
picker.addEmojiGroup(emojiGroup1[0], emojiGroup1[1]); |
| 67 |
picker.createDom(); |
| 68 |
picker.setAutoHide(true); |
| 69 |
var containingDiv = goog.dom.getElement('containingDiv'); |
| 70 |
picker.setAutoHideRegion(containingDiv); |
| 71 |
assertTrue(picker.getAutoHide()); |
| 72 |
assertEquals(containingDiv, picker.getAutoHideRegion()); |
| 73 |
} |