test fixes

This commit is contained in:
Val Erastov 2018-10-15 15:37:45 -07:00
parent 2f34f9390e
commit 325f08c9a0
4 changed files with 35 additions and 10 deletions

View file

@ -4,7 +4,7 @@ import {MBrepShell} from '../model/mshell';
/*
* TPI stands for the Test Program Interface
*/
export function activate({bus, services}) {
export function activate({streams, services}) {
function addShellOnScene(shell, skin) {
const sceneSolid = new MBrepShell(shell);
@ -16,7 +16,7 @@ export function activate({bus, services}) {
services.viewer.render();
}
services.tpi = Object.assign({
bus,
streams,
services,
addShellOnScene,
addOnScene

16
web/test/cases/craft.js Normal file
View file

@ -0,0 +1,16 @@
import * as test from '../test';
export default {
testPlanes: env => {
test.modeller(env.testTPI(tpi => {
tpi.services.action.run('PLANE');
console.dir(tpi);
env.done();
}));
},
};

View file

@ -19,8 +19,8 @@ export default {
],
ModellerOperations: [
Craft: [
TestCase('craft'),
],
BREP: [

View file

@ -51,7 +51,13 @@ export class TestEnv {
}
}
}
testTPI(testBlock) {
return this.test(function(win, app) {
testBlock(app.TPI);
});
}
assertTrue(stmt, msg) {
if (!stmt) {
this.fail('assertTrue fails.', msg);
@ -139,15 +145,15 @@ function checkSimilarity(data1, data2) {
}
export function load(url, callback) {
export function load(url, callback, apiGet) {
const sandbox = $('#sandbox');
sandbox.empty();
const frame = $('<iframe>');
sandbox.append(frame);
$(function() { // fire event when iframe is ready
frame.load(function() {
frame.on('load', function() {
const win = frame.get(0).contentWindow;
callback(win, {TPI: win.__CAD_APP.services.tpi})
callback(win, apiGet(win))
});
});
frame.attr('src', window.location.origin + url)
@ -156,17 +162,20 @@ export function load(url, callback) {
const TEST_PROJECT = '$$$__test__$$$';
const STORAGE_PREFIX_SKETCH = "TCAD.projects.";
const SKETCHER_API = win => win.__CAD_APP;
const MODELLER_API = win => ({TPI: win.__CAD_APP.services.tpi});
export function emptySketch(callback) {
localStorage.removeItem(STORAGE_PREFIX_SKETCH + TEST_PROJECT);
sketch(callback);
}
export function sketch(callback) {
load('/sketcher.html#' + TEST_PROJECT, callback);
load('/sketcher.html#' + TEST_PROJECT, callback, SKETCHER_API);
}
export function modeller(callback) {
load('/index.html#' + TEST_PROJECT, callback);
load('/index.html#' + TEST_PROJECT, callback, MODELLER_API);
}
export function emptyModeller(callback) {