mirror of
https://github.com/google/blockly.git
synced 2026-01-19 23:07:21 +01:00
* Ui events base (#4370) * Add constants for new ui event types * Add property to indicate an event as UI event * Click events (#4372) * Creating new ui base class. * Refactor theme event (#4391) * Add themeName property to theme event * Refactor marker move events. (#4389) * Refactor trashcan open event (#4392) * Refactor selected event (#4387) * Refactor toolbox item change event (#4394) * Refactor bubble open events (#4390) * Refactor block drag event (#4388) * Viewport events (#4395) * Fix event filtering for ui events (#4401) * Move events to new directory and rename Ui events base (#4400) * Move events to new directory and rename Ui events base * Add missing fromJson implementation for click event (#4410) * Adding serialization tests for events * Zoom controls event (#4407) * Refactor zoom event * Rename IS_UI_EVENT to isUiEvent
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
suite("Zoom Controls", function() {
|
|
setup(function() {
|
|
sharedTestSetup.call(this);
|
|
this.workspace = Blockly.inject('blocklyDiv',
|
|
{'zoom': {'controls': true}});
|
|
this.zoomControls = this.workspace.zoomControls_;
|
|
});
|
|
teardown(function() {
|
|
sharedTestTeardown.call(this);
|
|
});
|
|
|
|
suite("Events", function() {
|
|
function closeToMatcher(expectedValue, delta) {
|
|
return sinon.match(function(value) {
|
|
return Math.abs(value - expectedValue) <= delta;
|
|
});
|
|
}
|
|
test("Zoom in", function() {
|
|
simulateClick(this.zoomControls.zoomInGroup_);
|
|
|
|
assertEventFired(
|
|
this.eventsFireStub, Blockly.Events.Click,
|
|
{targetType: 'zoom_controls'}, this.workspace.id, null);
|
|
assertEventNotFired(
|
|
this.eventsFireStub, Blockly.Events.Click,
|
|
{targetType: 'workspace'});
|
|
chai.assert.closeTo(this.workspace.getScale(), 1.2, 0.05);
|
|
});
|
|
test("Zoom out", function() {
|
|
simulateClick(this.zoomControls.zoomOutGroup_);
|
|
|
|
assertEventFired(
|
|
this.eventsFireStub, Blockly.Events.Click,
|
|
{targetType: 'zoom_controls'}, this.workspace.id, null);
|
|
assertEventNotFired(
|
|
this.eventsFireStub, Blockly.Events.Click,
|
|
{targetType: 'workspace'});
|
|
chai.assert.closeTo(this.workspace.getScale(), 0.8, 0.05);
|
|
});
|
|
test("Reset zoom", function() {
|
|
simulateClick(this.zoomControls.zoomResetGroup_);
|
|
|
|
assertEventFired(
|
|
this.eventsFireStub, Blockly.Events.Click,
|
|
{targetType: 'zoom_controls'}, this.workspace.id, null);
|
|
assertEventNotFired(
|
|
this.eventsFireStub, Blockly.Events.Click,
|
|
{targetType: 'workspace'});
|
|
chai.assert.equal(this.workspace.getScale(), 1);
|
|
});
|
|
});
|
|
});
|