mirror of
https://github.com/google/blockly.git
synced 2026-01-13 20:07:08 +01:00
Remove tests that have been converted into mocha (#3373)
* Remove tests that have been converted into mocha
This commit is contained in:
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Tests for gesture.
|
||||
* @author marisaleung@google.com (Marisa Leung)
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var e;
|
||||
var workspace;
|
||||
|
||||
|
||||
function gestureTest_setUp() {
|
||||
workspace = new Blockly.Workspace();
|
||||
e = {};
|
||||
}
|
||||
|
||||
function gestureTest_tearDown() {
|
||||
e = null;
|
||||
workspace.dispose();
|
||||
}
|
||||
|
||||
function test_gestureConstructor() {
|
||||
var gesture = new Blockly.Gesture(e, workspace);
|
||||
assertEquals(gesture.mostRecentEvent_, e);
|
||||
assertEquals(gesture.creatorWorkspace_, workspace);
|
||||
}
|
||||
|
||||
function test_gestureIsField_ClickInWorkspace() {
|
||||
gestureTest_setUp();
|
||||
var block = new Blockly.Block(workspace);
|
||||
var field = new Blockly.Field();
|
||||
field.setSourceBlock(block);
|
||||
field.showEditor_ = function() {};
|
||||
var gesture = new Blockly.Gesture(e, workspace);
|
||||
gesture.setStartField(field);
|
||||
|
||||
var isFieldClick = gesture.isFieldClick_();
|
||||
assertEquals(isFieldClick, true);
|
||||
gestureTest_tearDown();
|
||||
}
|
||||
|
||||
function gestureIsFieldClick_InFlyoutHelper(flyout, expectedResult){
|
||||
// Assign workspace flyout
|
||||
workspace.flyout_ = flyout;
|
||||
// Create a Field inside of a Block
|
||||
var block = new Blockly.Block(workspace);
|
||||
var field = new Blockly.Field();
|
||||
field.setSourceBlock(block);
|
||||
field.showEditor_ = function() {};
|
||||
// Create gesture from the flyout
|
||||
var gesture = new Blockly.Gesture(e, workspace.flyout_);
|
||||
// Populate gesture with click start information
|
||||
gesture.setStartField(field);
|
||||
gesture.setStartFlyout_(workspace.flyout_);
|
||||
|
||||
var isFieldClick = gesture.isFieldClick_();
|
||||
assertEquals(isFieldClick, expectedResult);
|
||||
}
|
||||
|
||||
function test_gestureIsFieldClick_AutoCloseFlyout() {
|
||||
gestureTest_setUp();
|
||||
var flyout = new Blockly.VerticalFlyout({});
|
||||
gestureIsFieldClick_InFlyoutHelper(flyout, false);
|
||||
gestureTest_tearDown();
|
||||
}
|
||||
|
||||
function test_gestureIsFieldClick_AlwaysOpenFlyout() {
|
||||
gestureTest_setUp();
|
||||
var flyout = new Blockly.VerticalFlyout({});
|
||||
flyout.autoClose = false;
|
||||
gestureIsFieldClick_InFlyoutHelper(flyout, true);
|
||||
gestureTest_tearDown();
|
||||
}
|
||||
@@ -21,11 +21,7 @@
|
||||
<script src="event_test.js"></script>
|
||||
<script src="extensions_test.js"></script>
|
||||
<script src="generator_test.js"></script>
|
||||
<script src="gesture_test.js"></script>
|
||||
<script src="json_test.js"></script>
|
||||
<script src="metrics_test.js"></script>
|
||||
<script src="names_test.js"></script>
|
||||
<script src="theme_test.js"></script>
|
||||
<script src="utils_test.js"></script>
|
||||
<script src="utils_dom_test.js"></script>
|
||||
<script src="utils_math_test.js"></script>
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
function assertDimensionsMatch(toCheck, left, top, width, height) {
|
||||
assertEquals('Top did not match.', top, toCheck.top);
|
||||
assertEquals('Left did not match.', left, toCheck.left);
|
||||
assertEquals('Width did not match.', width, toCheck.width);
|
||||
assertEquals('Height did not match.', height, toCheck.height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a mock workspace object with two properties: getBlocksBoundingBox and
|
||||
* scale.
|
||||
*/
|
||||
function makeMockWs(scale, x, y, width, height) {
|
||||
return {
|
||||
getBlocksBoundingBox: function() {
|
||||
return {
|
||||
top: y,
|
||||
bottom: y + height,
|
||||
left: x,
|
||||
right: x + width
|
||||
}
|
||||
},
|
||||
scale: scale
|
||||
};
|
||||
}
|
||||
|
||||
// Empty workspace.
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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() {
|
||||
var ws = makeMockWs(1, 0, 0, 100, 100)
|
||||
var defaultZoom = Blockly.WorkspaceSvg.getContentDimensionsExact_(ws);
|
||||
// Pixel and ws units are the same at default zoom.
|
||||
assertDimensionsMatch(defaultZoom, 0, 0, 100, 100);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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() {
|
||||
var ws = makeMockWs(1, 10, 10, 100, 100)
|
||||
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.
|
||||
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);
|
||||
}
|
||||
|
||||
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() {
|
||||
var ws = makeMockWs(1, -10, -10, 100, 100)
|
||||
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.
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
function test_safeName() {
|
||||
var varDB = new Blockly.Names('window,door');
|
||||
assertEquals('SafeName empty.', 'unnamed', varDB.safeName_(''));
|
||||
assertEquals('SafeName ok.', 'foobar', varDB.safeName_('foobar'));
|
||||
assertEquals('SafeName number start.', 'my_9lives',
|
||||
varDB.safeName_('9lives'));
|
||||
assertEquals('SafeName number end.', 'lives9', varDB.safeName_('lives9'));
|
||||
assertEquals('SafeName special chars.', '____', varDB.safeName_('!@#$'));
|
||||
assertEquals('SafeName reserved.', 'door', varDB.safeName_('door'));
|
||||
}
|
||||
|
||||
function test_getName() {
|
||||
var varDB = new Blockly.Names('window,door');
|
||||
assertEquals('Name add #1.', 'Foo_bar', varDB.getName('Foo.bar', 'var'));
|
||||
assertEquals('Name get #1.', 'Foo_bar', varDB.getName('Foo.bar', 'var'));
|
||||
assertEquals('Name add #2.', 'Foo_bar2', varDB.getName('Foo bar', 'var'));
|
||||
assertEquals('Name get #2.', 'Foo_bar2', varDB.getName('foo BAR', 'var'));
|
||||
assertEquals('Name add #3.', 'door2', varDB.getName('door', 'var'));
|
||||
assertEquals('Name add #4.', 'Foo_bar3', varDB.getName('Foo.bar', 'proc'));
|
||||
assertEquals('Name get #1b.', 'Foo_bar', varDB.getName('Foo.bar', 'var'));
|
||||
assertEquals('Name get #4.', 'Foo_bar3', varDB.getName('Foo.bar', 'proc'));
|
||||
}
|
||||
|
||||
function test_getDistinctName() {
|
||||
var varDB = new Blockly.Names('window,door');
|
||||
assertEquals('Name distinct #1.', 'Foo_bar',
|
||||
varDB.getDistinctName('Foo.bar', 'var'));
|
||||
assertEquals('Name distinct #2.', 'Foo_bar2',
|
||||
varDB.getDistinctName('Foo.bar', 'var'));
|
||||
assertEquals('Name distinct #3.', 'Foo_bar3',
|
||||
varDB.getDistinctName('Foo.bar', 'proc'));
|
||||
varDB.reset();
|
||||
assertEquals('Name distinct #4.', 'Foo_bar',
|
||||
varDB.getDistinctName('Foo.bar', 'var'));
|
||||
}
|
||||
|
||||
function test_nameEquals() {
|
||||
assertTrue('Name equals #1.', Blockly.Names.equals('Foo.bar', 'Foo.bar'));
|
||||
assertFalse('Name equals #2.', Blockly.Names.equals('Foo.bar', 'Foo_bar'));
|
||||
assertTrue('Name equals #3.', Blockly.Names.equals('Foo.bar', 'FOO.BAR'));
|
||||
}
|
||||
Reference in New Issue
Block a user