path_test.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2007 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.ext.PathTest');
  4. goog.setTestOnly('goog.graphics.ext.PathTest');
  5. goog.require('goog.graphics');
  6. goog.require('goog.graphics.ext.Path');
  7. goog.require('goog.testing.graphics');
  8. goog.require('goog.testing.jsunit');
  9. function testClone() {
  10. var path = new goog.graphics.ext.Path().moveTo(0, 0).lineTo(1, 1).
  11. curveTo(2, 2, 3, 3, 4, 4).arc(5, 5, 6, 6, 0, 90, false).close();
  12. assertTrue('Cloned path is a goog.graphics.ext.Path',
  13. path instanceof goog.graphics.ext.Path);
  14. }
  15. function testBoundingBox() {
  16. var path = new goog.graphics.ext.Path().moveTo(0, 0).lineTo(1, 1).
  17. curveTo(2, 2, 3, 3, 4, 4).close();
  18. assertTrue('Bounding box is correct', goog.math.Rect.equals(
  19. path.getBoundingBox(), new goog.math.Rect(0, 0, 4, 4)));
  20. }
  21. function testModifyBounds() {
  22. var path1 = new goog.graphics.ext.Path().moveTo(0, 0).lineTo(1, 1).
  23. curveTo(2, 2, 3, 3, 4, 4).close();
  24. goog.testing.graphics.assertPathEquals(
  25. ['M', -2, -2, 'L', 0, 0, 'C', 2, 2, 4, 4, 6, 6, 'X'],
  26. path1.modifyBounds(-1, -1, 2, 2));
  27. }