Basic wasm skp debugger unit test

Bug: skia:
Change-Id: I91a3f40279724a29d759229c012be864d8a02edd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/197765
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Nathaniel Nifong <nifong@google.com>
This commit is contained in:
Nathaniel Nifong 2019-03-05 13:04:14 -05:00 committed by Skia Commit-Bot
parent 928112697e
commit 1523963d4f
3 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,73 @@
const isDocker = require('is-docker')();
module.exports = function(config) {
// Set the default values to be what are needed when testing the
// WebAssembly build locally.
let cfg = {
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
{ pattern: 'debugger/bin/debugger.wasm', included:false, served:true},
{ pattern: 'debugger/bin/debugger.data', included:false, served:true},
'../../modules/pathkit/tests/testReporter.js',
'debugger/bin/debugger.js',
'tests/*.spec.js'
],
proxies: {
'/debugger/': '/base/debugger/bin/',
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 4444,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
browserDisconnectTimeout: 15000,
browserNoActivityTimeout: 15000,
// start these browsers
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,
};
if (isDocker) {
// See https://hackernoon.com/running-karma-tests-with-headless-chrome-inside-docker-ae4aceb06ed3
cfg.browsers = ['ChromeHeadlessNoSandbox'],
cfg.customLaunchers = {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
// Without this flag, we see an error:
// Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
'--no-sandbox'
],
},
};
}
config.set(cfg);
}

View File

@ -0,0 +1,21 @@
{
"name": "debugger-local",
"version": "0.0.0",
"description": "private",
"private": true,
"main": "index.js",
"dependencies": {},
"devDependencies": {
"is-docker": "~1.1.0",
"jasmine-core": "~3.1.0",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-jasmine": "~1.1.2",
"requirejs": "~2.3.5"
},
"scripts": {
"test": "make test-continuous"
},
"author": "",
"license": "BSD-3-Clause"
}

View File

@ -0,0 +1,35 @@
// The increased timeout is especially needed with larger binaries
// like in the debug/gpu build
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
describe('Debugger\'s Startup Behavior', function() {
// Note, don't try to print the CanvasKit object - it can cause Karma/Jasmine to lock up.
var Debugger = null;
const LoadDebugger = new Promise(function(resolve, reject) {
if (Debugger) {
resolve();
} else {
DebuggerInit({
locateFile: (file) => '/debugger/'+file,
}).ready().then((_Debugger) => {
Debugger = _Debugger;
resolve();
});
}
});
let container = document.createElement('div');
document.body.appendChild(container);
container.innerHTML = `<canvas id=debugger_view width=720 height=1280></canvas>`;
it('can load the built in skp sample', function(done) {
LoadDebugger.then(catchException(done, () => {
const surface = Debugger.MakeSWCanvasSurface('debugger_view');
const player = new Debugger.SkpDebugPlayer();
player.loadSkp();
player.drawTo(surface, 789); // number of commands in sample file
surface.flush();
done();
}));
});
});