Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: yui/yui3
...
head fork: yui/yui3
  • 7 commits
  • 9 files changed
  • 0 commit comments
  • 3 contributors
View
2  .travis.yml
@@ -2,8 +2,6 @@ language: node_js
node_js:
- "0.8"
- "0.10"
-before_install:
- - npm -g install grunt-cli
script:
- grunt travis
git:
View
1  package.json
@@ -18,6 +18,7 @@
"yogi": "~0.1.0",
"parserlib": "~0.2.2",
"grunt": "~0.4.1",
+ "grunt-cli": "~0.1.7",
"grunt-yui-contrib": "~0.0.4",
"grunt-lib-contrib": "~0.5.3",
"grunt-contrib-compress": "~0.4.1"
View
95 src/graphics/tests/unit/assets/drawing-tests.js
@@ -0,0 +1,95 @@
+YUI.add('drawing-tests', function(Y) {
+
+var parentDiv = Y.DOM.create('<div id="testdiv" style="width: 400px; height: 400px;">'),
+ suite = new Y.Test.Suite("Graphics: Drawing"),
+ drawingTests = new Y.Test.Case({
+
+ setUp: function() {
+ this.graphic = new Y.Graphic({
+ render: parentDiv
+ });
+ this.path = this.graphic.addShape({
+ type: "path"
+ });
+ },
+
+ tearDown: function() {
+ this.graphic.destroy();
+ },
+
+ "test: moveTo()" : function() {
+ Y.Assert.areEqual(this.path, this.path.moveTo(10, 10), "The moveTo method should return a reference to the path.");
+ },
+
+ "test: relativeMoveTo()" : function() {
+ Y.Assert.areEqual(this.path, this.path.relativeMoveTo(10, 10), "The relativeMoveTo method should return a reference to the path.");
+ },
+
+ "test: lineTo()" : function() {
+ Y.Assert.areEqual(this.path, this.path.lineTo(10, 10), "The lineTo method should return a reference to the path.");
+ Y.Assert.areEqual(this.path, this.path.lineTo(10, 10, 20, 10, 20, 20, 10, 20, 10, 10), "The lineTo method should return a reference to the path.");
+ Y.Assert.areEqual(this.path, this.path.lineTo([10, 10], [20, 10], [20, 20], [10, 20], [10, 10]), "The lineTo method should return a reference to the path.");
+ },
+
+ "test: relativeLineTo()" : function() {
+ Y.Assert.areEqual(this.path, this.path.relativeLineTo(10, 10), "The relativeLineTo method should return a reference to the path.");
+ },
+
+ "test: curveTo()" : function() {
+ Y.Assert.areEqual(this.path, this.path.curveTo(83.5, 0, 100.5, 17, 100, 50), "The curveTo method should return a reference to the path.");
+ Y.Assert.areEqual(this.path, this.path.curveTo(83.5, 0, 100.5, 17, 100, 50), "The curveTo method should return a reference to the path.");
+ this.path._pathArray = [];
+ Y.Assert.areEqual(this.path, this.path.curveTo(83.5, 0, 100.5, 17, 100, 50), "The curveTo method should return a reference to the path.");
+ },
+
+ "test: relativeCurveTo()" : function() {
+ Y.Assert.areEqual(this.path, this.path.relativeCurveTo(83.5, 0, 100.5, 17, 100, 50), "The relativeCurveTo method should return a reference to the path.");
+ },
+
+ "test: quadraticCurveTo()" : function() {
+ Y.Assert.areEqual(this.path, this.path.quadraticCurveTo(10, 0, 10, 5), "The quadraticCurveTo method should return a reference to the path.");
+ Y.Assert.areEqual(this.path, this.path.quadraticCurveTo(10, 0, 10, 5), "The quadraticCurveTo method should return a reference to the path.");
+ this.path._pathArray = [];
+ Y.Assert.areEqual(this.path, this.path.quadraticCurveTo(10, 0, 10, 5), "The quadraticCurveTo method should return a reference to the path.");
+ },
+
+ "test: relativeQuadraticCurveTo()" : function() {
+ Y.Assert.areEqual(this.path, this.path.relativeQuadraticCurveTo(10, 0, 10, 5), "The relativeQuadraticCurveTo method should return a reference to the path.");
+ },
+
+ "test: drawRect()" : function() {
+ Y.Assert.areEqual(this.path, this.path.drawRect(0, 0, 20, 10), "The drawRect method should return a reference to the path.");
+ },
+
+ "test: drawRoundRect()" : function() {
+ Y.Assert.areEqual(this.path, this.path.drawRoundRect(0, 0, 200, 100, 4, 4), "The drawRoundRect method should return a reference to the path.");
+ },
+
+ "test: drawEllipse()" : function() {
+ Y.Assert.areEqual(this.path, this.path.drawEllipse(0, 0, 20, 10), "The drawEllipse method should return a reference to the path.");
+ },
+
+ "test: drawCircle()" : function() {
+ Y.Assert.areEqual(this.path, this.path.drawCircle(0, 0, 10), "The drawCircle method should return a reference to the path.");
+ },
+
+ "test: drawDiamond()" : function() {
+ Y.Assert.areEqual(this.path, this.path.drawDiamond(0, 0, 20, 10), "The drawDiamond method should return a reference to the path.");
+ },
+
+ "test: drawWedge()" : function() {
+ Y.Assert.areEqual(this.path, this.path.drawWedge(175, 175, -3, 87, 175), "The drawWedge method should return a reference to the path.");
+ this.path.moveTo(100, 85);
+ Y.Assert.areEqual(this.path, this.path.drawWedge(175, 175, -3, 87, 175), "The drawWedge method should return a reference to the path.");
+ //hit over 360 branch
+ Y.Assert.areEqual(this.path, this.path.drawWedge(175, 175, -3, 365, 175), "The drawWedge method should return a reference to the path.");
+ //hit 0 segs branch
+ Y.Assert.areEqual(this.path, this.path.drawWedge(175, 175, -3, 0, 175), "The drawWedge method should return a reference to the path.");
+ }
+ });
+
+ suite.add(drawingTests);
+ Y.Test.Runner.add( suite );
+
+
+}, '@VERSION@' ,{requires:['graphics', 'test']});
View
8 src/graphics/tests/unit/assets/shape-path-tests.js
@@ -428,10 +428,13 @@ setPathDataTest = function(name, attrs, pathData)
testDefault: function()
{
- var pathData = this.pathData,
- mypath = this.path,
+ var mypath = this.path,
pathAttr = mypath.get("path");
Y.Assert.areEqual(pathData, mypath.get("data"), "The path data should be " + pathData);
+ mypath.set("data", pathData2);
+ Y.Assert.areEqual(pathData2, mypath.get("data"), "The path data should be " + pathData2 + ".");
+ mypath.set("data", "");
+ Y.Assert.areEqual("", mypath.get("data"), "The path data should be an empty string.");
}
});
};
@@ -476,7 +479,6 @@ suite.add(drawWedgeTest("DrawWedgeTestStrokeAndFill", strokeAndFill));
suite.add(drawWedgeTest("DrawWedgeTestStrokeNoFill", strokeNoFill));
suite.add(drawWedgeTest("DrawWedgeTestFillNoStroke", fillNoStroke));
suite.add(setPathDataTest("TestPathDataAttr", {data: pathData}, pathData));
-suite.add(setPathDataTest("TestPathDataAttr", {data: pathData2}, pathData2));
Y.Test.Runner.add( suite );
View
121 src/graphics/tests/unit/assets/shape-tests.js
@@ -0,0 +1,121 @@
+YUI.add('shape-tests', function(Y) {
+
+var parentDiv = Y.DOM.create('<div id="testdiv" style="width: 400px; height: 400px;">'),
+ suite = new Y.Test.Suite("Graphics: Shape"),
+ shapeTests;
+ document.body.appendChild(parentDiv);
+
+ shapeTests = new Y.Test.Case({
+
+ setUp: function() {
+ this.graphic = new Y.Graphic({
+ render: parentDiv
+ });
+ this.shape = this.graphic.addShape({
+ type: "path",
+ });
+ },
+
+ tearDown: function() {
+ this.graphic.destroy();
+ },
+
+ "test: new Y.Shape()" : function() {
+ Y.Assert.isInstanceOf(Y.Shape, this.shape, "This should be an instance of Y.Shape.");
+ },
+
+ "test: initializer()" : function() {
+ function MockInitializerShape() {}
+ MockInitializerShape.prototype = {
+ _setGraphicCalled: false,
+ _parsePathDataCalled: false,
+ _updateHandlerCalled: false,
+ _setGraphic: function() {
+ this._setGraphicCalled = true;
+ },
+ _parsePathData: function() {
+ this._parsePathDataCalled = true;
+ },
+ _updateHandler: function() {
+ this._updateHandlerCalled = true;
+ },
+ get: function() {
+ return this._pathData;
+ },
+ createNode: function() {},
+ _initProps: function() {}
+ };
+ var mockShape = new MockInitializerShape(),
+ shape = this.shape;
+ shape.initializer.apply(mockShape, [{}]);
+ Y.Assert.isFalse(mockShape._setGraphicCalled, "The _setGraphic method should not be called when a graphic is not available.");
+ Y.Assert.isFalse(mockShape._parsePathDataCalled, "The _parsePathData method should not be called when a graphic is not available.");
+ Y.Assert.isTrue(mockShape._updateHandlerCalled, "the _updateHandler method should have been called.");
+ mockShape._pathData = "M5, 0l100, 215 c 150 60 150 60 300 0z";
+ shape.initializer.apply(mockShape, [{graphic: this.graphic}]);
+ Y.Assert.isTrue(mockShape._setGraphicCalled, "The _setGraphic method should have been called.");
+ Y.Assert.isTrue(mockShape._parsePathDataCalled, "The _parsePathData method should have been called.");
+ },
+
+ "test: on()" : function() {
+ var shape = this.shape,
+ handler = function() {
+ //do nothing
+ },
+ handle = this.shape.on("click", handler);
+ Y.Assert.isObject(handle, "The handle should have been set.");
+ Y.Assert.areEqual("click", handle.evt.type, "The event should be a click event.");
+ handle = shape.on("customEvent", handler);
+ Y.Assert.areEqual("customEvent", handle.evt.type, "The event should be a customEvent.");
+ },
+
+ "test: toFront()" : function() {
+ function MockToFrontShape() {}
+ MockToFrontShape.prototype = {
+ mockGraphic: null,
+ get: function() {
+ return this.mockGraphic;
+ }
+ }
+ var shape = this.shape,
+ mockShape = new MockToFrontShape(),
+ graphicToFrontCalled = false;
+ shape.toFront.apply(mockShape);
+ Y.Assert.isFalse(graphicToFrontCalled, "There is no graphic, so the toFront method could not be called.");
+ mockShape.mockGraphic = {
+ _toFront: function() {
+ graphicToFrontCalled = true;
+ }
+ };
+ shape.toFront.apply(mockShape);
+ Y.Assert.isTrue(graphicToFrontCalled, "The graphic's toFront method should have been called.");
+ },
+
+ "test: toBack()" : function() {
+ function MockToBackShape() {}
+ MockToBackShape.prototype = {
+ mockGraphic: null,
+ get: function() {
+ return this.mockGraphic;
+ }
+ }
+ var shape = this.shape,
+ mockShape = new MockToBackShape(),
+ graphicToBackCalled = false;
+ shape.toBack.apply(mockShape);
+ Y.Assert.isFalse(graphicToBackCalled, "There is no graphic, so the toBack method could not be called.");
+ mockShape.mockGraphic = {
+ _toBack: function() {
+ graphicToBackCalled = true;
+ }
+ };
+ shape.toBack.apply(mockShape);
+ Y.Assert.isTrue(graphicToBackCalled, "The graphic's toBack method should have been called.");
+ }
+ });
+
+ suite.add(shapeTests);
+ Y.Test.Runner.add( suite );
+
+
+}, '@VERSION@' ,{requires:['graphics', 'test']});
View
23 src/graphics/tests/unit/drawing.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+<head>
+ <title>Drawing Tests</title>
+</head>
+<body class="yui3-skin-sam">
+
+<div id="log"></div>
+<script src="../../../../build/yui/yui.js"></script>
+<script src="./assets/drawing-tests.js"></script>
+<script>
+YUI({
+ filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'raw',
+ coverage: ['graphics', 'graphics-canvas', 'graphics-canvas-default', 'graphics-svg', 'graphics-svg-default', 'graphics-vml', 'graphics-vml-default']
+}).use('test-console', 'drawing-tests', function (Y) {
+
+ (new Y.Test.Console()).render( "#log" );
+
+ Y.Test.Runner.run();
+});
+</script>
+</body>
+</html>
View
23 src/graphics/tests/unit/shape.html
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+<head>
+ <title>Shape Tests</title>
+</head>
+<body class="yui3-skin-sam">
+
+<div id="log"></div>
+<script src="../../../../build/yui/yui.js"></script>
+<script src="./assets/shape-tests.js"></script>
+<script>
+YUI({
+ filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'raw',
+ coverage: ['graphics', 'graphics-canvas', 'graphics-canvas-default', 'graphics-svg', 'graphics-svg-default', 'graphics-vml', 'graphics-vml-default']
+}).use('test-console', 'shape-tests', function (Y) {
+
+ (new Y.Test.Console()).render( "#log" );
+
+ Y.Test.Runner.run();
+});
+</script>
+</body>
+</html>
View
11 src/slider/tests/manual/basic.html
@@ -48,12 +48,19 @@
s.render('#slider');
s.on('railMouseDown', function (e) {
- console.log(e);
+ /*removing this because IE9 just stops here if you don't have the developer tools open,
+ * it makes you think mousedown on the rail is broken in a manual test,
+ * but it's just that it doesn't know what to do when there's
+ * a console command with no console. Y.log() doesn't have this problem.
+ */
+ //console.log(e);
+ Y.log(e + 'this is a Y.log');
});
s.rail.on(['mousedown', 'mouseup', 'click'], function (e) {
e.type;
- console.log(e);
+ //console.log(e); // using Y.log() instead for IE 9
+ Y.log(e + 'this is a Y.log');
});
report.set('innerHTML',s.get('value'));
View
39 src/slider/tests/unit/assets/slider-tests.js
@@ -518,7 +518,8 @@ suite.add( new Y.Test.Case({
width : '300px',
clickableRail: true
}),
- railRegion, where, fired;
+ railRegion, fake_event, fired,
+ noop = function() {};
slider.on('railMouseDown', function () {
fired = true;
@@ -527,18 +528,20 @@ suite.add( new Y.Test.Case({
slider.render('#testbed');
railRegion = slider.rail.get('region');
- where = {
+ fake_event = {
clientX: railRegion.left + Math.floor(railRegion.width / 2),
- clientY: railRegion.top + Math.floor(railRegion.height / 2)
+ clientY: railRegion.top + Math.floor(railRegion.height / 2),
+ pageX: railRegion.left + Math.floor(railRegion.width / 2),
+ pageY: railRegion.top + Math.floor(railRegion.height / 2),
+ halt: noop
};
+
slider.on('railMouseDown', function (e) {
fired = true;
});
- slider.rail.simulate('mousedown', where);
- slider.rail.simulate('mouseup', where);
- slider.rail.simulate('click', where);
+ slider._onRailMouseDown(fake_event);
Y.Assert.isTrue(fired, "railMouseDown didn't fire for clickableRail: true");
@@ -559,9 +562,7 @@ suite.add( new Y.Test.Case({
slider.render('#testbed');
- slider.rail.simulate('mousedown', where);
- slider.rail.simulate('mouseup', where);
- slider.rail.simulate('click', where);
+ slider._onRailMouseDown(fake_event);
Y.Assert.isFalse(fired, "railMouseDown fired for clickableRail: false");
@@ -688,7 +689,8 @@ suite.add( new Y.Test.Case({
max : 100,
value : 50
}),
- position, fired, railRegion, where;
+ position, fired, railRegion, fake_event,
+ noop = function() {};
function thumbPosition() {
return parseInt(slider.thumb.getStyle('left'), 10);
@@ -697,9 +699,12 @@ suite.add( new Y.Test.Case({
slider.render( "#testbed" );
railRegion = slider.rail.get('region');
- where = {
+ fake_event = {
clientX: railRegion.left + Math.floor(railRegion.width / 2),
- clientY: railRegion.top + Math.floor(railRegion.height / 2)
+ clientY: railRegion.top + Math.floor(railRegion.height / 2),
+ pageX: railRegion.left + Math.floor(railRegion.width / 2),
+ pageY: railRegion.top + Math.floor(railRegion.height / 2),
+ halt: noop
};
Y.Assert.areNotSame(0, thumbPosition());
@@ -708,16 +713,14 @@ suite.add( new Y.Test.Case({
Y.Assert.areSame(0, thumbPosition());
- slider.on('railMouseDown', function (e) {
+ slider.on('railMouseDown', function (fake_event) {
fired = true;
});
- slider.rail.simulate('mousedown', where);
- slider.rail.simulate('mouseup', where);
- slider.rail.simulate('click', where);
+ slider._onRailMouseDown(fake_event);
- Y.Assert.isTrue(fired);
- Y.Assert.isTrue( (thumbPosition() > 0) );
+ Y.Assert.isTrue(fired, "Failed to fire: railMouseDown");
+ Y.Assert.isTrue( (thumbPosition() > 0), "Failed to find thumPosition > 0" );
}
}));

No commit comments for this range

Something went wrong with that request. Please try again.