roundedpanel_test.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. goog.provide('goog.ui.RoundedPanelTest');
  15. goog.setTestOnly('goog.ui.RoundedPanelTest');
  16. goog.require('goog.testing.jsunit');
  17. goog.require('goog.ui.CssRoundedPanel');
  18. goog.require('goog.ui.GraphicsRoundedPanel');
  19. goog.require('goog.ui.RoundedPanel');
  20. goog.require('goog.userAgent');
  21. /**
  22. * Tests goog.ui.RoundedPanel.create(), ensuring that the proper instance is
  23. * created based on user-agent
  24. */
  25. function testRoundedPanelCreate() {
  26. var rcp = goog.ui.RoundedPanel.create(
  27. 15, 5, '#cccccc', '#cccccc', goog.ui.RoundedPanel.Corner.ALL);
  28. if (goog.userAgent.GECKO && goog.userAgent.isVersionOrHigher('1.9a')) {
  29. assertTrue(
  30. 'For Firefox 3.0+ (uses Gecko 1.9+), an instance of ' +
  31. 'goog.ui.CssRoundedPanel should be returned.',
  32. rcp instanceof goog.ui.CssRoundedPanel);
  33. } else if (goog.userAgent.WEBKIT && goog.userAgent.isVersionOrHigher('500')) {
  34. assertTrue(
  35. 'For Safari 3.0+, an instance of goog.ui.CssRoundedPanel ' +
  36. 'should be returned.',
  37. rcp instanceof goog.ui.CssRoundedPanel);
  38. } else if (goog.userAgent.EDGE) {
  39. assertTrue(
  40. 'For MS Edge, an instance of goog.ui.CssRoundedPanel ' +
  41. 'should be returned.',
  42. rcp instanceof goog.ui.CssRoundedPanel);
  43. } else if (
  44. goog.userAgent.GECKO || goog.userAgent.IE || goog.userAgent.OPERA ||
  45. goog.userAgent.WEBKIT) {
  46. assertTrue(
  47. 'For Gecko 1.8- (ex. Firefox 2.0-, Camino 1.5-, etc.), ' +
  48. 'IE, Opera, and Safari 2.0-, an instance of ' +
  49. 'goog.ui.GraphicsRoundedPanel should be returned.',
  50. rcp instanceof goog.ui.GraphicsRoundedPanel);
  51. } else {
  52. assertNull('For non-supported user-agents, null is returned.', rcp);
  53. }
  54. }