diff --git a/README.md b/README.md index 70436631..9c2bf2d1 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ Instead of manually writing a test which ensures parity with web implementations ``` -Once saving and exiting the editor window the script will open a browser window. From here open the developer console and you should see that the web page has output a test file. Copy this into a file and save it in the `tests` folder. Re-run `buck test //:CSSLayout` to validate the behavior. +Once saving and exiting the editor window the script will open a browser window. From here open the developer console and you should see that the web page has output a test file. Copy this into a file and save it in the `tests` folder. Re-run `buck test //:CSSLayout` to validate the behavior. One test case will be generated for every root `div` in the input html. ### Benchmarks Benchmarks are located in `benchmarks/CSSBenchmark.c` and can be run with `buck run //:benchmark`. If you think your change has affected performance please run this before and after your change to validate that nothing has regressed. diff --git a/gentest/gentest.js b/gentest/gentest.js index b32e0de6..198dcbb2 100755 --- a/gentest/gentest.js +++ b/gentest/gentest.js @@ -8,10 +8,10 @@ */ window.onload = function() { - printTest("INSERT_NAME_HERE", calculateTree(document.body.children[0])); + printTest(calculateTree(document.body.children[0])); } -function printTest(testName, layoutTree) { +function printTest(layoutTree) { var lines = [ '/**', ' * Copyright (c) 2014-present, Facebook, Inc.', @@ -26,22 +26,25 @@ function printTest(testName, layoutTree) { '#include ', '#include ', '', - 'TEST(CSSLayoutTest, ' + testName + ') {', ]; - lines.push(' ' + setupTestTree(layoutTree[0], 'root', null).reduce(function(curr, prev) { - return curr + '\n ' + prev; - })); + for (var i = 0; i < layoutTree.length - 1; i++) { + lines.push('TEST(CSSLayoutTest, INSERT_NAME_HERE) {'); - lines.push(' CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);'); - lines.push(''); + lines.push(' ' + setupTestTree(layoutTree[i], 'root', null).reduce(function(curr, prev) { + return curr + '\n ' + prev; + })); - lines.push(' ' + assertTestTree(layoutTree[0], 'root', null).reduce(function(curr, prev) { - return curr + '\n ' + prev; - })); + lines.push(' CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);'); + lines.push(''); - lines.push('}'); - lines.push(''); + lines.push(' ' + assertTestTree(layoutTree[i], 'root', null).reduce(function(curr, prev) { + return curr + '\n ' + prev; + })); + + lines.push('}'); + lines.push(''); + } printLines(lines); }