-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Conversation
…ered from touch tests.
…testable. Problem: touch events.
…s in Chrome emulation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, although it's a fairly big set of changes so I really would like to run some tests on my machine before approval. I am in the middle of some code here so will do testing after you address my comments on the PR.
There are a few minor tweaks and one thing I think is a bug. I didn't spend as long on the recorder code as I did on the KMW base changes.
web/source/build_recorder.sh
Outdated
@@ -0,0 +1,54 @@ | |||
#! /bin/bash | |||
# | |||
# Compile keymanweb and copy compiled javascript and resources to output/embedded folder |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment may not be correct?
web/source/kmwRecorder.html
Outdated
|
||
<!-- Initialization: set paths to keyboards, resources and fonts as required --> | ||
<script> | ||
var kmw = window.keyman; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The kmw
variable is probably overkill now. I'd prefer to see use just using keyman.
-- it's short enough and more self-documenting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good old holdovers from the old 'uncompiled' sample page. Will clean up.
web/source/kmwRecorder.html
Outdated
</td> | ||
<td style="width:50%"> | ||
<p style="font-weight: bold;">Valid OS:</p> | ||
<nobr><input type="checkbox" id="platform_any" checked onclick="clearPlatforms();">Any</nobr> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor improvment: Replacing the text Any
with <label for='platform_any'>Any</label>
means the user can click on the text as on the checkbox itself.
web/source/kmwosk.ts
Outdated
if(keyName == 'K_LOPT' || keyName == 'K_ROPT') { | ||
osk.optionKey(e,keyName,true); | ||
return true; | ||
} else if(keyName == 'K_BKSP') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work with keyboards that override the default backspace behaviour (e.g. Khmer Angkor with Coeng markers and subconsonants)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... thanks for bringing this up. I remember seeing a branch for K_BKSP there before and modified it to match the old behavior, but it's not in master. Not sure how that happened, but it's not a direct correlation to the code that's there now, at the very least. I'll look into it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future records: what I saw was on the touch handler, which originally bypassed this method entirely. Which was a bug, but adding the 'K_BKSP'
check here was also a bug, since there was code later in the method that could be relied upon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, it's because it was in touch but the recorder needs clickKey.
But the implementation in touch was a bug, as we realized after a little discussion.
web/source/kmwutils.ts
Outdated
|
||
return 999; | ||
getIEVersion() { | ||
Device._GetIEVersion(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return the result from Device._GetIEVersion()
shouldn't it?
@@ -31,11 +31,11 @@ Modernizr.on('touchevents', function(result) { | |||
describe('Basic Toggle UI', function() { | |||
|
|||
beforeEach(function(done) { | |||
this.timeout(10000); | |||
this.timeout(20000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because the tests are taking longer than 10 seconds to run? It feels a little arbitrary. Is it network or environment dependent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's network dependent. When the tests are run, they're hosted on the local machine, not on BrowserStack servers; a 'tunnel' of sorts is set up that allows the local machine to act as 'localhost' to their remote machines.
Therefore, the quality of net connection affects the needed timeouts... and our connection here locally isn't always the greatest, so periodically the tests fail when the connection acts up.
Some of the recent script changes in test_utils.js do their best to minimize the impact of this, as even initialization tests are far more able to recognize when they've successfully finished all their work, even when it's dependent on script loading, etc.
Possible enhancements to be desired:
fail()
signal, of course) that collects all errors for aKeyboardTest
instead of instantly failing on the first mismatched sequence when running the tests.This PR serves to introduce and facilitate automated testing of the core KMW keystroke/input processing system, providing two modules toward this end:
Engine Tester
The new file
engine.js
in the test case section implements the automated testing functionality, first running a few basic tests to ensure individual keystroke and keyboard loading correctness. The real meat is toward the end of the file, demonstrating how to automate an input test sequence through KMW.The existing test isn't terribly extensive, but serves as a proof-of-concept we can expand upon greatly in order to address various keyboard issues into the future.
Engine Recorder
To facilitate development of engine-related test cases, I've developed a few scripts and a web page designed to record KMW input on any device and generate corresponding JSON consumable by the Engine Tester. It'll take a bit of copy-paste and external file management, but the page takes care of writing the tedious aspects of the JSON content needed for any test. Heck, it can even load saved JSON and extend its data; the main issue is that JavaScript is typically blocked from saving anything to the user's filesystem.
Accordingly, the file structure of the testing area has expanded again, with a section devoted to JSON file content that can be preloaded by the Karma system for each webpage (hence targeting the JSON format for engine test specs).
Furthermore, a few changes to the OSK module of KMW were necessary in order to properly integrate the engine tester and the engine recorder - each had separate issues. Also, the
Device
object's definition was refactored out ofkmwutils.js
into its own file, allowing KMW's device-detection code to be utilized by the recorder.