mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Bug 1336002 - Part 4: Add gamepad button touched tests; r=Lenzak,qdot
MozReview-Commit-ID: 5OoR2vf0zZn --HG-- extra : rebase_source : 7f1089f5e50a68dc64e7b1615a6d28de167a7ae4
This commit is contained in:
parent
639e273a82
commit
d8ee3acbe9
@ -34,8 +34,8 @@ function checkTimestamp(){
|
||||
index = i;
|
||||
// Press a button to make the gamepad visible
|
||||
// to the page.
|
||||
GamepadService.newButtonEvent(index, 0, true);
|
||||
GamepadService.newButtonEvent(index, 0, true);
|
||||
GamepadService.newButtonEvent(index, 0, true, true);
|
||||
GamepadService.newButtonEvent(index, 0, true, true);
|
||||
ok(true, "test");
|
||||
});
|
||||
}
|
||||
@ -56,7 +56,7 @@ function buttonpresshandler(e) {
|
||||
} else {
|
||||
ok(timea <= e.gamepad.timestamp, "Timestamp less than last timestamp");
|
||||
}
|
||||
GamepadService.newButtonEvent(index, 0, false);
|
||||
GamepadService.newButtonEvent(index, 0, false, false);
|
||||
if (!firstPress) {
|
||||
testOver = true;
|
||||
SpecialPowers.executeSoon(cleanup);
|
||||
|
@ -21,8 +21,8 @@ let SpecialPowers = window.parent.SpecialPowers;
|
||||
var gamepad_index;
|
||||
|
||||
function pressButton() {
|
||||
GamepadService.newButtonEvent(gamepad_index, 0, true);
|
||||
GamepadService.newButtonEvent(gamepad_index, 0, false);
|
||||
GamepadService.newButtonEvent(gamepad_index, 0, true, true);
|
||||
GamepadService.newButtonEvent(gamepad_index, 0, false, false);
|
||||
}
|
||||
|
||||
// Add a gamepad
|
||||
|
@ -35,8 +35,8 @@ window.addEventListener("gamepadbuttondown", function() {
|
||||
});
|
||||
|
||||
function pressButton() {
|
||||
GamepadService.newButtonEvent(gamepad_index, 0, true);
|
||||
GamepadService.newButtonEvent(gamepad_index, 0, false);
|
||||
GamepadService.newButtonEvent(gamepad_index, 0, true, true);
|
||||
GamepadService.newButtonEvent(gamepad_index, 0, false, false);
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
|
@ -47,17 +47,21 @@ function gamepad_loaded() {
|
||||
w1.addEventListener("gamepadbuttonup", () => {
|
||||
ok(!f1.contentWindow.gamepad.buttons[0].pressed,
|
||||
"frame 1 no button pressed");
|
||||
ok(!f1.contentWindow.gamepad.buttons[0].touched,
|
||||
"frame 1 no button touched");
|
||||
});
|
||||
w2.addEventListener("gamepadbuttonup", () => {
|
||||
ok(!f2.contentWindow.gamepad.buttons[0].pressed,
|
||||
"frame 2 no button pressed");
|
||||
ok(!f2.contentWindow.gamepad.buttons[0].touched,
|
||||
"frame 2 no button touched");
|
||||
setFrameVisible(f2, false);
|
||||
SpecialPowers.executeSoon(function() {
|
||||
GamepadService.newButtonEvent(index, 0, true);
|
||||
GamepadService.newButtonEvent(index, 0, true, true);
|
||||
});
|
||||
})
|
||||
// Now press the button, but don't release it.
|
||||
GamepadService.newButtonEvent(index, 0, true);
|
||||
GamepadService.newButtonEvent(index, 0, true, true);
|
||||
}
|
||||
|
||||
window.addEventListener("gamepadbuttondown", function() {
|
||||
@ -74,10 +78,12 @@ var tests = [
|
||||
function check_button_pressed() {
|
||||
// At this point the both frames should see the button as pressed.
|
||||
ok(f1.contentWindow.gamepad.buttons[0].pressed, "frame 1 sees button pressed");
|
||||
ok(f1.contentWindow.gamepad.buttons[0].touched, "frame 1 sees button touched");
|
||||
ok(f2.contentWindow.gamepad.buttons[0].pressed, "frame 2 sees button pressed");
|
||||
ok(f2.contentWindow.gamepad.buttons[0].touched, "frame 2 sees button touched");
|
||||
|
||||
// Now release the button, then hide the second frame.
|
||||
GamepadService.newButtonEvent(index, 0, false);
|
||||
GamepadService.newButtonEvent(index, 0, false, false);
|
||||
}
|
||||
|
||||
function check_second_frame_no_button_press () {
|
||||
@ -86,7 +92,9 @@ function check_second_frame_no_button_press () {
|
||||
* but the second frame should not, since it's hidden.
|
||||
*/
|
||||
ok(f1.contentWindow.gamepad.buttons[0].pressed, "frame 1 sees button pressed");
|
||||
ok(f1.contentWindow.gamepad.buttons[0].touched, "frame 1 sees button touched");
|
||||
ok(!f2.contentWindow.gamepad.buttons[0].pressed, "frame 2 should not see button pressed");
|
||||
ok(!f2.contentWindow.gamepad.buttons[0].touched, "frame 2 should not see button touched");
|
||||
|
||||
// Now unhide the second frame.
|
||||
setFrameVisible(f2, true);
|
||||
@ -94,6 +102,7 @@ function check_second_frame_no_button_press () {
|
||||
// Now that the frame is visible again, it should see the button
|
||||
// that was pressed.
|
||||
ok(f2.contentWindow.gamepad.buttons[0].pressed, "frame 2 sees button pressed");
|
||||
ok(f2.contentWindow.gamepad.buttons[0].touched, "frame 2 sees button touched");
|
||||
// cleanup
|
||||
GamepadService.removeGamepad(index);
|
||||
SimpleTest.finish();
|
||||
|
@ -20,8 +20,8 @@ window.addEventListener("gamepadbuttondown", function() {
|
||||
});
|
||||
|
||||
function pressButton() {
|
||||
GamepadService.newButtonEvent(index, 0, true);
|
||||
GamepadService.newButtonEvent(index, 0, false);
|
||||
GamepadService.newButtonEvent(index, 0, true, true);
|
||||
GamepadService.newButtonEvent(index, 0, false, false);
|
||||
}
|
||||
|
||||
function setFrameVisible(f, visible) {
|
||||
|
@ -42,7 +42,7 @@ function startTest() {
|
||||
0).then(function(i) {
|
||||
index = i;
|
||||
// Simulate button events on the gamepad we added
|
||||
GamepadService.newButtonEvent(index, 0, true);
|
||||
GamepadService.newButtonEvent(index, 0, true, true);
|
||||
});
|
||||
}
|
||||
|
||||
@ -59,12 +59,14 @@ function connecthandler(e) {
|
||||
function buttontest1() {
|
||||
var gamepads = navigator.getGamepads();
|
||||
is(gamepads[0].buttons[0].pressed, true, "gamepad button should register as pressed");
|
||||
GamepadService.newButtonValueEvent(index, 1, true, 0.5);
|
||||
is(gamepads[0].buttons[0].touched, true, "gamepad button should register as touched");
|
||||
GamepadService.newButtonValueEvent(index, 1, true, true, 0.5);
|
||||
}
|
||||
|
||||
function buttontest2() {
|
||||
var gamepads = navigator.getGamepads();
|
||||
is(gamepads[0].buttons[1].pressed, true, "gamepad button should register as pressed");
|
||||
is(gamepads[0].buttons[1].touched, true, "gamepad button should register as touched");
|
||||
is(gamepads[0].buttons[1].value, 0.5, "gamepad button value should be 0.5");
|
||||
GamepadService.removeGamepad(index);
|
||||
SimpleTest.finish();
|
||||
|
@ -51,7 +51,7 @@ function startTest() {
|
||||
0).then(function(index) {
|
||||
internal_index1 = index;
|
||||
// Press a button to make the gamepad visible to the page.
|
||||
GamepadService.newButtonEvent(internal_index1, 0, true);
|
||||
GamepadService.newButtonEvent(internal_index1, 0, true, true);
|
||||
});
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ function check_first_gamepad(e) {
|
||||
2,
|
||||
0).then(function(index) {
|
||||
internal_index2 = index;
|
||||
GamepadService.newButtonEvent(internal_index2, 0, true);
|
||||
GamepadService.newButtonEvent(internal_index2, 0, true, true);
|
||||
});
|
||||
ok(true, "Done checking first gamepad");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user