Add the ability to generate multiple test cases
Summary: Modify test generation script to be able to generate multiple test cases Reviewed By: lucasr Differential Revision: D3714577 fbshipit-source-id: d2bc2155712f946c5a24231a9532d2acc097524c
This commit is contained in:
committed by
Facebook Github Bot 6
parent
f68521aa69
commit
c373056d80
@@ -111,7 +111,7 @@ Instead of manually writing a test which ensures parity with web implementations
|
|||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
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
|
||||||
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.
|
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.
|
||||||
|
@@ -8,10 +8,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
window.onload = function() {
|
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 = [
|
var lines = [
|
||||||
'/**',
|
'/**',
|
||||||
' * Copyright (c) 2014-present, Facebook, Inc.',
|
' * Copyright (c) 2014-present, Facebook, Inc.',
|
||||||
@@ -26,22 +26,25 @@ function printTest(testName, layoutTree) {
|
|||||||
'#include <CSSLayoutTestUtils/CSSLayoutTestUtils.h>',
|
'#include <CSSLayoutTestUtils/CSSLayoutTestUtils.h>',
|
||||||
'#include <gtest/gtest.h>',
|
'#include <gtest/gtest.h>',
|
||||||
'',
|
'',
|
||||||
'TEST(CSSLayoutTest, ' + testName + ') {',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
lines.push(' ' + setupTestTree(layoutTree[0], 'root', null).reduce(function(curr, prev) {
|
for (var i = 0; i < layoutTree.length - 1; i++) {
|
||||||
|
lines.push('TEST(CSSLayoutTest, INSERT_NAME_HERE) {');
|
||||||
|
|
||||||
|
lines.push(' ' + setupTestTree(layoutTree[i], 'root', null).reduce(function(curr, prev) {
|
||||||
return curr + '\n ' + prev;
|
return curr + '\n ' + prev;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
lines.push(' CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);');
|
lines.push(' CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);');
|
||||||
lines.push('');
|
lines.push('');
|
||||||
|
|
||||||
lines.push(' ' + assertTestTree(layoutTree[0], 'root', null).reduce(function(curr, prev) {
|
lines.push(' ' + assertTestTree(layoutTree[i], 'root', null).reduce(function(curr, prev) {
|
||||||
return curr + '\n ' + prev;
|
return curr + '\n ' + prev;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
lines.push('}');
|
lines.push('}');
|
||||||
lines.push('');
|
lines.push('');
|
||||||
|
}
|
||||||
|
|
||||||
printLines(lines);
|
printLines(lines);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user