Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web] KeymanWeb - Engine testing #585

Merged
merged 29 commits into from
Feb 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
496433a
Initial engine unit test infrastructure in place with keyboard load t…
jahorton Feb 9, 2018
fc19f32
Unit test can now simulate a key press. Desktop only; is not yet fil…
jahorton Feb 9, 2018
317230b
Slight documentation enhancement.
jahorton Feb 9, 2018
9b5ef1f
A click-simulating OSK test has been added to the engine suite.
jahorton Feb 9, 2018
e58312d
Removed unnecessary timeout delays.
jahorton Feb 9, 2018
6d1f718
Design and partial integration of recording-oriented resources for en…
jahorton Feb 10, 2018
12d3a04
Added new InputTestSequence class and integrated a test with it.
jahorton Feb 10, 2018
1f35e7a
Partial touch support - keystrokes on touch-aliased elements are now …
jahorton Feb 10, 2018
b493be2
Touch emulation now supported. Had to alter true code to run dev tes…
jahorton Feb 10, 2018
1b2da39
Added code to capture + reconstruct keyboard stubs from KMW's activeS…
jahorton Feb 11, 2018
b3896bd
Rudimentary test recording UI is now up for the recorder page.
jahorton Feb 11, 2018
a90cb14
Recorder page is now Chrome-touch-simulation compatible.
jahorton Feb 11, 2018
889d2e2
Adjusts the OSK to allow the recorder to detect touch-based deletions.
jahorton Feb 11, 2018
8e1e0bc
Merge branch 'web-350-attachment-tests' into web-350-engine-tests
jahorton Feb 13, 2018
c0b518e
Accidental lines left out of merge + necessitated change to the new '…
jahorton Feb 13, 2018
6970c86
Relocates the recorder into the general /source/ directory + ties its…
jahorton Feb 13, 2018
1d88348
Engine test + recorder build now integrated and working with CI test …
jahorton Feb 13, 2018
607cefd
InputTestSequence JSON pretty-print is "go." Fixes recorder post-merge.
jahorton Feb 13, 2018
99db1cd
Moved Device to new file for Recorder access, + objects for auto tests.
jahorton Feb 13, 2018
5ec722e
Added initial constructor for the KeyboardTest class.
jahorton Feb 13, 2018
18ba780
Merge branch 'master' into web-350-engine-tests
jahorton Feb 14, 2018
7ebb730
Recorder infrastructure and UI now only need polish.
jahorton Feb 14, 2018
428ba42
The new OO structure is now used by the example engine test case.
jahorton Feb 14, 2018
819e37a
Minor test runner parameter tweak for readability.
jahorton Feb 14, 2018
0f14149
Tweaks recorder touch support to better load existing JSON.
jahorton Feb 14, 2018
0725a8f
Now takes in per-sequence error messages if specified.
jahorton Feb 14, 2018
ffa76e7
Fixes for PR comments.
jahorton Feb 15, 2018
049f7a7
Missed a minor detail and addressed the OSK BKSP key thing.
jahorton Feb 15, 2018
22c1c98
Merge branch 'master' into web-350-engine-tests
jahorton Feb 15, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/source/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ copy_resources ( ) {
cp -Rf $SOURCE/*.ts $1/src
echo $BUILD > $1/src/version.txt

# Remove KMW Recorder source.
rm -f $1/src/recorder_*.ts
rm -f $1/src/recorder_*.js

cp -Rf $SOURCE/resources/ui $1/src/ >/dev/null
cp -Rf $SOURCE/resources/osk $1/src/ >/dev/null

Expand Down
54 changes: 54 additions & 0 deletions web/source/build_recorder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#! /bin/bash
#
# Compile the KeymanWeb Recorder module for use with developing/running engine tests.
#

# Fails the build if a specified file does not exist.
assert ( ) {
if ! [ -f $1 ]; then
fail "Build failed."
exit 1
fi
}

fail() {
FAILURE_MSG="$1"
if [[ "$FAILURE_MSG" == "" ]]; then
FAILURE_MSG="Unknown failure"
fi
echo "${ERROR_RED}$FAILURE_MSG${NORMAL}"
exit 1
}

# Ensure the dependencies are downloaded. --no-optional should help block fsevents warnings.
echo "Node.js + dependencies check"
npm install --no-optional

if [ $? -ne 0 ]; then
fail "Build environment setup error detected! Please ensure Node.js is installed!"
fi

# Definition of global compile constants
COMPILED_FILE="recorder_InputEvents.js"
OUTPUT="../release/recorder"
NODE_SOURCE="source"
ENGINE_TEST_OUTPUT="../unit_tests/"

readonly OUTPUT
readonly NODE_SOURCE
readonly ENGINE_TEST_OUTPUT

# Ensures that we rely first upon the local npm-based install of Typescript.
# (Facilitates automated setup for build agents.)
PATH="../../node_modules/.bin:$PATH"

compiler="npm run tsc --"
compilecmd="$compiler"

$compilecmd -p $NODE_SOURCE/tsconfig.recorder.json
if [ $? -ne 0 ]; then
fail "Typescript compilation failed."
fi

cp $OUTPUT/$COMPILED_FILE $ENGINE_TEST_OUTPUT
cp $OUTPUT/$COMPILED_FILE.map $ENGINE_TEST_OUTPUT
196 changes: 196 additions & 0 deletions web/source/kmwRecorder.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<!-- Set the viewport width to match phone and tablet device widths -->
<meta name="viewport" content="width=device-width,user-scalable=no" />

<!-- Allow KeymanWeb to be saved to the iPhone home screen -->
<meta name="apple-mobile-web-app-capable" content="yes" />

<!-- Enable IE9 Standards mode -->
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<title>KeymanWeb - Test Input Recorder</title>

<!-- Your page CSS -->
<style type='text/css'>
body {
font-family: Tahoma, helvetica;
}

h3 {
font-size: 1em;
font-weight: normal;
color: darkred;
margin-bottom: 4px
}

.test {
font-size: 1.5em;
width: 80%;
min-height: 30px;
border: 1px solid gray;
}

#KeymanWebControl {
width: 50%;
min-width: 600px;
}

td {
vertical-align:top;
padding:15px;
}
</style>

<script src="../release/unminified/web/keymanweb.js" type="application/javascript"></script>
<script src="../release/unminified/web/kmwuitoggle.js"></script>
<script src="recorder_KeyboardScripts.js" type="application/javascript"></script>
<script src="../release/recorder/recorder_InputEvents.js" type="application/javascript"></script>
<script src="recorder_ui_and_stubs.js" type="application/javascript"></script>

<!-- Initialization: set paths to keyboards, resources and fonts as required -->
<script>
keyman.init({
attachType: 'auto',
});
</script>
</head>

<!-- Sample page HTML -->

<body onload='loadKeyboards();'>
<table style="width:100%">
<tr>
<td colspan="2">
<h1>KeymanWeb - Test Input Recorder</h1>
<p>This page is designed to record KeymanWeb input for use in test case development.</p>
</td>
</tr>
</table>
<hr/>
<table width="100%">
<tr>
<td style="width:100%">
<h2>Load Existing JSON</h2>
<input type="file" id="existingFile" accept=".json" onchange="loadExistingTest(this.files);" />
</td>
</tr>
</table>
<hr>
<table width="100%">
<tr>
<td style="width:50%">
<h2>Load a Keyboard</h2>
<h3>Add a keyboard by keyboard stub (to addKeyboards):</h3>
<textarea style="width:90%; height:100px" id='kbd_stub_add' class='kmw-disabled' onkeypress="clickOnEnter(event,4);"></textarea><br>
<input type='button' id='btn4' onclick='addKeyboard(4);' style="width:90%" value='Add' />
</td>
<td style="vertical-align: bottom;">
<h3>Add a keyboard by keyboard name:</h3>
<input type='input' id='kbd_id1' class='kmw-disabled' onkeypress="clickOnEnter(event,1);"/>
<input type='button' id='btn1' onclick='addKeyboard(1);' value='Add' />

<h3>Add a keyboard by ISO 639 or BCP-47 language code:</h3>
<input type='input' id='kbd_id2' class='kmw-disabled' onkeypress="clickOnEnter(event,2);"/>
<input type='button' id='btn2' onclick='addKeyboard(2);' value='Add' />

<h3>Add a keyboard by language name:</h3>
<input type='input' id='kbd_id3' class='kmw-disabled' onkeypress="clickOnEnter(event,3);"/>
<input type='button' id='btn3' onclick='addKeyboard(3);' value='Add' />
</td>
</tr>
</table>
<hr/>
<table style="width:100%">
<tr>
<td style="width:50%;" >
<h2>Keyboard Selection</h2>
<p>Each defined test set should utilize the same keyboard.</p>
<p>Select a keyboard: <select id='KMW_Keyboard' onchange='KMW_KeyboardChange()'><option value=''>-disabled-</option></select></p>
<p>Please ensure a copy of this keyboard's *.js resides at the specified location within the <code>unit_tests/</code> folder.</p>
</td>
<td style="width:50%;">
<p>Currently active stub (for use with addKeyboards):</p>
<textarea id='activeStub' style="width:80%; height:100px" readonly></textarea>
</td>
</tr>
</table>
<hr/>
<table style="width:100%">
<tr>
<td style="width:50%">
<h2>Constraint Selection</h2>
<p>Active form factor: <span style="font-weight: bold;" id="activeFormFactor"/></p>
<p>Touch availablility: <span style="font-weight: bold;" id="activeTouch"/></p>
<p>Current OS: <span style="font-weight: bold;" id="activeOS"/></p>
<p>Current browser: <span style="font-weight: bold;" id="activeBrowser"/></p>
</td>
<td style="width:50%">
<p style="font-weight: bold;">Valid OS:</p>
<nobr><input type="checkbox" id="platform_any" checked onclick="clearPlatforms();">
<label for="platform_any">Any</label></nobr>
<nobr><input type="checkbox" id="platform_windows" onclick="setPlatformAny();" value="windows">
<label for="platform_windows">Windows</label></nobr>
<nobr><input type="checkbox" id="platform_macosx" onclick="setPlatformAny();" value="macosx">
<label for="platform_macosx">Mac OS X</label></nobr>
<nobr><input type="checkbox" id="platform_linux" onclick="setPlatformAny();" value="linux">
<label for="platform_linux">Linux</label></nobr>
<nobr><input type="checkbox" id="platform_android" onclick="setPlatformAny();" value="android">
<label for="platform_android">Android</label></nobr>
<nobr><input type="checkbox" id="platform_ios" onclick="setPlatformAny();" value="ios">
<label for="platform_ios">iOS</label></nobr>
<p style="font-weight: bold">Valid browser:</p>
<nobr><input type="checkbox" id="browser_any" checked onclick="clearBrowsers();">
<label for="browser_any">Any</label></nobr>
<nobr><input type="checkbox" id="browser_chrome" onclick="setBrowserAny();" value="chrome">
<label for="browser_chrome">Chrome</label></nobr>
<nobr><input type="checkbox" id="browser_firefox" onclick="setBrowserAny();" value="firefox">
<label for="browser_firefox">Firefox</label></nobr>
<nobr><input type="checkbox" id="browser_safari" onclick="setBrowserAny();" value="safari">
<label for="browser_safari">Safari</label></nobr>
<nobr><input type="checkbox" id="browser_ie" onclick="setBrowserAny();" value="ie">
<label for="browser_ie">IE</label></nobr>
<nobr><input type="checkbox" id="browser_opera" onclick="setBrowserAny();" value="opera">
<label for="browser_opera">Opera</label></nobr>
</td>
</tr>
</table>
<hr/>
<table style="width:100%">
<tr>
<td style="width:50%">
<h2>Input Recording</h2>
<p>Error message here:</p>
<input type='text' id='errorText' onchange="errorUpdate();"/>
<p>Record input here:</p>
<input type='text' id='receiver'/>
<p>You must click 'Set Sequence' to save any changes to an input sequence above
before continuing input recording, or they will be lost upon new input.</p>
</td>
<td style="width:50%">
<p>Current test sequence JSON:</p>
<textarea id='inputRecord' style="width:90%; height:180px"></textarea>
<button id='btnSave' type="button" onclick="saveInputRecord();">Save Test Sequence</button>
<button id='btnCopy' type="button" onclick="copyInputRecord();">Copy Sequence</button>
<button id='btnSet' type="button" onclick="reviseInputRecord();">Set Sequence</button>
<button id='btnClear' type="button" onclick="resetInputRecord();">Clear Sequence</button>
<!-- Add 'add to set' button -->
</td>
</tr>
</table>
<hr/>
<table style="width:100%">
<tr>
<td width="100%">
<h2>Test suite JSON:</h2>
<textarea id="masterJSON" class="kmw-disabled" style="width:100%; height:600px"></textarea>
</td>
</tr>
</table>
</body>

</html>
2 changes: 1 addition & 1 deletion web/source/kmwapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ goog.exportSymbol("Util.prototype.getAbsoluteX", Util.prototype._GetAbsoluteX);
goog.exportSymbol("Util.prototype.getAbsoluteY", Util.prototype._GetAbsoluteY);
goog.exportSymbol("Util.prototype.getAbsolute", Util.prototype._GetAbsolute);
goog.exportSymbol("Util.prototype.createElement", Util.prototype.createElement);
goog.exportSymbol("Util.prototype.getIEVersion", Util.prototype._GetIEVersion);
goog.exportSymbol("Util.prototype.getIEVersion", Util.prototype.getIEVersion);
goog.exportSymbol("Util.prototype.isTouchDevice", Util.prototype.isTouchDevice);
goog.exportSymbol("Util.prototype.createShim", Util.prototype.createShim);
goog.exportSymbol("Util.prototype.showShim", Util.prototype.showShim);
Expand Down
2 changes: 1 addition & 1 deletion web/source/kmwcallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ class KeyboardInterface {
* Description Get start of selection (with supplementary plane modifications)
*/
_SelPos(Pelem: HTMLElement) {
var Ldoc: Document, Ldv: Window, isMSIE=(this.keymanweb.util._GetIEVersion()<999); // I3363 (Build 301)
var Ldoc: Document, Ldv: Window, isMSIE=(Device._GetIEVersion()<999); // I3363 (Build 301)

if((<any>this.keymanweb).isPositionSynthesized())
return this.keymanweb.touchAliasing.getTextCaret(Pelem);
Expand Down
Loading