-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4 workspace files for this directory, in HTML and JS formats.
- Loading branch information
1 parent
16c9da7
commit f1f4d89
Showing
4 changed files
with
1,048 additions
and
0 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
...s/Blockly/blockly-1.20181105.0/blockly-1.20181105.0/tests/workspace_svg/event_svg_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
Oops, something went wrong.