Differentiate clamped from non clamped mouse io data (GUI#179)

This commit is contained in:
Paul Kaplan 2018-01-09 09:39:52 -05:00
parent 980efedf0f
commit bbcb6bd5b7
4 changed files with 38 additions and 16 deletions

View file

@ -10,6 +10,8 @@ test('spec', t => {
t.type(m.postData, 'function');
t.type(m.getX, 'function');
t.type(m.getY, 'function');
t.type(m.getClampedX, 'function');
t.type(m.getClampedY, 'function');
t.type(m.getIsDown, 'function');
t.end();
});
@ -19,14 +21,16 @@ test('mouseUp', t => {
const m = new Mouse(rt);
m.postData({
x: 1,
x: -20,
y: 10,
isDown: false,
canvasWidth: 480,
canvasHeight: 360
});
t.strictEquals(m.getX(), -239);
t.strictEquals(m.getX(), -260);
t.strictEquals(m.getY(), 170);
t.strictEquals(m.getClampedX(), -240);
t.strictEquals(m.getClampedY(), 170);
t.strictEquals(m.getIsDown(), false);
t.end();
});
@ -37,13 +41,15 @@ test('mouseDown', t => {
m.postData({
x: 10,
y: 100,
y: 400,
isDown: true,
canvasWidth: 480,
canvasHeight: 360
});
t.strictEquals(m.getX(), -230);
t.strictEquals(m.getY(), 80);
t.strictEquals(m.getY(), -220);
t.strictEquals(m.getClampedX(), -230);
t.strictEquals(m.getClampedY(), -180);
t.strictEquals(m.getIsDown(), true);
t.end();
});