skia2/modules/canvaskit/tests/canvaskitinit.js
Kevin Lubick cc8a76f3c7 [canvaskit] Add gm helper functions to tests.
Note to the reviewer: Look at tests/util.js first and then
look at the others. Gerrit lets you ignore whitespace changes,
which I would recommend for this.

This emulates tests on the C++ side and dramatically reduces
boilerplate on the test code.

This also uses the beforeEach(async () => {}) trick to save
a lot of promise resolutions before each tests.

I try to clean up the style a bit as I go, seriously thinking
about adding eslint for at least the tests.

Change-Id: Iced4abb57f66572035ab5d1a54b374055e8aaa58
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/281439
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
2020-04-03 19:12:02 +00:00

18 lines
591 B
JavaScript

// The increased timeout is especially needed with larger binaries
// like in the debug/gpu build
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
let CanvasKit = null;
const LoadCanvasKit = new Promise((resolve, reject) => {
console.log('canvaskit loading', new Date());
CanvasKitInit({
locateFile: (file) => '/canvaskit/'+file,
}).ready().then((loaded) => {
console.log('canvaskit loaded', new Date());
CanvasKit = loaded;
resolve();
}).catch((e) => {
console.error('canvaskit failed to load', new Date(), e);
reject();
});
});