Break tests out into individual cases

This commit is contained in:
Rachel Fenichel
2018-04-11 13:35:54 -07:00
parent 9f07d04709
commit e11ec48ed3

View File

@@ -40,7 +40,7 @@ function makeMockWs(scale, x, y, width, height) {
y: y
}
},
scale: 1
scale: scale
};
}
@@ -49,17 +49,19 @@ var test_GetContentDimensionsExact_empty = function() {
var ws = makeMockWs(1, 0, 0, 0, 0)
var defaultZoom = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
assertDimensionsMatch(defaultZoom, 0, 0, 0, 0);
}
// zoom in.
ws.scale = 2;
var test_GetContentDimensionsExact_emptyZoomIn = function() {
var ws = makeMockWs(2, 0, 0, 0, 0)
var zoomIn = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
assertDimensionsMatch(zoomIn, 0, 0, 0, 0);
}
// zoom out.
ws.scale = .5;
var test_GetContentDimensionsExact_emptyZoomOut = function() {
var ws = makeMockWs(.5, 0, 0, 0, 0)
var zoomOut = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
assertDimensionsMatch(zoomOut, 0, 0, 0, 0);
};
}
// Non-empty workspace, with top-left corner at ws origin.
var test_GetContentDimensionsExact_nonEmptyAtOrigin = function() {
@@ -67,19 +69,21 @@ var test_GetContentDimensionsExact_nonEmptyAtOrigin = function() {
var defaultZoom = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
// Pixel and ws units are the same at default zoom.
assertDimensionsMatch(defaultZoom, 0, 0, 100, 100);
}
// zoom in.
ws.scale = 2;
var test_GetContentDimensionsExact_nonEmptyAtOriginZoomIn = function() {
var ws = makeMockWs(2, 0, 0, 100, 100)
var zoomIn = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
// 1 ws unit = 2 pixels at this zoom level.
assertDimensionsMatch(zoomIn, 0, 0, 200, 200);
}
// zoom out.
ws.scale = .5;
var test_GetContentDimensionsExact_nonEmptyAtOriginZoomOut = function() {
var ws = makeMockWs(.5, 0, 0, 100, 100)
var zoomOut = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
// 1 ws unit = 0.5 pixels at this zoom level.
assertDimensionsMatch(zoomOut, 0, 0, 50, 50);
};
}
// Non-empty workspace, with top-left corner in positive ws coordinates.
var test_GetContentDimensionsExact_nonEmptyPositiveOrigin = function() {
@@ -87,21 +91,22 @@ var test_GetContentDimensionsExact_nonEmptyPositiveOrigin = function() {
var defaultZoom = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
// Pixel and ws units are the same at default zoom.
assertDimensionsMatch(defaultZoom, 10, 10, 100, 100);
}
// Changing zoom will change both width/height and origin location in pixels.
// zoom in.
ws.scale = 2;
// Changing zoom will change both width/height and origin location in pixels.
var test_GetContentDimensionsExact_nonEmptyPositiveOriginZoomIn = function() {
var ws = makeMockWs(2, 10, 10, 100, 100)
var zoomIn = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
// 1 ws unit = 2 pixels at this zoom level.
assertDimensionsMatch(zoomIn, 20, 20, 200, 200);
}
// zoom out.
ws.scale = .5;
var test_GetContentDimensionsExact_nonEmptyPositiveOriginZoomOut = function() {
var ws = makeMockWs(.5, 10, 10, 100, 100)
var zoomOut = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
// 1 ws unit = 0.5 pixels at this zoom level.
assertDimensionsMatch(zoomOut, 5, 5, 50, 50);
};
}
// Non-empty workspace, with top-left corner in negative ws coordinates.
var test_GetContentDimensionsExact_nonEmptyNegativeOrigin = function() {
@@ -109,19 +114,19 @@ var test_GetContentDimensionsExact_nonEmptyNegativeOrigin = function() {
var defaultZoom = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
// Pixel and ws units are the same at default zoom.
assertDimensionsMatch(defaultZoom, -10, -10, 100, 100);
}
// Changing zoom will change both width/height and origin location in pixels.
// zoom in.
ws.scale = 2;
// Changing zoom will change both width/height and origin location in pixels.
var test_GetContentDimensionsExact_nonEmptyNegativeOriginZoomIn = function() {
var ws = makeMockWs(2, -10, -10, 100, 100)
var zoomIn = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
// 1 ws unit = 2 pixels at this zoom level.
assertDimensionsMatch(zoomIn, -20, -20, 200, 200);
}
// zoom out.
ws.scale = .5;
var test_GetContentDimensionsExact_nonEmptyNegativeOriginZoomOut = function() {
var ws = makeMockWs(.5, -10, -10, 100, 100)
var zoomOut = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
// 1 ws unit = 0.5 pixels at this zoom level.
assertDimensionsMatch(zoomOut, -5, -5, 50, 50);
};
}