Skip to content

Commit

Permalink
Issue #1 merge: Merge pull request #8 from akashgupta9990/master
Browse files Browse the repository at this point in the history
Fixed renderer test setup
  • Loading branch information
manojchandrashekar authored May 15, 2018
2 parents 590110b + 987a384 commit f498cdd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
6 changes: 4 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
"angular-mocks": "1.5.9",
"content-editor-dependency": "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/content-editor/scripts/external.min.js",
"content-editor": "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/content-editor/scripts/script.min.js",
"renderer-dependency-appconfig": "https://dev.ekstep.in/content/preview/scripts/renderer.script.min.js?ver=379",
"renderer-dependency-appconfig": "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/v3/preview/scripts/renderer.script.min.js",
"renderer-dependency-toastr": "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/v3/preview/scripts/renderer.external.min.js",
"renderer-createjs": "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/v3/preview/coreplugins/org.ekstep.ecmlrenderer-1.0/renderer/libs/createjs.min.js",
"renderer-creatine": "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/v3/preview/coreplugins/org.ekstep.ecmlrenderer-1.0/renderer/libs/creatine-1.0.0.min.js",
"renderer": "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/v3/preview/coreplugins/org.ekstep.ecmlrenderer-1.0/renderer/libs/renderer.min.js",
"pollyfill": "https://cdn.jsdelivr.net/npm/promise-polyfill@7/dist/polyfill.min.js",
"renderer-telemetry": "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/v3/preview/scripts/renderer.telemetry.min.js"
"renderer-telemetry": "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/v3/preview/scripts/renderer.telemetry.min.js",
"renderer-cordovaplugin" : "https://s3.ap-south-1.amazonaws.com/ekstep-public-prod/v3/preview/coreplugins/org.ekstep.ecmlrenderer-1.0/renderer/libs/cordovaaudioplugin-0.6.1.min.js",
"renderer-angular-mocks": "https://cdn.jsdelivr.net/npm/angular-mocks@1.5.9/angular-mocks.min.js"
}
}
32 changes: 26 additions & 6 deletions lib/renderer/dom-simulation.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,40 @@
var contentBody = JSON.parse('{"theme":{"stage":{"manifest":{"media":[]},"x":0,"y":0,"w":100,"h":100,"id":"stage1"},"manifest":{"media":[]},"plugin-manifest":"","compatibilityVersion":2,"id":"theme","version":1,"startStage":"stage1"}}');

var contentBody = JSON.parse('{"theme":{"stage":{"manifest":{"media":[]},"x":0,"y":0,"w":100,"h":100,"id":"stage1","rotate":""},"manifest":{"media":[]},"plugin-manifest":"","compatibilityVersion":2,"id":"theme","version":1,"startStage":"stage1"}}');
function setUpRenderer() {
var canvas = "<div ng-app='genie-canvas' id='gameArea'><div id='overlay'></div><canvas id='gameCanvas' style='top: 10px;left: 10px;position: absolute;'></canvas></div><div id='splashScreen'></div>";
window.Renderer = {};
var canvas = "<div ng-app='genie-canvas' id='gameArea'><div id='overlay'></div><canvas id='gameCanvas' style='top: 10px;left: 10px;position: absolute;'></canvas></div>";
var body = document.getElementsByTagName("body")[0];
var div = document.createElement('div');
div.innerHTML = canvas;
body.appendChild(div.children[0]);
setGlobalConfig({config: {}, context: {}});
setGlobalConfig({ 'context': {}, 'config': {} });
window.isMobile = window.cordova ? true : false;
window.content = JSON.parse('{"baseDir":"/base/public/test/testContent", "path":"/base/public/test/testContent", "identifier": "org.ekstep.item.sample", "mimeType": "application/vnd.ekstep.ecml-archive", "name": "Content Preview ", "author": "EkStep", "localData": {"name": "Content Preview ", "loadingMessage": "Without requirements or design, programming is the art of adding bugs to an empty text file. ...", "identifier": "org.ekstep.item.sample" }, "pkgVersion": 1, "isAvailable": true}');
window.content.body = JSON.parse(JSON.stringify(contentBody));
org.ekstep.service.init();
AppConfig.corePluginspath = '/public/coreplugins';
org.ekstep.contentrenderer.initPlugins('', '/public/coreplugins');
AppConfig.corePluginspath = 'base';
org.ekstep.contentrenderer.initPlugins('', AppConfig.corePluginspath);
GlobalContext.game.id = packageName;
GlobalContext.game.ver = version;
startTelemetry(GlobalContext.game.id, GlobalContext.game.ver);
this.contentMetaData = window.content;
this.gdata = content.body;
content.body.theme.canvasId = 'gameCanvas'
document.fonts = { 'ready': {} };
document.fonts.ready.then = jasmine.createSpy().and.callFake(function () {
Renderer.update = true;
});
Renderer.divIds = { 'canvas': 'ganmeCanvas', 'gameArea': 'gameArea' };
Renderer.theme = new ThemePlugin(content.body.theme);
Renderer.theme.baseDir = globalConfig.basepath || content.path;
Renderer.theme.start(content.path.replace('file:///', '') + "/assets/");
createjs.Ticker.addEventListener("tick", function () {
if (Renderer.update && (typeof Renderer.theme !== 'undefined')) {
Renderer.theme.update();
Renderer.update = false;
} else if (Renderer.theme) {
Renderer.theme.tick();
}
});
};

function startRenderer(data) {
Expand All @@ -24,3 +43,4 @@ function startRenderer(data) {
}

setUpRenderer();

7 changes: 5 additions & 2 deletions lib/renderer/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ module.exports = function(config) {
// TODO: Remove this hack to get jquery, angular etc till renderer exposes bundled dependency file
// https://github.com/ekstep/Contributed-Plugins/issues/136
"bower_components/pollyfill/index.js",
"bower_components/renderer-dependency-toastr/index.js",
"bower_components/renderer-dependency-appconfig/index.js",
"bower_components/renderer-createjs/index.js",
"bower_components/renderer-cordovaplugin/index.js",
"bower_components/renderer-creatine/index.js",
"bower_components/renderer-dependency-toastr/index.js",
"bower_components/renderer-angular-mocks/index.js",
"bower_components/renderer-telemetry/index.js",
"bower_components/renderer-dependency-appconfig/index.js",
"bower_components/renderer/index.js",
"bower_components/renderer-telemetry/index.js",
__dirname + "/dom-simulation.js",
Expand Down

0 comments on commit f498cdd

Please sign in to comment.