Changes between Initial Version and Version 1 of Writing Layout Tests for DumpRenderTree


Ignore:
Timestamp:
Nov 12, 2006 8:45:42 AM (16 years ago)
Author:
mitz@webkit.org
Comment:

Copied from Google cache of wiki.opendarwin.org with minimal modifications and reformatting. People who contributed to this page include Eric Seidel and Geoff Garen.

Legend:

Unmodified
Added
Removed
Modified
  • Writing Layout Tests for DumpRenderTree

    v1 v1  
     1[[PageOutline]]
     2= Writing good test cases =
     3
     4''Should have some tips here about how to make a test which is easy to know when it succeeds, things like a 100x100 green block, just printing SUCCESS or FAILURE, and using `dumpAsText()`.''
     5
     6''Should remind folks to write tests that work both in Safari and in DRT. The trick is to test for the existence of a special object like layoutTestController before using it. An example:''
     7{{{
     8if (window.layoutTestController)
     9    layoutTestController.dumpAsText()
     10}}}
     11
     12= DumpRenderTree JavaScript Environment =
     13
     14DumpRenderTree exposes a number of additional JavaScript objects in the testing environment.
     15
     16These can be used to perform additional debugging-related tasks.
     17
     18== `window.layoutTestController` ==
     19
     20=== `dumpAsText()` ===
     21
     22Call this method to make your test output plain text instead of a render tree. This is useful if your test prints messages rather than testing fancy layout. For an example of how to print to a console in a test, check out `LayoutTests/fast/dom/ Element/attribute-uppercase.html`.
     23
     24=== `waitUntilDone()` and `notifyDone()` ===
     25
     26By default, DumpRenderTree dumps each test file immediately after the document has loaded and the load event handlers have executed. If your test needs to do further processing after loading -- for example, waiting for a timer to fire -- call `layoutTestController.waitUntilDone()` to tell DumpRenderTree to delay its dump, and then call `notifyDone` when your results are ready.
     27
     28== `window.eventSender` ==
     29
     30=== `mouseMoveTo(x, y)` ===
     31
     32Used to change the current mouse position.
     33
     34=== `leapForward(ms)` ===
     35
     36Jumps the current event time forward by a specified number of miliseconds.
     37
     38=== `mouseDown()` ===
     39
     40Sends a mouseDown event to the WebView at the current mouse position.
     41
     42=== `mouseUp()` ===
     43
     44Sends a mouseUp event to the WebView at the current mouse position.
     45
     46=== `mouseClick()` ===
     47
     48Call `mouseClick` only if you need to simulate a click in a platform widget. Otherwise, use `mouseDown` and `mouseUp`.
     49
     50== `window.textInputController` ==
     51
     52''Needs to be filled in.''
     53
     54=== `insertText` ===
     55
     56=== `doCommand` ===
     57
     58=== `setMarkedText` ===
     59
     60=== `substringFromRange` ===
     61
     62=== `attributedSubstringFromRange` ===
     63
     64=== `firstRectForCharacterRange` ===
     65
     66=== `characterIndexForPoint` ===
     67
     68=== `makeAttributedString` ===
     69
     70== `window.appleScriptController` ==
     71
     72=== `doJavaScript()` ===
     73
     74''Needs to be filled in.''
     75
     76== `window.navigationController` ==
     77
     78'''The navigation controller is currently broken.''' ''Need to add a bug number.''
     79
     80=== `evalAfterBackForwardNavigation(script [, destination])` ===
     81
     82To test a bug having to do with the loader or the back/forward cache, call this method to run a script after executing a back/forward navigation. The first argument is the script to run, and the second argument is the page to load during the navigation. The second argument is optional. It defaults to `about:blank`.
     83
     84= Writing tests which require network access =
     85
     86`run-webkit-tests` (the script which runs DumpRenderTree) also launches a local Apache daemon (`httpd`) to allow real local-only network based testing (for incremental loads, XMLHttpRequest, etc.) ap needs to document how best to use this.