mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-24 00:27:40 +00:00
test(web/engine): Adds keystroke-sequence unit test
This commit is contained in:
parent
44e3bb3364
commit
a79b4dfa5e
4 changed files with 116 additions and 1 deletions
|
|
@ -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"
|
||||
];
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
54
web/unit_tests/json/engine_tests/options_with_save_1.json
Normal file
54
web/unit_tests/json/engine_tests/options_with_save_1.json
Normal 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."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
38
web/unit_tests/json/engine_tests/options_with_save_2.json
Normal file
38
web/unit_tests/json/engine_tests/options_with_save_2.json
Normal 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."
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue