Namespacing

Code that is not shared across multiple targets should live in the global namespace. Code that is shared across multiple targets should live in the cr_fuchsia namespace.

Test code

Under the //fuchsia directory , there are 3 major types of tests:

Unit tests: Exercises a single class in isolation, allowing full control over the external environment of this class.

Browser tests: Spawns a full browser process along child processes. The test code is run inside the browser process, allowing for full access to the browser code, but not other processes.

Integration tests: they exercise the published API of a Fuchsia component. For instance, //fuchsia/engine:web_engine_integration_tests make use of the //fuchsia/engine:web_engine component. The test code is run in a separate process in a separate component, allowing only access to the published API of the component under test.

Integration tests are more resource-intensive than browser tests, which are in turn more expensive than unit tests. Therefore, when writing new tests, it is preferred to write unit tests over browser tests over integration tests.

As a general rule, test-only code should live in the same directory as the code under test with an explicit file name, either fake_*, test_*, *_unittest.cc, *_ browser_test.cc or *_integration_test.cc.

Test code that is shared across components should live in a dedicated test directory, under the cr_fuchsia namespace. For instance, see the //fuchsia/engine/test directory, which contains code shared by all browser tests.

Building and deploying the WebRunner service

When you build web_runner, Chromium will automatically generate scripts for you that will automatically provision a device with Fuchsia and then install web_runner and its dependencies.

To build and run web_runner, follow these steps:

(Optional) Ensure that you have a device ready to boot into Fuchsia.

If you wish to have web_runner manage the OS deployment process, then you should have the device booting into Zedboot.

Build web_runner.

$ autoninja -C out/fuchsia web_runner

Install web_runner.

For devices running Zedboot:

$ out/fuchsia/bin/install_web_runner -d

For devices already booted into Fuchsia:

You will need to add command line flags specifying the device's IP address and the path to the ssh_config used by the device (located at $FUCHSIA_OUT_DIR/ssh-keys/ssh_config):