Debian Codegraph @

closure-library/closure/goog/graphics/ext/path_test.js

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