Changes between Version 26 and Version 27 of Writing Layout Tests for DumpRenderTree

Oct 27, 2011 5:06:22 PM (12 years ago)

How to write good test case (edit 2), pixel tests


  • Writing Layout Tests for DumpRenderTree

    v26 v27  
    142142=== How to write portable pixel tests ===
    144  * Do not use fonts other than those bundled with Mac OS X (usually there's no need to specify font families in a test). The only exception to this is the ''Ahem'' font.
     144The problem with a pixel dump is that it '''can be''' highly depend on the platform on which you run it. To be avoided to have more portable tests cases are the following:
     145 * fonts
     146 * native controls
     148==== Fonts ====
     150Fonts are very dependent on the platform and the source of a lot of differences in our tests. That's because not all platform share the same fonts and in this case, the fallback mechanism is pretty much defined per machine as it depends on the OS and the available fonts!
     152The golden rule is that '''if you can avoid text, you should'''.
     154This seems against the previous section about writing understandable test cases and it is. However there are a couple of ways to put the information you need while keeping the portability of the no-text mantra:
     156  * put your information as comments into the HTML
     157  * put your text outside of the dumped area: by default DumpRenderTree dumps a viewport of 600 * 800 pixels (FIXME: not 100% sure about those numbers). This means that anything outside this range would not be dumped in DRT but will appear in a browser opening the test.
     158  * add a 0 opacity to your text.
     160'''Important note:''' For the 2 last points, the text will still be on the text render tree dump!
     162If you test '''really needs to use some fonts''', make sure you use the ''Ahem'' font as it is a very portable font. Make sure to specify the font-height too not to depend on the platform (FIXME: not sure if this is really needed but better safe than sorry).
     164==== Native controls ====
     166Native controls cover anything that is painted by the OS. In WebKit, this means buttons, scroll bars, media players, ...
     168You can use the previous tips for text here to hide your button if you don't need.
     170For scroll bars, you just have to use the following rule in your CSS to disable them:
     173overflow: hidden;
    148176= Writing JavaScript-based DOM-only Test Cases =