solidfill_test.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2012 The Closure Library Authors. All Rights Reserved.
  2. // Use of this source code is governed by the Apache License, Version 2.0.
  3. goog.provide('goog.graphics.SolidFillTest');
  4. goog.setTestOnly('goog.graphics.SolidFillTest');
  5. goog.require('goog.graphics.SolidFill');
  6. goog.require('goog.testing.jsunit');
  7. function testGetColor() {
  8. var fill = new goog.graphics.SolidFill('#123');
  9. assertEquals('#123', fill.getColor());
  10. fill = new goog.graphics.SolidFill('#abcdef');
  11. assertEquals('#abcdef', fill.getColor());
  12. fill = new goog.graphics.SolidFill('#123', 0.5);
  13. assertEquals('#123', fill.getColor());
  14. fill = new goog.graphics.SolidFill('#abcdef', 0.5);
  15. assertEquals('#abcdef', fill.getColor());
  16. }
  17. function testGetOpacity() {
  18. // Default opacity
  19. var fill = new goog.graphics.SolidFill('#123');
  20. assertEquals(1, fill.getOpacity());
  21. // Opaque
  22. var fill = new goog.graphics.SolidFill('#123', 1);
  23. assertEquals(1, fill.getOpacity());
  24. // Semi-transparent
  25. fill = new goog.graphics.SolidFill('#123', 0.5);
  26. assertEquals(0.5, fill.getOpacity());
  27. // Fully transparent
  28. fill = new goog.graphics.SolidFill('#123', 0);
  29. assertEquals(0, fill.getOpacity());
  30. }