dimensionpickerrenderer_test.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2013 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.DimensionPickerRendererTest');
  15. goog.setTestOnly('goog.ui.DimensionPickerRendererTest');
  16. goog.require('goog.a11y.aria.LivePriority');
  17. goog.require('goog.array');
  18. goog.require('goog.testing.jsunit');
  19. goog.require('goog.testing.recordFunction');
  20. goog.require('goog.ui.DimensionPicker');
  21. goog.require('goog.ui.DimensionPickerRenderer');
  22. var renderer;
  23. var picker;
  24. function setUp() {
  25. renderer = new goog.ui.DimensionPickerRenderer();
  26. picker = new goog.ui.DimensionPicker(renderer);
  27. }
  28. function tearDown() {
  29. picker.dispose();
  30. }
  31. /**
  32. * Tests that the right aria label is added when the highlighted
  33. * size changes.
  34. */
  35. function testSetHighlightedSizeUpdatesLiveRegion() {
  36. picker.render();
  37. var sayFunction = goog.testing.recordFunction();
  38. renderer.announcer_.say = sayFunction;
  39. renderer.setHighlightedSize(picker, 3, 7);
  40. assertEquals(1, sayFunction.getCallCount());
  41. assertTrue(
  42. goog.array.equals(
  43. ['3 by 7', goog.a11y.aria.LivePriority.ASSERTIVE],
  44. sayFunction.getLastCall().getArguments()));
  45. }