220 Commits

Author SHA1 Message Date
Kazuki Sakamoto
dc5e613285 gentest for Java and C#
Summary:
- Revise scripts to generate Java and C# unittests using the same HTML fixtures as well as C for code coverage.
- Add wrap_column test workaround in gentest.js.
- Add checkDefaultValues for sanity check of the CSSLayout default values by test-template.html
- Add `align-content: flex-start;` in default div to align with CSSLayout default

    $ cd csharp/gentest
    $ ruby gentest.rb

- macOS example for C#

    $ cd csharp/tests/Facebook.CSSLayout
    $ clang -DCSS_ASSERT_FAIL_ENABLED -Wall -Wextra -dynamiclib -o libCSSLayout.dylib -g -I../../.. ../../../CSSLayout/*.c ../../CSSLayout/CSSInterop.cpp
    $ mcs -debug -t:library -r:nunit.framework.dll -out:CSSLayoutTest.dll *.cs ../../../csharp/Facebook.CSSLayout/*cs
    $ mono64 --debug nunit-console.exe CSSLayoutTest.dll

Reviewed By: emilsjolander

Differential Revision: D4053777

fbshipit-source-id: 84450208015e65baf604987bd56c6a268598b545
2016-10-23 10:37:39 -07:00
Emil Sjolander
501ed57784 Only look at computed style if key was not set inline
Summary: Prefer inline style to computed style as inline style should be the source of truth and computed style may differ

Reviewed By: gkassabli

Differential Revision: D4029373

fbshipit-source-id: 39ce9d577f295c2361dc384212d7467418c63c33
2016-10-17 06:37:45 -07:00
Emil Sjolander
1f300a58fb Free memory used in tests to enable use of valgrind
Summary: Its very usefull to be able to run valgrind on the tests and benchmarks. We were previously not freeing test memory so valgrind output was very messy.

Reviewed By: javache

Differential Revision: D3937493

fbshipit-source-id: 23c6970d7769b081575d39de583ba954fc65a397
2016-09-29 04:22:47 -07:00
Emil Sjolander
6b16dc4060 Fix flex-end/flex-start RTL transpilation
Summary: Oops, when regexing start->left/right end->left/right I did not take into account flex-start and flex-end. Easiest solution is to regex back flex-left and flex-right into their correct values.

Reviewed By: lucasr

Differential Revision: D3930244

fbshipit-source-id: 20742cbc8e5f23af694e14584c7c3df89526876e
2016-09-27 08:52:44 -07:00
Emil Sjolander
21a05417cd Generate RTL version of tests
Summary: Generate RTL versions of css-layout tests

Reviewed By: lucasr

Differential Revision: D3863081

fbshipit-source-id: df4debb3c1e371425d7c297f8d013b8042ad1e0e
2016-09-14 08:52:44 -07:00
Emil Sjolander
8fcb265830 Make generated test input more copy pastable
Summary: previously when copying in a test inout into an editor the user of gentest needed to remove the ` * ` prefix. This was annoying so this diff fixes that by removing that from gentest.

Reviewed By: lucasr

Differential Revision: D3862943

fbshipit-source-id: 06bd3ee3fa3f85cc44b6ea1d67cf3e91ed368791
2016-09-14 08:52:44 -07:00
Emil Sjolander
059384f277 Improve formatting of generated test code input
Summary: Make input html easier to read by indenting it and adding a space between children. The code to do this could very well be improved but it works for the current set of inputs.

Reviewed By: lucasr

Differential Revision: D3798087

fbshipit-source-id: 0d50ff276000f14ed078cf5ce2e7560ace285a6a
2016-08-31 11:22:42 -07:00
Emil Sjolander
d9191431ff Generate test for border (and fix gentest to include border offset)
Summary: Generate tests for border. This required modifying gentest to add the parent clientLeft and clientTop so that border width are accounted for in output.

Reviewed By: lucasr

Differential Revision: D3791286

fbshipit-source-id: 698cc2332a3f4118e1afdfbfd745ba824e8ec3f4
2016-08-31 08:07:59 -07:00
Emil Sjolander
284634c880 Remove unnecesarry imports for tests
Summary: Minimal imports

Reviewed By: lucasr

Differential Revision: D3790919

fbshipit-source-id: 496078d8132252307ef2b3cb45472917a19d7750
2016-08-31 06:22:46 -07:00
Emil Sjolander
e3fa40e694 Allow specifying the test name in the input to gentest
Summary: Allow adding test name within html through the id of the root element. This makes it much easier to re-generate test files.

Differential Revision: D3771966

fbshipit-source-id: 313e1648dcf4521e7c649f54c4ced2aa3297bf06
2016-08-26 10:38:01 -07:00
Emil Sjolander
1fd3a16116 Fix naming of some style props in gentest
Summary: These props were never tested so I didn't notice the typo until now.

Differential Revision: D3771132

fbshipit-source-id: 9d7c2037195f29b3cac5d21599035edf3b7830ff
2016-08-25 15:38:14 -07:00
Emil Sjolander
aa70125f6c Generate tests for absolute layout
Summary: generate absolute layout tests. Also make sure default value for position is relative (#default div is absolutely positioned)

Reviewed By: IanChilds

Differential Revision: D3770947

fbshipit-source-id: 0327b071c0dc1aa4574ded759dcc667768b28f55
2016-08-25 15:38:14 -07:00
Emil Sjolander
f65febb1af Remove certain computed values from output style
Summary: Remove output properties from computed styles as they will be computed to their output values before we can read them. Only include them if they are explicitly set by the user.

Reviewed By: IanChilds

Differential Revision: D3770917

fbshipit-source-id: e55996cf8744073496debea19c36a188d2e5086c
2016-08-25 15:38:14 -07:00
Emil Sjolander
ccbfee3841 Ensure multiple test cases all have the same origin
Summary: Make the test cases absolute to ensure left/top are both zero for each layout in the test case.

Reviewed By: IanChilds

Differential Revision: D3770913

fbshipit-source-id: c3085c2f8709b52fde0af7f47e1417252997b610
2016-08-25 15:38:14 -07:00
Emil Sjolander
9eb75e27cc Update gentest to new api
Summary: Update gentest to handle new CSSEdge api

Reviewed By: IanChilds

Differential Revision: D3770906

fbshipit-source-id: 1fa978354209fb8f4d0c5a2f892e1c79b062d4de
2016-08-25 15:38:14 -07:00
Emil Sjolander
ca72b2b796 Use const where possible
Summary: Use const where possible. This does not use const for all variables as that would require too much refactoring for one diff. It does however use const where currently possible as well as does some small refactoring to enable const usage in more locations. Striving for 100% const usage leads to code with is easier to reason about as a reference will always reference the same value. The compiler will also assist if you accidentally override a reference.

Reviewed By: IanChilds

Differential Revision: D3741999

fbshipit-source-id: 1ba7da5784c3047f2d4c03746890192f724aa65e
2016-08-22 07:07:41 -07:00
Emil Sjolander
28bc42a988 Add generation script header to generated tests
Summary: Add header to generated code so that code can easily be re-generated in case test generation is improved in the future.

Reviewed By: lucasr

Differential Revision: D3715181

fbshipit-source-id: 593baa691c2d7c7f171c6673898fb8a2ecf0e008
2016-08-15 09:23:28 -07:00
Emil Sjolander
c373056d80 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
2016-08-15 09:23:28 -07:00
Emil Sjolander
f68521aa69 Add support for flex-grow, flex-shrink, and flex-basis
Summary: Add support for flex-grow, flex-shrink, and flex-basis properties. The flex property behavior is preserved for backwards compatibility.

Reviewed By: lucasr

Differential Revision: D3714520

fbshipit-source-id: 80d3a9a1e2b6f74b863bbe22357f2c9865fa290e
2016-08-15 09:23:28 -07:00
Emil Sjolander
a43b813517 Add test generation scripts
Summary:
Add first version of test generation script. Currently works for most layouts and styles. Probably has a bunch of broken edge-case.

Usage:
$ gentest/gentest.sh
<Enter HTML with inline styles> e.g. <div style="width: 100px; height: 100px;"></div>
Open chrome dev tools console tab.
Copy code from console into file and save.
Run buck test //:CSSLayout

Differential Revision: D3697812

fbshipit-source-id: e6809f95bf6782e7e2cc47b9cdd3a25a13163c5c
2016-08-11 11:52:44 -07:00