test(web/engine): Adds keystroke-sequence unit test

This commit is contained in:
jahorton 2020-03-24 12:37:00 +07:00
parent 44e3bb3364
commit a79b4dfa5e
4 changed files with 116 additions and 1 deletions

View file

@ -5,6 +5,7 @@ function loadKeyboards() {
var preloadFiles = [
filePrefix + "khmer_angkor.json",
filePrefix + "lao_2008_basic.json",
filePrefix + "options_with_save.json",
filePrefix + "test_deadkeys.json",
filePrefix + "test_chirality.json"
];

View file

@ -901,7 +901,29 @@ describe('Engine', function() {
}, kmwconfig.timeouts.scriptLoad);
});
});
})
it("Multiple-sequence check", function(done) {
this.timeout(kmwconfig.timeouts.standard + kmwconfig.timeouts.scriptLoad * 3);
var keyboardID = "options_with_save";
var storeName = "foo";
keyman.setActiveKeyboard(keyboardID, 'en').then(function() {
KeymanWeb.saveStore(storeName, 1);
keyman.removeKeyboards(keyboardID);
var finalCheck = function() {
// Reset the keyboard... again.
keyman.removeKeyboards(keyboardID);
// Second test: expects option to still be "off" b/c cookies.
runKeyboardTestFromJSON('/engine_tests/options_with_save_2.json', {usingOSK: false}, done, assert.equal, kmwconfig.timeouts.scriptLoad);
};
// First test: expects option to be "on" from cookie-init setting, emitting "foo.", then turning option "off".
runKeyboardTestFromJSON('/engine_tests/options_with_save_1.json', {usingOSK: false}, finalCheck, assert.equal, kmwconfig.timeouts.scriptLoad);
});
});
});
// Performs basic processing system checks/tests to ensure the sequence testing
// is based on correct assumptions about the code.

View file

@ -0,0 +1,54 @@
{
"keyboard": {
"id": "options_with_save",
"name": "Variable-store test kbd: options_with_save",
"filename": "resources/keyboards/options_with_save.js",
"languages": [
{
"id": "en",
"name": "English",
"region": "World"
}
]
},
"inputTestSets": [
{
"constraint": {
"target": "hardware",
"validOSList": null,
"validBrowsers": null
},
"testSet": [
{
"inputs": [
{
"type": "key",
"key": "a",
"code": "KeyA",
"keyCode": 65,
"modifierSet": 0,
"location": 0
},
{
"type": "key",
"key": "0",
"code": "Digit0",
"keyCode": 48,
"modifierSet": 0,
"location": 0
},
{
"type": "key",
"key": "2",
"code": "Digit2",
"keyCode": 50,
"modifierSet": 0,
"location": 0
}
],
"output": "foo."
}
]
}
]
}

View file

@ -0,0 +1,38 @@
{
"keyboard": {
"id": "options_with_save",
"name": "Variable-store test kbd: options_with_save",
"filename": "resources/keyboards/options_with_save.js",
"languages": [
{
"id": "en",
"name": "English",
"region": "World"
}
]
},
"inputTestSets": [
{
"constraint": {
"target": "hardware",
"validOSList": null,
"validBrowsers": null
},
"testSet": [
{
"inputs": [
{
"type": "key",
"key": "a",
"code": "KeyA",
"keyCode": 65,
"modifierSet": 0,
"location": 0
}
],
"output": "no foo."
}
]
}
]
}