mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-03 17:14:27 -04:00
Fix the monitor threads test. It was written before monitors could be loaded so was hand editing the monitorBlocks before loading the default project. The code I added to dispose was then clearing that out.
This commit is contained in:
parent
d6acd97ec7
commit
694af40964
2 changed files with 2 additions and 36 deletions
test
BIN
test/fixtures/timer-monitor.sb3
vendored
Normal file
BIN
test/fixtures/timer-monitor.sb3
vendored
Normal file
Binary file not shown.
|
@ -6,7 +6,7 @@ const VirtualMachine = require('../../src/index');
|
||||||
const Thread = require('../../src/engine/thread');
|
const Thread = require('../../src/engine/thread');
|
||||||
const Runtime = require('../../src/engine/runtime');
|
const Runtime = require('../../src/engine/runtime');
|
||||||
|
|
||||||
const projectUri = path.resolve(__dirname, '../fixtures/default.sb2');
|
const projectUri = path.resolve(__dirname, '../fixtures/timer-monitor.sb3');
|
||||||
const project = readFileToBuffer(projectUri);
|
const project = readFileToBuffer(projectUri);
|
||||||
|
|
||||||
const checkMonitorThreadPresent = (t, threads) => {
|
const checkMonitorThreadPresent = (t, threads) => {
|
||||||
|
@ -14,15 +14,12 @@ const checkMonitorThreadPresent = (t, threads) => {
|
||||||
const monitorThread = threads[0];
|
const monitorThread = threads[0];
|
||||||
t.equal(monitorThread.stackClick, false);
|
t.equal(monitorThread.stackClick, false);
|
||||||
t.equal(monitorThread.updateMonitor, true);
|
t.equal(monitorThread.updateMonitor, true);
|
||||||
t.equal(monitorThread.topBlock.toString(), 'sensing_timer');
|
t.equal(monitorThread.topBlock.toString(), 'timer');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a monitor and then checks if it gets run every frame.
|
* Creates a monitor and then checks if it gets run every frame.
|
||||||
*/
|
*/
|
||||||
/* TODO: when loadProject loads monitors, we can create a project with a monitor and will
|
|
||||||
* not have to do the create monitor step manually.
|
|
||||||
*/
|
|
||||||
test('monitor thread runs every frame', t => {
|
test('monitor thread runs every frame', t => {
|
||||||
const vm = new VirtualMachine();
|
const vm = new VirtualMachine();
|
||||||
vm.attachStorage(makeTestStorage());
|
vm.attachStorage(makeTestStorage());
|
||||||
|
@ -31,22 +28,6 @@ test('monitor thread runs every frame', t => {
|
||||||
t.doesNotThrow(() => {
|
t.doesNotThrow(() => {
|
||||||
// Note: don't run vm.start(), we handle calling _step() manually in this test
|
// Note: don't run vm.start(), we handle calling _step() manually in this test
|
||||||
vm.runtime.currentStepTime = Runtime.THREAD_STEP_INTERVAL;
|
vm.runtime.currentStepTime = Runtime.THREAD_STEP_INTERVAL;
|
||||||
|
|
||||||
// Manually populate the monitor block and set its isMonitored to true.
|
|
||||||
vm.runtime.monitorBlocks.createBlock({
|
|
||||||
id: 'sensing_timer',
|
|
||||||
opcode: 'sensing_timer',
|
|
||||||
inputs: {},
|
|
||||||
fields: {},
|
|
||||||
next: null,
|
|
||||||
topLevel: true,
|
|
||||||
parent: null,
|
|
||||||
shadow: false,
|
|
||||||
isMonitored: true,
|
|
||||||
x: '0',
|
|
||||||
y: '0'
|
|
||||||
});
|
|
||||||
|
|
||||||
vm.clear();
|
vm.clear();
|
||||||
vm.setCompatibilityMode(false);
|
vm.setCompatibilityMode(false);
|
||||||
vm.setTurboMode(false);
|
vm.setTurboMode(false);
|
||||||
|
@ -86,21 +67,6 @@ test('monitor thread not added twice', t => {
|
||||||
// Note: don't run vm.start(), we handle calling _step() manually in this test
|
// Note: don't run vm.start(), we handle calling _step() manually in this test
|
||||||
vm.runtime.currentStepTime = 0;
|
vm.runtime.currentStepTime = 0;
|
||||||
|
|
||||||
// Manually populate the monitor block and set its isMonitored to true.
|
|
||||||
vm.runtime.monitorBlocks.createBlock({
|
|
||||||
id: 'sensing_timer',
|
|
||||||
opcode: 'sensing_timer',
|
|
||||||
inputs: {},
|
|
||||||
fields: {},
|
|
||||||
next: null,
|
|
||||||
topLevel: true,
|
|
||||||
parent: null,
|
|
||||||
shadow: false,
|
|
||||||
isMonitored: true,
|
|
||||||
x: '0',
|
|
||||||
y: '0'
|
|
||||||
});
|
|
||||||
|
|
||||||
vm.clear();
|
vm.clear();
|
||||||
vm.setCompatibilityMode(false);
|
vm.setCompatibilityMode(false);
|
||||||
vm.setTurboMode(false);
|
vm.setTurboMode(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue