Changes between Version 5 and Version 6 of Writing Layout Tests to test iOS UI features


Ignore:
Timestamp:
Sep 30, 2015 3:38:31 PM (7 years ago)
Author:
Simon Fraser
Comment:

--

Legend:

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

    v5 v6  
    6666}}}
    6767
    68 The script passed in to runUIScript() is just a string. You can pass a string literal here, or, for longer scripts make script tag and get is context as text:
     68The script passed in to runUIScript() is just a string. You can pass a string literal here, or, for longer scripts make script tag and get its content as text:
    6969{{{
    7070<script id="ui-script" type="text/plain">
     
    9393
    9494Because testRunner.runUIScript() is asynchronous, the caller has to supply a callback function. The string result returned by the UI process script is passed to this callback function as an argument. You can use this to return simple bits of data as strings, or use JSON.stringify() in the UI script, and JSON.parse() in the test script to get more complex objects across the process boundary.
     95
     96= UIScriptController functions =
     97
     98UIScriptController is the mechanism for driving behavior in the UI process, and to accessing UI state. Many of the functions will trigger UI behaviors that take time (e.g. a zoom animation, or bringing up the keyboard). Rather than blocking, these functions take a callback that is triggered in the UI script context when that operation is complete:
     99
     100{{{
     101(function() {
     102    uiController.doubleTapAtPoint(50, 50, function() {
     103        console.log("Taps were dispatched");
     104    });
     105})();
     106}}}
     107
     108Note that this console.log() won't show in layout test output, since it's being generated in the UI process (but it will be logged if you run webkittestrunner directly, which is useful for debugging).
     109
     110However, the web process needs to be told that the UI script is complete, so when your test has finished doing work in the UI process, it should call uiScriptComplete(), passing the result:
     111
     112{{{
     113(function() {
     114    uiController.doubleTapAtPoint(50, 50, function() {
     115        uiController.uiScriptComplete("Taps were dispatched");
     116    });
     117})();
     118}}}
     119
     120