mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
fix: improve collapse / uncollapse performance (#6860)
* feat: enable render queueing for collapse-related things * chore: delay bumping * chore: fixup tests
This commit is contained in:
@@ -1112,48 +1112,42 @@ suite('Blocks', function() {
|
||||
suite('Add Connections Programmatically', function() {
|
||||
test('Output', function() {
|
||||
const block = createRenderedBlock(this.workspace, 'empty_block');
|
||||
// this.workspace.newBlock('empty_block');
|
||||
// block.initSvg();
|
||||
// block.render();
|
||||
|
||||
block.setOutput(true);
|
||||
|
||||
this.clock.runAll();
|
||||
chai.assert.equal(this.getOutputs().length, 1);
|
||||
});
|
||||
test('Value', function() {
|
||||
const block = this.workspace.newBlock('empty_block');
|
||||
block.initSvg();
|
||||
block.render();
|
||||
const block = createRenderedBlock(this.workspace, 'empty_block');
|
||||
|
||||
block.appendValueInput('INPUT');
|
||||
|
||||
this.clock.runAll();
|
||||
chai.assert.equal(this.getInputs().length, 1);
|
||||
});
|
||||
test('Previous', function() {
|
||||
const block = this.workspace.newBlock('empty_block');
|
||||
block.initSvg();
|
||||
block.render();
|
||||
const block = createRenderedBlock(this.workspace, 'empty_block');
|
||||
|
||||
block.setPreviousStatement(true);
|
||||
|
||||
this.clock.runAll();
|
||||
chai.assert.equal(this.getPrevious().length, 1);
|
||||
});
|
||||
test('Next', function() {
|
||||
const block = this.workspace.newBlock('empty_block');
|
||||
block.initSvg();
|
||||
block.render();
|
||||
const block = createRenderedBlock(this.workspace, 'empty_block');
|
||||
|
||||
block.setNextStatement(true);
|
||||
|
||||
this.clock.runAll();
|
||||
chai.assert.equal(this.getNext().length, 1);
|
||||
});
|
||||
test('Statement', function() {
|
||||
const block = this.workspace.newBlock('empty_block');
|
||||
block.initSvg();
|
||||
block.render();
|
||||
const block = createRenderedBlock(this.workspace, 'empty_block');
|
||||
|
||||
block.appendStatementInput('STATEMENT');
|
||||
|
||||
this.clock.runAll();
|
||||
chai.assert.equal(this.getNext().length, 1);
|
||||
});
|
||||
});
|
||||
@@ -1719,8 +1713,10 @@ suite('Blocks', function() {
|
||||
test('Add Input', function() {
|
||||
const blockA = createRenderedBlock(this.workspace, 'empty_block');
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA);
|
||||
|
||||
blockA.appendDummyInput('NAME');
|
||||
|
||||
this.clock.runAll();
|
||||
assertCollapsed(blockA);
|
||||
chai.assert.isNotNull(blockA.getInput('NAME'));
|
||||
});
|
||||
@@ -1794,20 +1790,20 @@ suite('Blocks', function() {
|
||||
const blockA = createRenderedBlock(this.workspace, 'variable_block');
|
||||
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA, 'x');
|
||||
|
||||
const variable = this.workspace.getVariable('x', '');
|
||||
this.workspace.renameVariableById(variable.getId(), 'y');
|
||||
|
||||
this.clock.runAll();
|
||||
assertCollapsed(blockA, 'y');
|
||||
});
|
||||
test('Coalesce, Different Case', function() {
|
||||
const blockA = createRenderedBlock(this.workspace, 'variable_block');
|
||||
|
||||
blockA.setCollapsed(true);
|
||||
assertCollapsed(blockA, 'x');
|
||||
|
||||
const variable = this.workspace.createVariable('y');
|
||||
this.workspace.renameVariableById(variable.getId(), 'X');
|
||||
|
||||
this.clock.runAll();
|
||||
assertCollapsed(blockA, 'X');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -541,6 +541,7 @@ suite('Procedures', function() {
|
||||
Blockly.Events.setGroup(false);
|
||||
|
||||
this.workspace.undo();
|
||||
this.clock.runAll();
|
||||
|
||||
chai.assert.isTrue(
|
||||
defBlock.getFieldValue('PARAMS').includes('param1'),
|
||||
|
||||
@@ -152,7 +152,7 @@ suite('Checkbox Fields', function() {
|
||||
workspace: {
|
||||
keyboardAccessibilityMode: false,
|
||||
},
|
||||
render: function() {field.render_();},
|
||||
queueRender: function() {field.render_();},
|
||||
bumpNeighbours: function() {},
|
||||
};
|
||||
field.constants_ = {
|
||||
|
||||
@@ -23,7 +23,7 @@ suite('Inputs', function() {
|
||||
'<block type="empty_block"/>'
|
||||
), this.workspace);
|
||||
|
||||
this.renderStub = sinon.stub(this.block, 'render');
|
||||
this.renderStub = sinon.stub(this.block, 'queueRender');
|
||||
this.bumpNeighboursStub = sinon.stub(this.block, 'bumpNeighbours');
|
||||
|
||||
this.dummy = this.block.appendDummyInput('DUMMY');
|
||||
|
||||
Reference in New Issue
Block a user