In-depth analysis of WebKit layout tests

Source: Internet
Author: User

Reprinted please indicate the source: http://blog.csdn.net/horkychen

There is no special organization to share the knowledge points in the PPT sorting process.

 

Layout test main process:

Run the following command:

Run-WebKit-Tests [Option]
Test script file or directory
The main parameters are:

-- Verbose displays detailed information

-- No-build do not try to recompile dumprendertree

-- Debug uses the debug version for testing

-- Help: display all options

0. Test Method Induction

I. static testing (the test result is determined by comparing the final webpage output .)

Four detection methods:

Render tree, body text, pixel data, ref Test

(Body text has no format information, while pixel data does not have text information. Therefore, the two are used in combination, mainly body text .)

Ref test is compared in the form of HTML pages.Unmatched results are stored as images.

Ii. Dynamic Testing (the test results are dynamically determined during execution. But still output to the webpage,It is reported through static testing .)

The dynamic testing method is the same as static testing.The difference is that the comparison content is already the test result.That is, the Javascript script has root test conditions and data,The test is successful or fails. Then, the static test mechanism outputs the results.

Composition of test cases:

A. html files used for testing (must be in the layouttests directory)

Export testname).html

B. Baseline)

. Export testnameapps-expected.txt-> body text

. Export testnameapps-expected.png-> pixel Test

. Export testnameapps-expected.html-> ref Test

. {Testname}-expected-mismatch.HTML-> ref Test

C. Description

.MissmatchType test onlyRef TestSupported

. Ref TestIs exclusive, if the currentCaseYesRef test,No other content will be detected.

* For audio comparison, the content in the script is not analyzed.

* During the first test, there was no comparison standard,Layouttest automatically generates XXX-expected.Txt or xxxx-expected.png.

* All tested webpages must be placed in the layouttests directory.

1. Do not output a date or time in the webpage.

(Dynamic content cannot be compared)

2. The entire test case running time cannot exceed 30 s. For details, see another article.

3. js-test-re.js (used with js-test-post.js) defines several result validation functions, such as shouldbetrue.

For example:

<SCRIPT src = "../fast/JS/resources/JS-Test-pre.js> </SCRIPT>

...

<SCRIPT>

Totalcount = 5;

Shouldbetrue ("totalcount = 3 ");

</SCRIPT>

...

<SCRIPT src = "../fast/JS/resources/JS-Test-post.js> </SCRIPT>

Running result:

Fail totalcount = 3 shocould be true. was false.

Other functions: shouldbe,Shouldbecloseto, shouldnotbe,Shouldbefalse, sholdbenan,Shouldbenull, shouldbezero,

Shouldbedomaintostring,Shouldbeemptystring,Shouldbedefined,Shouldbeundefined, shouldthrow...

Detailed content allows you to view the js-test-pre.js script.

4. layouttests/canvas/tests/23.Canvas.reference.html

...

<Canvas id = "C" Class = "output" width = "100" Height = "50"> <P class = "fallback"> fail (fallback content) </P> </canvas>

<Ul id = "D"> </ul>

<SCRIPT>

_ Addtest(Function (canvas, CTX ){

_ Assertsame (CTX. Canvas, canvas, "CTX. canvas", "canvas ");

});

</SCRIPT>

_ Assertsame is defined in layouttests/Canvas/test. js.

All canvas 2D tests use the same ID to facilitate test script execution.

Working Method (implementation in test. JS ):

If the test succeeds, a pass is output on the webpage; otherwise, an error message is output. In this way, the comparison result is achieved.

Another function: _ assertpixel (2d.clearrect.nonfinite.html)

_ Assertpixel (canvas, 50, 25, 0,255, 0,255, "50, 25", "0,255, 0,255 ");

Function Definition:

_ Assertpixel (canvas, X, Y, R, G, B, A, POs, color)

POs and colors are two strings representing coordinates and colors.Not used in the function.

POs: "X, Y"

Color: "R, G, B,"

Function list:

_ Assert

_ Assertsame (===)

_ Assertdifferent (! =)

_ Assertequal (=)

_ Assertmatch (MATCH) Regular Expression match

_ Assertpixel

_ Assertpixelapprox <-a slight color deviation is allowed.

_ Requiremanualcheck: data cannot be obtained due to some reasons and may need to be manually checked and confirmed.

5. For pixel test, except that the dumpastext () parameter is set to true, you must specify --Pixel parameters. Expected images are stored in PNG.PNG files are saved to the corresponding platform directory.

A. the captured image is only available in the visible area.

B. do not involve text content because of font rendering.

C. Because native control is drawn by the system, there are differences between different systems.

Refer to the WebKit article.

6. overridepreference (Key, value)

It is used to dynamically modify the preference value in the script.Available keys:

Webkitenablecaretbrowsing

Webkituseprehtml5parserquirks

* For More definitions, see webpreferencesprivate. h.

7. layouttest font problems in Windows

Reference: http://trac.webkit.org/Wiki/buildingonwindows(Font-metric-related failures)

 

8. Complete testcontroller method list:

Compare the Code with layouttestcontroller.Layouttestcontroller in CPP ::Staticfunctions () Definition

9. Default webpage View Size (dumprendertree)

W3C SVG test: 480X360

Other tests: 800x600

* Defined in layouttestcontroller. cpp:2563 lines, in the sizewebviewforcurrenttest Function.

All are constant definitions, and no parameters can be modified.

10. built-in Dom test cases. Use selfhtml. js and JS files with the same name as HTML.

Selfhtml. js provides the test entry functions starttest and nine assert operation for use: assertsize, assertequalscollectionautocase...

XXXX.JS provides runtest implementation for starttest to call.

Starttest:

A. waituntildone

B. runtest

C. policydone

11. golden rule:

A. For pixel test, try not to involve text.

B. do not involve dynamic content, such as time and date.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.