Merge pull request #6597 from keymanapp/chore/web/fixup-test-paths

chore(web): fixup keyboard-processor and input-processor tests 🎡
This commit is contained in:
Marc Durdin 2022-05-27 08:46:47 +10:00 committed by GitHub
commit 9a29c08c42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 277 additions and 184 deletions

View file

@ -54,22 +54,36 @@ if [ $FETCH_DEPS = true ]; then
fi
# Ensures that the lexical model compiler has been built locally.
echo_heading "Preparing Lexical Model Compiler for test use"
pushd $WORKING_DIRECTORY/node_modules/@keymanapp/lexical-model-compiler
npm run build
popd
#echo_heading "Preparing Lexical Model Compiler for test use"
#pushd $WORKING_DIRECTORY/node_modules/@keymanapp/lexical-model-compiler
#npm run build
#popd
test-headless ( ) {
if (( CI_REPORTING )); then
FLAGS="$FLAGS --reporter mocha-teamcity-reporter"
fi
npm run mocha -- --recursive $FLAGS ./tests/cases/
# Poor Man's Modules until we support ES6 throughout
PREPEND=./tests/cases/prepend.js
(cat ../../../../resources/web-environment/build/index.js; echo) > $PREPEND
(cat ../utils/build/index.js; echo) >> $PREPEND
(cat ../keyboard-processor/build/index.js; echo) >> $PREPEND
(cat ../input-processor/build/index.js; echo) >> $PREPEND
(cat tests/cases/inputProcessor.js; echo) >> $PREPEND
# TODO: We will re-enable languageProcessor tests when we have sorted out
# paths and modules for lmc
#(cat tests/cases/languageProcessor.js; echo) >> $PREPEND
npm run mocha -- --recursive $FLAGS ./tests/cases/prepend.js
rm $PREPEND
}
if [ $FETCH_DEPS = true ]; then
# First, run tests on the keyboard processor.
pushd $WORKING_DIRECTORY/node_modules/@keymanapp/keyboard-processor
pushd "$KEYMAN_ROOT/common/core/web/keyboard-processor"
./test.sh -skip-package-install || fail "Tests failed by dependencies; aborting integration tests."
popd
fi

View file

