| OLD | NEW |
| 1 Hacking on Sky | 1 Hacking on Sky |
| 2 ============== | 2 ============== |
| 3 | 3 |
| 4 Building | 4 Building |
| 5 -------- | 5 -------- |
| 6 | 6 |
| 7 * Follow the setup & build instructions for [Mojo](https://github.com/domokit/mo
jo) | 7 * Follow the setup & build instructions for [Mojo](https://github.com/domokit/mo
jo) |
| 8 | 8 |
| 9 The build directory will be `out/Debug` for Linux debug builds, and |
| 10 `out/Release` for Linux release builds. For Android builds, prefix |
| 11 `android_`, as in, `android_Debug`. |
| 12 |
| 9 Running applications | 13 Running applications |
| 10 -------------------- | 14 -------------------- |
| 11 | 15 |
| 12 * ``./mojo/tools/mojodb start out/Debug [url]`` | 16 To run an application on your device, run: |
| 13 | 17 |
| 14 `mojodb` has numerous commands, visible via `mojodb help`. Common ones incl
ude: | 18 * ``./mojo/tools/mojodb start out/android_Debug [url]`` |
| 15 * `mojodb start` BUILD_DIR [url] | 19 |
| 16 * `mojodb load` [url] | 20 `mojodb` has numerous commands, visible via `mojodb help`. Common ones include: |
| 17 * `mojodb stop` | 21 * `mojodb start` BUILD_DIR [url] |
| 18 * `mojodb start_tracing` # Starts recoding a performance trace (use stop_tra
cing to stop) | 22 * `mojodb load` [url] |
| 19 * `mojodb print_crash` # Symbolicate the most recent crash from android. | 23 * `mojodb stop` |
| 24 * `mojodb start_tracing` # Starts recoding a performance trace (use stop_tracing
to stop) |
| 25 * `mojodb print_crash` # Symbolicate the most recent crash from android. |
| 20 | 26 |
| 21 Once `mojodb start` is issued, all subsequent commands will be sent to | 27 Once `mojodb start` is issued, all subsequent commands will be sent to |
| 22 the running mojo_shell instance (even on an attached android device). | 28 the running mojo_shell instance (even on an attached android device). |
| 23 `mojodb start` reads gn args from the passed build directory to | 29 `mojodb start` reads gn args from the passed build directory to |
| 24 determine whether its using android, for example. | 30 determine whether its using android, for example. |
| 25 | 31 |
| 32 Running tests |
| 33 ------------- |
| 34 |
| 35 Tests are only supported on Linux currently. |
| 36 |
| 26 * ``./sky/tools/test_sky --debug`` | 37 * ``./sky/tools/test_sky --debug`` |
| 27 * This runs the tests against ``//out/Debug``. If you want to run against | 38 * This runs the tests against ``//out/Debug``. If you want to run against |
| 28 ``//out/Release``, omit the ``--debug`` flag. | 39 ``//out/Release``, omit the ``--debug`` flag. |
| 29 | 40 |
| 30 Running tests manually | 41 Running tests manually |
| 31 ---------------------- | 42 ---------------------- |
| 32 | 43 |
| 33 * ``sky/tools/skygo/linux64/sky_server -t Debug . 8000`` | 44 Running tests manually lets you more quickly iterate during |
| 34 * ``out/Debug/mojo_shell --args-for="mojo:native_viewport_service --use-headless
-config --use-osmesa" --args-for"=mojo:sky_viewer --testing" --content-handlers=
text/sky,mojo:sky_viewer --url-mappings=mojo:window_manager=mojo:sky_tester,mojo
:surfaces_service=mojo:fake_surfaces_service mojo:window_manager`` | 45 development; rather than having to compile and rerun all the tests, |
| 46 then trawl through the build output to find the current results, you |
| 47 can just run the test you're working on and reload it over and over, |
| 48 seeing the output right there on your console. |
| 49 |
| 50 * ``sky/tools/skygo/linux64/sky_server -v -p 8000 out/Debug out/Debug/gen/dart-p
kg/packages`` |
| 51 * ``out/Debug/mojo_shell --args-for="mojo:native_viewport_service --use-headless
-config --use-osmesa" --args-for"=mojo:sky_viewer --testing" --content-handlers=
application/dart,mojo:sky_viewer --url-mappings=mojo:window_manager=mojo:sky_tes
ter,mojo:surfaces_service=mojo:fake_surfaces_service mojo:window_manager`` |
| 35 * The ``sky_tester`` should print ``#READY`` when ready | 52 * The ``sky_tester`` should print ``#READY`` when ready |
| 36 * Type the URL you wish to run, for example ``http://127.0.0.1:8000/sky/tests/lo
wlevel/text.html``, and press the enter key | 53 * Type the URL you wish to run, for example ``http://127.0.0.1:8000/sky/tests/wi
dgets/dialog.dart``, and press the enter key |
| 37 * The harness should print the results of the test. You can then type another U
RL. | 54 * The harness should print the results of the test. You can then type another U
RL. |
| 38 | 55 |
| 39 Writing tests | 56 Writing tests |
| 40 ------------- | 57 ------------- |
| 41 | 58 |
| 42 * We recommend using the ``unittest.dart`` testing framework. | 59 We recommend using the [Dart |
| 43 * See ``sky/tests/lowlevel/attribute-collection.sky`` for an example. | 60 ``test``](https://pub.dartlang.org/packages/test) testing framework. |
| 44 | 61 See [``sky/tests/raw/color_bounds.dart``](tests/raw/color_bounds.dart) |
| 45 Adding pixel tests | 62 for an example. |
| 46 ------------------ | |
| 47 | |
| 48 Sky does not have proper pixel tests. Instead we have only reftests. | |
| 49 If you want a pixel test, you need to dump the png from a reftest, | |
| 50 upload it to googlestorage and then put and <img> pointing to the | |
| 51 uploaded file in the reference. | |
| 52 | |
| 53 1. Create your test (e.g. foo.sky). | |
| 54 2. Create an dummy reference file (foo-expected.sky). | |
| 55 3. Run the test (it will fail). | |
| 56 4. Copy the -actual.png file to googlestorage (see below). | |
| 57 5. Put an ``<img>`` pointing to your newly uploaded png in the reference file at | |
| 58 http://storage.googleapis.com/mojo/sky-pngs/SHA1_HASH_HERE | |
| 59 | |
| 60 Copying the file to googlestorage: | |
| 61 ```bash | |
| 62 $ sha1sum ../out/Debug/layout-test-results/framework/flights-app-pixels-actual.p
ng | |
| 63 db0508cdfe69e996a93464050dc383f6480f1283 ../out/Debug/layout-test-results/frame
work/flights-app-pixels-actual.png | |
| 64 $ gsutil.py cp ../out/Debug/layout-test-results/framework/flights-app-pixels-act
ual.png gs://mojo/sky-pngs/db0508cdfe69e996a93464050dc383f6480f1283 | |
| 65 ``` | |
| 66 | |
| 67 Long-term, we should not have these tests at all and should just | |
| 68 dump paint commands. In the short-term, if we find we're doing this | |
| 69 a lot we should obviously automate this process, e.g. test_sky could | |
| 70 do all of this work, including spitting out the correct reference file. | |
| OLD | NEW |