Yoga tries to be as close as possible to chrome in its flexbox behaviour. To ensure this most of Yoga's test suite is automatically generateded from running the corresponding layout in chrome using a webdriver which then generates C++ test which asserts that Yoga will produce matching outputs for that layout.
git submodule init
followed by git submodule update
.buck test //:yoga
.Instead of manually writing a test which ensures parity with web implementations
of Flexbox we make use of a generated test suite. We use gentest/gentest.rb
to
generate this test suite. Write the html which you want to verify in Yoga and put
it in the gentest/fixtures
folder, such as the following.
<div id="my_test" style="width: 100px; height: 100px; align-items: center;">
<div style="width: 50px; height: 50px;"></div>
</div>
Run gentest/gentest.rb
to generate test code and re-run buck test //:yoga
to validate the behavior. One test case will be generated for every root div
in the input html with the string in the id
corresponding to the test name.
You should run bundle install
in the gentest
directory to install dependencies for the gentest/gentest.rb
Ruby script.
For some aspects of Yoga we cannot generate a test using the test generation
infrastructure described earlier. For these cases we manually write a test in
the /tests
directory.