popupemojipicker_test.js 2.3 KB

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