-
-
Notifications
You must be signed in to change notification settings - Fork 838
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web: Fix enter key's keyCode, + test
- Loading branch information
1 parent
1bb96d8
commit b1cbdc4
Showing
7 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
web/packages/selfhosted/test/integration_tests/keyboard_input/Test.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package { | ||
import flash.display.MovieClip; | ||
import flash.events.KeyboardEvent; | ||
|
||
public class Test extends MovieClip { | ||
public function Test() { | ||
text.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); | ||
text.addEventListener(KeyboardEvent.KEY_UP, onKeyUp); | ||
|
||
// Magic phrase is expected by "playAndMonitor", tells the test that it's ready | ||
trace("Hello from Flash!"); | ||
} | ||
|
||
function onKeyDown(event: KeyboardEvent) { | ||
trace("onKeyDown"); | ||
trace("event.charCode = " + event.charCode); | ||
trace("event.keyCode = " + event.keyCode); | ||
trace(""); | ||
} | ||
|
||
function onKeyUp(event: KeyboardEvent) { | ||
trace("onKeyUp"); | ||
trace("event.charCode = " + event.charCode); | ||
trace("event.keyCode = " + event.keyCode); | ||
trace(""); | ||
} | ||
} | ||
} |
Binary file added
BIN
+4.62 KB
web/packages/selfhosted/test/integration_tests/keyboard_input/test.fla
Binary file not shown.
48 changes: 48 additions & 0 deletions
48
web/packages/selfhosted/test/integration_tests/keyboard_input/test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { jsApiBefore, getTraceOutput } = require("../../utils"); | ||
const { use, expect } = require("chai"); | ||
const chaiHtml = require("chai-html"); | ||
const { Key } = require("webdriverio"); | ||
|
||
use(chaiHtml); | ||
|
||
describe("Key up and down events work", () => { | ||
jsApiBefore("/test/integration_tests/keyboard_input/test.swf"); | ||
|
||
it("'a' key is recognised", async () => { | ||
const player = await browser.$("<ruffle-player>"); | ||
await player.click(); | ||
|
||
await browser.keys("a"); | ||
const actualOutput = await getTraceOutput(browser, player); | ||
expect(actualOutput).to.eql( | ||
`onKeyDown | ||
event.charCode = 97 | ||
event.keyCode = 65 | ||
onKeyUp | ||
event.charCode = 97 | ||
event.keyCode = 65 | ||
`, | ||
); | ||
}); | ||
|
||
it("enter key is recognised", async () => { | ||
const player = await browser.$("<ruffle-player>"); | ||
await player.click(); | ||
|
||
await browser.keys([Key.Enter]); | ||
const actualOutput = await getTraceOutput(browser, player); | ||
expect(actualOutput).to.eql( | ||
`onKeyDown | ||
event.charCode = 13 | ||
event.keyCode = 13 | ||
onKeyUp | ||
event.charCode = 13 | ||
event.keyCode = 13 | ||
`, | ||
); | ||
}); | ||
}); |
Binary file added
BIN
+1.04 KB
web/packages/selfhosted/test/integration_tests/keyboard_input/test.swf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters