mirror of
https://github.com/google/blockly.git
synced 2026-01-11 10:57:07 +01:00
Add test for deleting a rendered block with a comment (#1984)
Disabled for now as it fails due to #1960.
This commit is contained in:
@@ -191,6 +191,7 @@ function test_blockDelete_constructor() {
|
||||
setUpMockMethod(mockControl_, Blockly.utils, 'genUid', null, ['1']);
|
||||
try {
|
||||
var block = createSimpleTestBlock(workspace);
|
||||
block.setCommentText('test comment');
|
||||
var event = new Blockly.Events.BlockDelete(block);
|
||||
checkDeleteEventValues(event, block, ['1'], 'delete');
|
||||
} finally {
|
||||
@@ -810,4 +811,4 @@ function test_events_filter_nomerge_move() {
|
||||
} finally {
|
||||
eventTest_tearDownWithMockBlocks();
|
||||
}
|
||||
}
|
||||
}
|
||||
90
tests/workspace_svg/event_svg_test.js
Normal file
90
tests/workspace_svg/event_svg_test.js
Normal file
@@ -0,0 +1,90 @@
|
||||
/**
|
||||
* @license
|
||||
* Blockly Tests
|
||||
*
|
||||
* Copyright 2018 Google Inc.
|
||||
* https://developers.google.com/blockly/
|
||||
*
|
||||
* 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';
|
||||
|
||||
goog.require('goog.testing');
|
||||
goog.require('goog.testing.MockControl');
|
||||
|
||||
function eventSvg_setUpMockBlocks() {
|
||||
// TODO: Replace with defineGetVarBlock();
|
||||
Blockly.defineBlocksWithJsonArray([{
|
||||
'type': 'field_variable_test_block',
|
||||
'message0': '%1',
|
||||
'args0': [
|
||||
{
|
||||
'type': 'field_variable',
|
||||
'name': 'VAR',
|
||||
'variable': 'item'
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
'type': 'simple_test_block',
|
||||
'message0': 'simple test block',
|
||||
'output': null
|
||||
},
|
||||
{
|
||||
'type': 'test_val_in',
|
||||
'message0': 'test in %1',
|
||||
'args0': [
|
||||
{
|
||||
'type': 'input_value',
|
||||
'name': 'NAME'
|
||||
}
|
||||
]
|
||||
}]);
|
||||
}
|
||||
|
||||
function eventSvg_tearDownMockBlocks() {
|
||||
delete Blockly.Blocks['field_variable_test_block'];
|
||||
delete Blockly.Blocks['simple_test_block'];
|
||||
delete Blockly.Blocks['test_val_in'];
|
||||
}
|
||||
|
||||
function eventSvg_createWorkspaceWithToolbox() {
|
||||
var toolbox = document.getElementById('toolbox-categories');
|
||||
return Blockly.inject('blocklyDiv', {toolbox: toolbox});
|
||||
}
|
||||
|
||||
function eventSvg_createNewBlock(workspace, type) {
|
||||
var block = workspace.newBlock(type);
|
||||
block.initSvg();
|
||||
return block;
|
||||
}
|
||||
|
||||
function test_blockDelete_svgDispose() {
|
||||
eventSvg_setUpMockBlocks();
|
||||
var workspace = eventSvg_createWorkspaceWithToolbox();
|
||||
Blockly.Events.fire = temporary_fireEvent;
|
||||
temporary_fireEvent.firedEvents_ = [];
|
||||
try {
|
||||
var block = eventSvg_createNewBlock(workspace);
|
||||
block.setCommentText('test comment');
|
||||
var event = new Blockly.Events.BlockDelete(block);
|
||||
workspace.clearUndo();
|
||||
block.dispose();
|
||||
var firedEvents = workspace.undoStack_;
|
||||
assertEquals('Delete event created by dispose matches constructed delete event',
|
||||
Blockly.Xml.domToText(event.oldXml), Blockly.Xml.domToText(firedEvents[0].oldXml));
|
||||
} finally {
|
||||
eventSvg_tearDownMockBlocks();
|
||||
workspace.dispose();
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,10 @@ h1 {
|
||||
<div id="blocklyDiv"></div>
|
||||
|
||||
<h1>Blockly Workspace testing</h1>
|
||||
<script src="../jsunit/test_utilities.js"></script>
|
||||
<script src="workspace_svg_test.js"></script>
|
||||
<!-- TODO (#1960): Uncomment once comment deletion is fixed. -->
|
||||
<!--<script src="event_svg_test.js"></script>-->
|
||||
|
||||
<xml id="toolbox-simple" style="display: none">
|
||||
<block type="controls_ifelse"></block>
|
||||
|
||||
Reference in New Issue
Block a user