123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- goog.provide('goog.ui.CharPickerTest');
- goog.setTestOnly('goog.ui.CharPickerTest');
- goog.require('goog.a11y.aria');
- goog.require('goog.a11y.aria.State');
- goog.require('goog.dispose');
- goog.require('goog.dom');
- goog.require('goog.events.Event');
- goog.require('goog.events.EventType');
- goog.require('goog.i18n.CharPickerData');
- goog.require('goog.i18n.uChar.NameFetcher');
- goog.require('goog.testing.MockControl');
- goog.require('goog.testing.events');
- goog.require('goog.testing.jsunit');
- goog.require('goog.testing.mockmatchers');
- goog.require('goog.ui.CharPicker');
- goog.require('goog.ui.FlatButtonRenderer');
- var charPicker, charPickerData, charPickerElement;
- var mockControl, charNameFetcherMock;
- function setUp() {
- mockControl = new goog.testing.MockControl();
- charNameFetcherMock = mockControl.createLooseMock(
- goog.i18n.uChar.NameFetcher, true );
- charPickerData = new goog.i18n.CharPickerData();
- charPickerElement = goog.dom.getElement('charpicker');
- charPicker = new goog.ui.CharPicker(charPickerData, charNameFetcherMock);
- }
- function tearDown() {
- goog.dispose(charPicker);
- goog.dom.removeChildren(charPickerElement);
- mockControl.$tearDown();
- }
- function testAriaLabelIsUpdatedOnFocus() {
- var character = '←';
- var characterName = 'right arrow';
- charNameFetcherMock.getName(character, goog.testing.mockmatchers.isFunction)
- .$does(function(c, callback) { callback(characterName); });
- mockControl.$replayAll();
- charPicker.decorate(charPickerElement);
-
-
- var gridElement = goog.dom.getElementByClass(
- goog.getCssName('goog-char-picker-grid'), charPickerElement);
- var buttonElement = goog.dom.getElementsByClass(
- goog.ui.FlatButtonRenderer.CSS_CLASS, gridElement)[0];
- buttonElement.setAttribute('char', character);
-
- goog.testing.events.fireBrowserEvent(
- new goog.events.Event(goog.events.EventType.FOCUS, buttonElement));
- mockControl.$verifyAll();
- var ariaLabel =
- goog.a11y.aria.getState(buttonElement, goog.a11y.aria.State.LABEL);
- assertEquals(
- 'The aria label should be updated when the button' +
- 'gains focus.',
- characterName, ariaLabel);
- }
|