Changes between Version 9 and Version 10 of Writing Layout Tests to test iOS UI features


Ignore:
Timestamp:
Oct 1, 2015 1:24:05 PM (9 years ago)
Author:
Wenson Hsieh
Comment:

Added documentation on key event testing to UIScriptController wiki page

Legend:

Unmodified
Added
Removed
Modified
  • Writing Layout Tests to test iOS UI features

    v9 v10  
    130130}}}
    131131
    132 If your UI-side script is very simple and only accesses uiController properties, then it doesn't need to call uiScriptComplete(). If you call any uiController functions that are asynchronous (i.e. take a callback), then you need to call uiScriptComplete() at some point.
     132UIScriptController also supports sending key events. However, the keyboard must first be shown for the key events to be properly handled. First, your UI-side script must perform some action that will cause the keyboard to be shown. Your script must then bind uiController.didShowKeyboardCallback to a function which is invoked after the keyboard is shown and is ready to accept key inputs. This callback should call one of the typeCharacter methods (currently, there is only typeCharacterUsingHardwareKeyboard, but we intend on supporting software key events as well). In the below example, suppose that tapping at (50, 25) touches an input element.
     133
     134{{{
     135(function() {
     136    uiController.singleTapAtPoint(50, 25, function() { });
     137    uiController.didShowKeyboardCallback = function() {
     138        uiController.typeCharacterUsingHardwareKeyboard("a", function() { });
     139    }
     140})();
     141}}}
     142
     143Observe that we didn't call uiController.uiScriptComplete. This is because when the key event is handled by the UI process, there is no guarantee that the web process has received the resulting editing event, so the value of the element may not be updated. Instead of waiting on the UI-side script to complete, we can instead invoke testRunner.notifyDone when the element itself has received an oninput event.
     144
     145If your UI-side script is very simple and only accesses uiController properties, then it doesn't need to call uiScriptComplete(). If you call any uiController functions that are asynchronous (i.e. take a callback), then you need to call uiScriptComplete() at some point unless you are waiting to invoke testRunner.notifyDone from the web process.
    133146
    134147You can chain as many asynchronous things as you like in the UI-side script, as long as you call uiScriptComplete() when the chain is complete. You can also call testRunner.runUIScript() as many times as you like from the test content, making it possible to test a long sequence of operations that bounce between the UI process and the web process.
     
    136149= Future enhancements =
    137150
    138 UIScriptController will grow to allow tests to drive more behaviors in the UI process, for things like the keyboard, key events, selection, callouts etc.. We will also likely add ways to read back UI process state, like the state of the selection handles and callout bars.
     151UIScriptController will grow to allow tests to drive more behaviors in the UI process, for things like the software keyboard events, selection, callouts etc.. We will also likely add ways to read back UI process state, like the state of the selection handles and callout bars.
    139152
    140153= Non-iOS platforms =