@ -2,13 +2,12 @@ var assert = require('chai').assert;
var fs = require("fs");
var vm = require("vm");
let InputProcessor = require('../../dist');
// Required initialization setup.
global.com = InputProcessor.com; // exports all keyboard-processor namespacing.
global.keyman = {}; // So that keyboard-based checks against the global `keyman` succeed.
// 10.0+ dependent keyboards, like khmer_angkor, will otherwise fail to load.
let InputProcessor = com.keyman.text.InputProcessor;
let device = {
formFactor: 'phone',
OS: 'ios',
@ -55,7 +54,7 @@ describe('InputProcessor', function() {
var keyboard;
// Easy peasy long context: use the input processor's full source!
let coreSourceCode = fs.readFileSync('dist/index.js', 'utf-8');
let coreSourceCode = fs.readFileSync('build/index.js', 'utf-8');
// At the time this test block was written... 810485 chars.
// Let's force it to the same order of magnitude, even if the codebase grows.

View file

@ -1,6 +1,18 @@
namespace com.keyman.keyboards {
type KeyDistribution = text.KeyDistribution;
// TS 3.9 changed behavior of getters to make them
// non-enumerable by default. This broke our 'polyfill'
// functions which depended on enumeration to copy the
// relevant props over.
// https://github.com/microsoft/TypeScript/pull/32264#issuecomment-677718191
function Enumerable(
target: unknown,
propertyKey: string,
descriptor: PropertyDescriptor
) {
descriptor.enumerable = true;
};
export class ActiveKey implements LayoutKey {
@ -52,6 +64,7 @@ namespace com.keyman.keyboards {
*
* Is used to determine the keycode for input events, rule-matching, and keystroke processing.
*/
@Enumerable
public get baseKeyID(): string {
if(typeof this.id === 'undefined') {
return undefined;
@ -78,6 +91,7 @@ namespace com.keyman.keyboards {
*
* Useful when the active layer of an input-event is already known.
*/
@Enumerable
public get coreID(): string {
if(typeof this.id === 'undefined') {
return undefined;
@ -110,6 +124,7 @@ namespace com.keyman.keyboards {
*
* Useful when only the active keyboard is known about an input event.
*/
@Enumerable
public get elementID(): string {
if(typeof this.id === 'undefined') {
return undefined;

View file

@ -10,7 +10,8 @@
"target": "es5",
"types": ["node"],
"lib": ["es6"],
"outFile": "../build/index.js"
"outFile": "../build/index.js",
"experimentalDecorators": true,
},
"references": [
{ "path": "../../../../../common/models/types" },

View file

@ -55,13 +55,43 @@ test-headless ( ) {
FLAGS="$FLAGS --reporter mocha-teamcity-reporter"
fi
npm run mocha -- --recursive $FLAGS ./tests/cases/
# Poor Man's Modules until we support ES6 throughout
PREPEND=./tests/cases/prepend.js
rm -f $PREPEND
for n in tests/cases/*.js; do
echo $n
(cat ../../../../resources/web-environment/build/index.js; echo) > $PREPEND
(cat ../utils/build/index.js; echo) >> $PREPEND
(cat ../tools/recorder/build/nodeProctor/index.js; echo) >> $PREPEND
(cat ../keyboard-processor/build/index.js; echo) >> $PREPEND
(cat $n; echo) >> $PREPEND;
npm run mocha -- --recursive $FLAGS $PREPEND || die
rm $PREPEND
done
# Poor Man's Modules until we support ES6 throughout
PREPEND=./tests/cases/engine/prepend.js
rm -f $PREPEND
for n in tests/cases/engine/*.js; do
echo $n
(cat ../../../../resources/web-environment/build/index.js; echo) > $PREPEND
(cat ../utils/build/index.js; echo) >> $PREPEND
(cat ../tools/recorder/build/nodeProctor/index.js; echo) >> $PREPEND
(cat ../keyboard-processor/build/index.js; echo) >> $PREPEND
(cat $n; echo) >> $PREPEND;
npm run mocha -- --recursive $FLAGS $PREPEND || die
rm $PREPEND
done
# npm run mocha -- --recursive $FLAGS ./tests/cases/
}
# Build test dependency
pushd "$KEYMAN_ROOT/common/core/web/tools/recorder/src"
./build.sh -skip-package-install || fail "recorder-core compilation failed."
popd
if [ $FETCH_DEPS = true ]; then
# Build test dependency
pushd "$KEYMAN_ROOT/common/core/web/tools/recorder/src"
./build.sh -skip-package-install || fail "recorder-core compilation failed."
popd
fi
# Run headless (browserless) tests.
echo_heading "Running Keyboard Processor test suite"

View file

@ -2,11 +2,11 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');
let KeyboardProcessor = require('../../dist');
let KMWRecorder = require('../../../tools/recorder/dist/nodeProctor');
let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
describe('Engine - Basic Simulation', function() {
let testJSONtext = fs.readFileSync('../tests/resources/json/engine_tests/basic_lao_simulation.json');
@ -41,7 +41,7 @@ describe('Engine - Basic Simulation', function() {
// Converts each test set into its own Mocha-level test.
for(let set of testSuite.inputTestSets) {
let proctor = new KMWRecorder.NodeProctor(keyboard, device, assert.equal);
if(!proctor.compatibleWithSuite(testSuite)) {
it.skip(set.toTestName() + " - Cannot run this test suite on Node.");
} else {

View file

@ -2,15 +2,12 @@ var assert = require('chai').assert;
var fs = require("fs");
var vm = require("vm");
let KeyboardProcessor = require('../../dist');
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
global.keyman = {}; // So that keyboard-based checks against the global `keyman` succeed.
// 10.0+ dependent keyboards, like khmer_angkor, will otherwise fail to load.
let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
global.com = com;
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
String.kmwEnableSupplementaryPlane(false);
// Test the KeyboardProcessor interface.
describe('KeyboardProcessor', function() {

View file

@ -2,11 +2,11 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');
let KeyboardProcessor = require('../../dist');
let KMWRecorder = require('../../../tools/recorder/dist/nodeProctor');
let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
describe('Engine - Chirality', function() {
let testJSONtext = fs.readFileSync('../tests/resources/json/engine_tests/chirality.json');
@ -41,7 +41,7 @@ describe('Engine - Chirality', function() {
// Converts each test set into its own Mocha-level test.
for(let set of testSuite.inputTestSets) {
let proctor = new KMWRecorder.NodeProctor(keyboard, device, assert.equal);
if(!proctor.compatibleWithSuite(testSuite)) {
it.skip(set.toTestName() + " - Cannot run this test suite on Node.");
} else if(set.constraint.target == 'hardware') {

View file

@ -2,11 +2,12 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');
let KeyboardProcessor = require('../../dist');
let KMWRecorder = require('../../../tools/recorder/dist/nodeProctor');
let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
global.com = com;
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
describe('Engine - Deadkeys', function() {
let testJSONtext = fs.readFileSync('../tests/resources/json/engine_tests/deadkeys.json');
@ -41,7 +42,7 @@ describe('Engine - Deadkeys', function() {
// Converts each test set into its own Mocha-level test.
for(let set of testSuite.inputTestSets) {
let proctor = new KMWRecorder.NodeProctor(keyboard, device, assert.equal);
if(!proctor.compatibleWithSuite(testSuite)) {
it.skip(set.toTestName() + " - Cannot run this test suite on Node.");
} else {

View file

@ -2,22 +2,26 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');
let KeyboardProcessor = require('../../../dist');
let KMWRecorder = require('../../../../tools/recorder/dist/nodeProctor');
let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
global.com = com;
/*
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
/*
* ABOUT THIS TEST SUITE
* ---------------------
*
*
* This suite contains two types of tests, both designed to test all possible variations
* of behaviors that `KeyboardInterface.fullContextMatch` may be expected to handle.
*
*
* Type 1: White-box tests for validity of the generated context-cache
* - uses only the `baseSequence` of each test spec definition; does not
* use any `fullMatchDefs` entries.
* - uses the specified `contextCache` entry of each test spec in assertions
* - CTRL+F `Tests "stage 1" of fullContextMatch` for more details.
*
*
* Type 2: Black-box rule-matching tests
* - uses both `baseSequence` and `fullMatchDefs` entries of a test spec
* - tests that each simulation sequence's output either passes or fails against
@ -26,9 +30,6 @@ let KMWRecorder = require('../../../../tools/recorder/dist/nodeProctor');
* It should be a removable limitation, though.
*/
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
let device = {
formFactor: 'desktop',
OS: 'windows',
@ -68,12 +69,13 @@ function runEngineRuleSet(ruleSet, defaultNoun) {
// Now for the real test!
let processor = new KeyboardProcessor();
processor.device = device;
processor.activeKeyboard = keyboard;
var res = processor.keyboardInterface.fullContextMatch(ruleDef.n, target, ruleDef.rule);
var msg = matchTest.msg;
if(!msg) {
msg = defaultNoun + " incorrectly reported as " + (matchTest.result ? "unmatched!" : "matched!");
msg = defaultNoun + " incorrectly reported as " + (matchTest.result ? "unmatched!" : "matched!");
}
assert.equal(res, matchTest.result, msg);
}
@ -463,7 +465,7 @@ var ANY_CONTEXT_TEST_2 = {
*
* store(ac) 'ac'
* store(bc) 'bc'
*
*
* 'c' any(ac) any(bc) context(3) context(2) > 'success'
*/
var ANY_CONTEXT_TEST_3 = {
@ -520,7 +522,7 @@ var ANY_CONTEXT_TEST_3 = {
*
* store(ab) 'ab'
* store(bc) 'bc'
*
*
* 'c' any(ab) index(bc, 2) 'a' > 'success'
*/
var ANY_INDEX_TEST_1 = {
@ -567,7 +569,7 @@ var ANY_INDEX_TEST_1 = {
*
* store(ab) 'ab'
* store(bc) 'bc'
*
*
* 'c' any(ab) index(bc, 2) index(bc, 2) index(ab, 2) > 'success'
*/
var ANY_INDEX_TEST_2 = {
@ -614,7 +616,7 @@ var ANY_INDEX_TEST_2 = {
*
* store(ab) 'ab'
* store(bc) 'bc'
*
*
* 'c' any(ab) any(bc) index(bc, 3) index(ab, 2) > 'success'
*/
var ANY_INDEX_TEST_3 = {
@ -747,7 +749,7 @@ var DEADKEY_STORE_TEST_2 = {
*
* store(match) dk(0) dk(1) dk(2)
* store(abc) 'abc'
*
*
* any(match) index(abc, 1) > 'success'
*/
var DEADKEY_STORE_TEST_3 = {
@ -880,7 +882,7 @@ var NOTANY_NUL_TEST_1 = {
*
* store(match) dk(0) dk(1) dk(2)
* store(abc) 'abc'
*
*
* notany(match) any(abc) > 'success'
*/
var NOTANY_NUL_TEST_2 = {
@ -917,7 +919,7 @@ var NOTANY_NUL_TEST_2 = {
*
* store(first) dk(0) 'b' dk(2)
* store(second) 'a' dk(1) 'c'
*
*
* notany(first) any(second) > 'success'
*/
var NOTANY_NUL_TEST_3 = {
@ -964,8 +966,8 @@ var NOTANY_NUL_TEST_3 = {
}]
};
var DEADKEY_RULE_SET = [ DEADKEY_TEST_1, DEADKEY_TEST_2, DEADKEY_TEST_3, DEADKEY_TEST_4,
DEADKEY_TEST_5, DEADKEY_TEST_6
var DEADKEY_RULE_SET = [ DEADKEY_TEST_1, DEADKEY_TEST_2, DEADKEY_TEST_3, DEADKEY_TEST_4,
DEADKEY_TEST_5, DEADKEY_TEST_6
];
var ANY_CONTEXT_RULE_SET = [ ANY_CONTEXT_TEST_1, ANY_CONTEXT_TEST_2, ANY_CONTEXT_TEST_3 ];
var ANY_INDEX_RULE_SET = [ ANY_INDEX_TEST_1, ANY_INDEX_TEST_2, ANY_INDEX_TEST_3 ];
@ -1007,6 +1009,7 @@ describe('Engine - Context Matching', function() {
// Now for the real test!
let processor = new KeyboardProcessor();
processor.device = device;
processor.activeKeyboard = keyboard;
var res = processor.keyboardInterface._BuildExtendedContext(ruleDef.n, ruleDef.ln, target);
@ -1067,7 +1070,7 @@ describe('Engine - Context Matching', function() {
runEngineRuleSet([ANY_INDEX_TEST_3]);
});
});
describe('handles interactions with deadkeys in stores', function() {
it('for any on pure deadkey store: DEADKEY_STORE_TEST_1', function() {
runEngineRuleSet([DEADKEY_STORE_TEST_1]);

View file

@ -2,16 +2,11 @@ const assert = require('chai').assert;
const fs = require('fs');
const vm = require('vm');
const KeyboardProcessor = require('../../../dist');
const KMWRecorder = require('../../../../tools/recorder/dist/nodeProctor');
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
global.keyman = {}; // So that keyboard-based checks against the global `keyman` succeed.
// 10.0+ dependent keyboards, like khmer_angkor, will otherwise fail to load.
let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
String.kmwEnableSupplementaryPlane(false);
const device = {
formFactor: 'desktop',
@ -32,7 +27,7 @@ function runEngineRuleSet(ruleSet) {
}
/**
* Wrapper to simplify running tests -- supports either virtual key codes as string (e.g. 'A' is VK_A)
* Wrapper to simplify running tests -- supports either virtual key codes as string (e.g. 'A' is VK_A)
* or an array of integers. Does not currently support modifiers (not needed here).
* @param {String|Array} input Virtual key codes of each character (as string or array)
* @param {String} output Expected output
@ -40,11 +35,11 @@ function runEngineRuleSet(ruleSet) {
function runStringRuleSet(input, output) {
const rule = {
"inputs":
"inputs":
typeof input == 'string'
? input.split("").map(ch =>
? input.split("").map(ch =>
{ return { "type": "key", "keyCode": ch.charCodeAt(0), "states": 10752, "modifiers": 0, "modifierChanged": false, "isVirtualKey": true } })
: input.map(ch =>
: input.map(ch =>
{ return { "type": "key", "keyCode": ch, "states": 10752, "modifiers": 0, "modifierChanged": false, "isVirtualKey": true } }),
"output": output
};

View file

@ -2,36 +2,43 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');
let KeyboardProcessor = require('../../../dist');
let KMWRecorder = require('../../../../tools/recorder/dist/nodeProctor');
let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
let device = {
formFactor: 'desktop',
OS: 'windows',
browser: 'native'
}
describe('Engine - Stores', function() {
var toSupplementaryPairString = function(code){
var H = Math.floor((code - 0x10000) / 0x400) + 0xD800;
var L = (code - 0x10000) % 0x400 + 0xDC00;
return String.fromCharCode(H, L);
}
it('Store \'Explosion\'', function() {
let processor = new KeyboardProcessor();
processor.device = device;
// A 'hollow' Keyboard that only follows default rules. That said, we need a Keyboard
// instance to host cache data for our exploded store tests.
processor.activeKeyboard = new com.keyman.keyboards.Keyboard();
// Function defined at top of file; creates supplementary pairs for extended Unicode codepoints.
var u = toSupplementaryPairString;
var STORES = [
{smp: false, in: "apple", out: ['a','p','p','l','e']},
//In JS-escaped form: "\\ud804\\udd12\\ud804\\udd0d\\ud804\\udd0f\\ud804\\udd10\\ud804\\udd0a\\ud804\\udd05"
//(Supplementary pairs, copied from the easy_chakma keyboard.)
{smp: true, in: "𑄒𑄍𑄏𑄐𑄊𑄅", out: ["𑄒","𑄍","𑄏","𑄐","𑄊","𑄅"]},
// Built in-line via function. Looks functionally equivalent to "apple", but with SMP characters.
{smp: true, in: (u(0x1d5ba)+u(0x1d5c9)+u(0x1d5c9)+u(0x1d5c5)+u(0x1d5be)),
{smp: true, in: (u(0x1d5ba)+u(0x1d5c9)+u(0x1d5c9)+u(0x1d5c5)+u(0x1d5be)),
out: [u(0x1d5ba), u(0x1d5c9), u(0x1d5c9), u(0x1d5c5), u(0x1d5be)]}
];

View file

@ -2,11 +2,11 @@ var assert = require('chai').assert;
let fs = require('fs');
let vm = require('vm');
let KeyboardProcessor = require('../../../dist');
let KMWRecorder = require('../../../../tools/recorder/dist/nodeProctor');
let KeyboardProcessor = com.keyman.text.KeyboardProcessor;
global.keyman = {};
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
describe('Engine - Unmatched Final Groups', function() {
let testJSONtext = fs.readFileSync('../tests/resources/json/engine_tests/ghp_enter.json');

View file

@ -1,16 +1,15 @@
var assert = require('chai').assert;
let KeyboardProcessor = require('../../dist');
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
global.keyman = {};
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
describe("Transcriptions and Transforms", function() {
var toSupplementaryPairString = function(code){
var H = Math.floor((code - 0x10000) / 0x400) + 0xD800;
var L = (code - 0x10000) % 0x400 + 0xDC00;
return String.fromCharCode(H, L);
}
@ -50,7 +49,7 @@ describe("Transcriptions and Transforms", function() {
* Other modules coming later will need it, though.
*/
var transcription = target.buildTranscriptionFrom(original, null);
assert.equal(transcription.transform.insert, "s", "Failed to recognize inserted text");
assert.equal(transcription.transform.deleteLeft, 0, "Incorrectly detected left-of-caret deletions");
assert.equal(transcription.transform.deleteRight, 0, "Incorrectly detected right-of-caret deletions");
@ -322,11 +321,11 @@ but not himself.`; // Sheev Palpatine, in the Star Wars prequels.
// could eventually run in 'headless' mode.
var target = new Mock("apple");
var original = Mock.from(target);
target.setDeadkeyCaret(4);
target.insertDeadkeyBeforeCaret(0);
target.setDeadkeyCaret(1);
target.insertDeadkeyBeforeCaret(1);
target.insertDeadkeyBeforeCaret(1);
target.setDeadkeyCaret(2);
target.insertDeadkeyBeforeCaret(2); // 'a' dk(1) 'p' dk(2) | 'p' 'l' dk(0) 'e'
@ -337,8 +336,8 @@ but not himself.`; // Sheev Palpatine, in the Star Wars prequels.
target.setDeadkeyCaret(3);
target.deleteCharsBeforeCaret(2);
target.insertTextBeforeCaret("b");
target.insertDeadkeyBeforeCaret(3); // In effect: 'a' dk(1) 'b' dk(3) | 'l' dk(0) 'e'
target.insertTextBeforeCaret("b");
target.insertDeadkeyBeforeCaret(3); // In effect: 'a' dk(1) 'b' dk(3) | 'l' dk(0) 'e'
var transcription = target.buildTranscriptionFrom(original, null);
@ -350,7 +349,7 @@ but not himself.`; // Sheev Palpatine, in the Star Wars prequels.
var rem = transcription.removedDks;
assert.equal(rem.length, 1, "Incorrect count for removed deadkeys");
assert.deepEqual({d: rem[0].d, p: rem[0].p}, {d: 2, p: 2}, "Selected wrong deadkey as removed");
var ins = transcription.insertedDks;
assert.equal(ins.length, 1, "Incorrect count for inserted deadkeys");
assert.deepEqual({d: ins[0].d, p: ins[0].p}, {d: 3, p:2}, "Selected wrong deadkey as inserted");

View file

@ -1,8 +1,9 @@
var assert = require('chai').assert;
let KeyboardProcessor = require('../../dist');
// Required initialization setup.
global.com = KeyboardProcessor.com; // exports all keyboard-processor namespacing.
global.keyman = {};
// Initialize supplementary plane string extensions
String.kmwEnableSupplementaryPlane(false);
describe('Version Logic', function() {
it('Should provide a default, fallback value when nothing is specified', function() {
@ -42,5 +43,5 @@ describe('Version Logic', function() {
// Ensures the first "precede" check's return is flipped when the order's flipped.
assert.equal(v9_1_0.compareTo(v9_0_1), 1);
});
});

View file

@ -57,12 +57,12 @@ PATH="../node_modules/.bin:$PATH"
compiler="npm run tsc --"
compilecmd="$compiler"
$compilecmd -p "$SCRIPT_DIR/tsconfig.json"
$compilecmd --build "$SCRIPT_DIR/tsconfig.json"
if [ $? -ne 0 ]; then
fail "KeymanWeb recorder-core compilation failed."
fi
$compilecmd -p "$SCRIPT_DIR/nodeProctor.tsconfig.json"
$compilecmd --build "$SCRIPT_DIR/nodeProctor.tsconfig.json"
if [ $? -ne 0 ]; then
fail "Node-based unit-test Proctor compilation failed."
fi

View file

@ -1,4 +1,3 @@
/// <reference path="../node_modules/@keymanapp/keyboard-processor/src/text/keyEvent.ts" />
/// <reference path="proctor.ts" />
namespace KMWRecorder {
@ -92,7 +91,7 @@ namespace KMWRecorder {
static fromJSONObject(obj: any): RecordedKeystroke {
if(obj && obj.type) {
if(obj.type == "key") {
return new RecordedPhysicalKeystroke(obj as RecordedPhysicalKeystroke);
return new RecordedPhysicalKeystroke(obj as RecordedPhysicalKeystroke);
} else if(obj && obj.type) {
return new RecordedSyntheticKeystroke(obj as RecordedSyntheticKeystroke);
}
@ -375,7 +374,7 @@ namespace KMWRecorder {
this.id = activeStub.KLC;
this.name = activeStub.KL;
this.region = activeStub.KR;
// Fonts.
if(activeStub.KFont) {
this.font = new FontStubForLanguage(activeStub.KFont);
@ -515,7 +514,7 @@ namespace KMWRecorder {
this.result = output;
}
}
export interface TestSet<Sequence extends TestSequence<any>> {
constraint: Constraint;
@ -649,7 +648,7 @@ namespace KMWRecorder {
public specVersion: com.keyman.utils.Version = KeyboardTest.CURRENT_VERSION;
/**
* The version of KMW in which the Recorder was first written. Worked from 10.0 to 13.0 with
* The version of KMW in which the Recorder was first written. Worked from 10.0 to 13.0 with
* only backward-compatible changes and minor tweaks to conform to internal API shifts.
*/
public static readonly FALLBACK_VERSION = new com.keyman.utils.Version("10.0");
@ -667,8 +666,8 @@ namespace KMWRecorder {
inputTestSets: TestSet<any>[];
/**
* Reconstructs a KeyboardTest object from its JSON representation, restoring its methods.
* @param fromJSON
* Reconstructs a KeyboardTest object from its JSON representation, restoring its methods.
* @param fromJSON
*/
constructor(fromJSON?: string|KeyboardStub|KeyboardTest) {
if(!fromJSON) {
@ -720,7 +719,7 @@ namespace KMWRecorder {
var newSet = new RecordedSequenceTestSet(new Constraint(constraint));
this.inputTestSets.push(newSet);
newSet.addTest(seq);
newSet.addTest(seq);
}
test(proctor: Proctor) {

View file

@ -1,5 +1,3 @@
///<reference path="index.ts" />
///<reference path="../node_modules/@keymanapp/keyboard-processor/src/text/keyboardProcessor.ts" />
namespace KMWRecorder {
export class NodeProctor extends Proctor {

View file

@ -1,19 +1,28 @@
{
"extends": "../../../../../../tsconfig-base.json",
"compilerOptions": {
"allowJs": true,
"module": "none",
"outDir": "../dist/",
"inlineSources": true,
"inlineSourceMap": true,
"target": "es5",
"types": ["node"],
"lib": ["es6"],
"outFile": "../dist/nodeProctor.js"
"allowJs": true,
"module": "none",
"outDir": "../build/nodeProctor/",
"outFile": "../build/nodeProctor/index.js",
"inlineSources": true,
"inlineSourceMap": true,
"target": "es5",
"types": ["node"],
"lib": ["es6"]
},
"files": [
"../node_modules/@keymanapp/models-types/index.d.ts",
"../node_modules/@keymanapp/web-environment/environment.inc.ts",
"../node_modules/@keymanapp/web-utils/src/index.ts",
"nodeProctor.ts"
"index.ts",
"proctor.ts",
"nodeProctor.ts"
],
"references": [
{ "path": "../../../../../../resources/web-environment" },
{ "path": "../../../../../../common/core/web/utils" },
{ "path": "../../../../../../common/core/web/keyboard-processor/src" },
{ "path": "../../../../../../common/web/lm-message-types" }
]
}

View file

@ -1,19 +1,27 @@
{
"extends": "../../../../../../tsconfig-base.json",
"compilerOptions": {
"allowJs": true,
"module": "none",
"outDir": "../build/",
"inlineSources": true,
"inlineSourceMap": true,
"target": "es5",
"types": ["node"],
"lib": ["es6"],
"outFile": "../build/index.js"
"allowJs": true,
"module": "none",
"outDir": "../build/",
"inlineSources": true,
"inlineSourceMap": true,
"target": "es5",
"types": ["node"],
"lib": ["es6"],
"outFile": "../build/index.js"
},
"files": [
"../node_modules/@keymanapp/models-types/index.d.ts",
"../node_modules/@keymanapp/web-environment/environment.inc.ts",
"../node_modules/@keymanapp/web-utils/src/index.ts",
"index.ts"
"index.ts",
"proctor.ts"
],
"references": [
{ "path": "../../../../../../resources/web-environment" },
{ "path": "../../../../../../common/core/web/utils" },
{ "path": "../../../../../../common/core/web/keyboard-processor/src" },
{ "path": "../../../../../../common/web/lm-message-types" }
]
}

0
common/web/keyman-version/build.sh Normal file → Executable file
View file

View file

@ -473,7 +473,7 @@ if [ $BUILD_COREWEB = true ]; then
# TEMP STUB LMLayerWorkerCode
pwd
cat $INTERMEDIATE/keymanweb.js ../../common/predictive-text/build/intermediate/index.js > $INTERMEDIATE/km1.js
cat $INTERMEDIATE/keymanweb.js <(echo) ../../common/predictive-text/build/index.js > $INTERMEDIATE/km1.js
mv $INTERMEDIATE/km1.js $INTERMEDIATE/keymanweb.js
echo Native TypeScript compiled as $INTERMEDIATE/keymanweb.js

View file

@ -1,5 +1,5 @@
#! /bin/bash
#
#
# Compiles development-related KeymanWeb resources for use with developing/running tests.
# - the Recorder module (for engine tests)
# - the DOM module (for touch-alias and element-interface tests)
@ -49,7 +49,7 @@ compilecmd="$compiler"
for (( n=0; n<$PRODUCT_COUNT; n++ )) # Apparently, args ends up zero-based, meaning $2 => n=1.
do
$compilecmd -p $NODE_SOURCE/tsconfig.${SCRIPT_TAGS[$n]}.json
$compilecmd --build $NODE_SOURCE/tsconfig.${SCRIPT_TAGS[$n]}.json
if [ $? -ne 0 ]; then
fail "Typescript compilation failed for '${SCRIPT_TAGS[$n]}'."
fi

View file

@ -1,17 +1,28 @@
{
"extends": "../../tsconfig-base.json",
"compilerOptions": {
"allowJs": true,
"inlineSources": true,
"module": "none",
"outFile": "../release/dev_resources/dev_resources.js",
"sourceMap": true,
"target": "es5"
},
"allowJs": true,
"inlineSources": true,
"module": "none",
"outFile": "../release/dev_resources/dev_resources.js",
"sourceMap": true,
"target": "es5"
},
"files": [
"../node_modules/@keymanapp/keyboard-processor/src/text/outputTarget.ts",
"../node_modules/@keymanapp/web-environment/environment.inc.ts",
"../node_modules/@keymanapp/web-utils/src/index.ts",
"../node_modules/@keymanapp/lexical-model-layer/message.d.ts",
"dom/targets/wrapElement.ts"
"dom/targets/wrapElement.ts",
"dom/targets/input.ts",
"dom/targets/textarea.ts",
"dom/targets/contentEditable.ts",
"dom/targets/designIFrame.ts",
"dom/targets/touchAlias.ts",
],
"references": [
{ "path": "../../common/core/web/keyboard-processor/src" },
{ "path": "../../resources/web-environment" },
{ "path": "../../common/core/web/utils" },
{ "path": "../../common/web/lm-message-types" }
]
}

View file

@ -1,5 +1,3 @@
/// <reference path="../../node_modules/@keymanapp/recorder-core/src/index.ts" />
namespace KMWRecorder {
export class BrowserDriver {
static readonly physicalEventClass: string = "KeyboardEvent";
@ -44,7 +42,7 @@ namespace KMWRecorder {
event = document.createEvent(BrowserDriver.physicalEventClass);
// An override to ensure that IE's method gets called.
// Many thanks to https://gist.github.com/termi/4654819, line 142 at the time of writing this.
var success = (<any>event).initKeyboardEvent(BrowserDriver.physicalEventType, false, true, null, eventSpec.key, /*this.code,*/ eventSpec.location,
var success = (<any>event).initKeyboardEvent(BrowserDriver.physicalEventType, false, true, null, eventSpec.key, /*this.code,*/ eventSpec.location,
eventSpec.generateModifierString(), 0, 0);
}

View file

@ -1,5 +1,5 @@
#! /bin/bash
#
#
# Compiles development-related KeymanWeb resources for use with developing/running tests.
# - the Recorder module (for engine tests)
# - the DOM module (for touch-alias and element-interface tests)
@ -35,7 +35,7 @@ popd
compiler="npm run tsc --"
compilecmd="$compiler"
$compilecmd -p "$SCRIPT_DIR/tsconfig.json"
$compilecmd --build "$SCRIPT_DIR/tsconfig.json"
if [ $? -ne 0 ]; then
fail "KeymanWeb test sequence recorder compilation failed."
fi

View file

@ -1,22 +1,20 @@
/// <reference path="../../node_modules/@keymanapp/recorder-core/src/index.ts" />
/// <reference path="../../node_modules/eventemitter3/index.js" />
//Since TS won't recognize the types b/c no "import"/"require" statements.
// A small-scale manual definition.
declare class EventEmitter {
/** Add a listener for a given event */
on(event: string, func: (...args: any[]) => boolean, context?: any);
/** Add a one-time listener for a given event */
once(event: string, func: (...args: any[]) => boolean, context?: any);
removeListener(event: string, func: (...args: any[]) => boolean, context?: any, once?: boolean);
// declare class EventEmitter {
// /** Add a listener for a given event */
// on(event: string, func: (...args: any[]) => boolean, context?: any);
// /** Add a one-time listener for a given event */
// once(event: string, func: (...args: any[]) => boolean, context?: any);
// removeListener(event: string, func: (...args: any[]) => boolean, context?: any, once?: boolean);
// Defines their alternately-themed aliases.
addListener: typeof EventEmitter.prototype.on;
off: typeof EventEmitter.prototype.removeListener;
// // Defines their alternately-themed aliases.
// addListener: typeof EventEmitter.prototype.on;
// off: typeof EventEmitter.prototype.removeListener;
// Defines the actual event-raising function.
emit(eventName: string, ...args: any[]);
}
// // Defines the actual event-raising function.
// emit(eventName: string, ...args: any[]);
// }
// Makes sure the code below knows that the namespaces exist.
namespace com.keyman {
@ -35,8 +33,8 @@ namespace com.keyman {
namespace KMWRecorder {
/**
* Contains browser-dependent code used to transcribe browser-based events
* so that thay may be reconstructed for use in KMW testing.
* Contains browser-dependent code used to transcribe browser-based events
* so that thay may be reconstructed for use in KMW testing.
*/
export class Scribe extends EventEmitter {
//#region Static methods for recording input events
@ -155,7 +153,7 @@ namespace KMWRecorder {
} else {
delete this.currentSequence.msg;
}
this.raiseRecordChanged();
}
@ -196,7 +194,7 @@ namespace KMWRecorder {
window.setTimeout(function() {
recorderScribe.addInputRecord(recording, in_output.getText());
}, 1);
return retVal;
}
@ -244,7 +242,7 @@ namespace KMWRecorder {
recorderScribe.emit('stub-changed', JSON.stringify(kbdRecord));
// var ta_activeStub = document.getElementById('activeStub');
// ta_activeStub.value = JSON.stringify(kbdRecord);
if(!sameKbd && !recorderScribe.keyboardJustActivated) {
recorderScribe.testDefinition = new KMWRecorder.KeyboardTest(kbdRecord);
}

View file

@ -1,16 +1,26 @@
{
"extends": "../../../tsconfig-base.json",
"compilerOptions": {
"allowJs": true,
"inlineSources": true,
"module": "none",
"outFile": "build/recorder_InputEvents.js",
"sourceMap": true,
"target": "es5"
},
"allowJs": true,
"inlineSources": true,
"module": "none",
"outFile": "build/recorder_InputEvents.js",
"sourceMap": true,
"target": "es5"
},
"files": [
"../../node_modules/@keymanapp/web-environment/environment.inc.ts",
"../../node_modules/@keymanapp/web-utils/src/index.ts",
"../../node_modules/@keymanapp/lexical-model-layer/message.d.ts",
"browserProctor.ts"
"browserProctor.ts",
"browserDriver.ts",
"scribe.ts"
],
"references": [
{ "path": "../../../resources/web-environment" },
{ "path": "../../../common/core/web/utils" },
{ "path": "../../../common/core/web/keyboard-processor/src" },
{ "path": "../../../common/core/web/input-processor/src" },
{ "path": "../../../common/core/web/tools/recorder/src" },
{ "path": "../../../common/web/lm-message-types" }
]
}

View file

@ -129,7 +129,7 @@ cd ../tools/recorder
# Run our headless tests first.
# First: Web-core tests.
pushd $WORKING_DIRECTORY/node_modules/@keymanapp/input-processor
pushd "$KEYMAN_ROOT/common/core/web/input-processor"
./test.sh $HEADLESS_FLAGS || fail "Tests failed by dependencies; aborting integration tests."
# Once done, now we run the integrated (KeymanWeb) tests.
popd