Support for selenium tests.
This commit is contained in:
parent
6042928cc5
commit
b3d06ca5c0
@ -22,6 +22,7 @@ ImporterApp = function ()
|
|||||||
this.importerButtons = null;
|
this.importerButtons = null;
|
||||||
this.extensionButtons = null;
|
this.extensionButtons = null;
|
||||||
this.dialog = null;
|
this.dialog = null;
|
||||||
|
this.readyForTest = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
ImporterApp.prototype.Init = function ()
|
ImporterApp.prototype.Init = function ()
|
||||||
@ -81,6 +82,19 @@ ImporterApp.prototype.Init = function ()
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ImporterApp.prototype.ClearReadyForTest = function ()
|
||||||
|
{
|
||||||
|
if (this.readyForTest !== null) {
|
||||||
|
this.readyForTest.remove ();
|
||||||
|
this.readyForTest = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ImporterApp.prototype.SetReadyForTest = function ()
|
||||||
|
{
|
||||||
|
this.readyForTest = $('<div>').attr ('id', 'readyfortest').hide ().appendTo ($('body'));
|
||||||
|
};
|
||||||
|
|
||||||
ImporterApp.prototype.AddExtension = function (extension)
|
ImporterApp.prototype.AddExtension = function (extension)
|
||||||
{
|
{
|
||||||
if (!extension.IsEnabled ()) {
|
if (!extension.IsEnabled ()) {
|
||||||
@ -168,9 +182,10 @@ ImporterApp.prototype.JsonLoaded = function (progressBar)
|
|||||||
|
|
||||||
ImporterApp.prototype.GenerateMenu = function ()
|
ImporterApp.prototype.GenerateMenu = function ()
|
||||||
{
|
{
|
||||||
function AddDefaultGroup (menu, name)
|
function AddDefaultGroup (menu, name, id)
|
||||||
{
|
{
|
||||||
var group = menu.AddGroup (name, {
|
var group = menu.AddGroup (name, {
|
||||||
|
id : id,
|
||||||
openCloseButton : {
|
openCloseButton : {
|
||||||
isOpen : false,
|
isOpen : false,
|
||||||
open : 'images/opened.png',
|
open : 'images/opened.png',
|
||||||
@ -265,6 +280,7 @@ ImporterApp.prototype.GenerateMenu = function ()
|
|||||||
userData : mesh
|
userData : mesh
|
||||||
},
|
},
|
||||||
userButton : {
|
userButton : {
|
||||||
|
id : 'showhidemesh-' + meshIndex,
|
||||||
isOpen : true,
|
isOpen : true,
|
||||||
onCreate : function (image) {
|
onCreate : function (image) {
|
||||||
image.attr ('src', 'images/visible.png');
|
image.attr ('src', 'images/visible.png');
|
||||||
@ -283,7 +299,7 @@ ImporterApp.prototype.GenerateMenu = function ()
|
|||||||
var menu = $('#menu');
|
var menu = $('#menu');
|
||||||
var importerMenu = new ImporterMenu (menu);
|
var importerMenu = new ImporterMenu (menu);
|
||||||
|
|
||||||
var filesGroup = AddDefaultGroup (importerMenu, 'Files');
|
var filesGroup = AddDefaultGroup (importerMenu, 'Files', 'filesmenuitem');
|
||||||
importerMenu.AddSubItem (filesGroup, this.fileNames.main);
|
importerMenu.AddSubItem (filesGroup, this.fileNames.main);
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < this.fileNames.requested.length; i++) {
|
for (i = 0; i < this.fileNames.requested.length; i++) {
|
||||||
@ -291,23 +307,23 @@ ImporterApp.prototype.GenerateMenu = function ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.fileNames.missing.length > 0) {
|
if (this.fileNames.missing.length > 0) {
|
||||||
var missingFilesGroup = AddDefaultGroup (importerMenu, 'Missing Files');
|
var missingFilesGroup = AddDefaultGroup (importerMenu, 'Missing Files', 'missingfilesmenuitem');
|
||||||
for (i = 0; i < this.fileNames.missing.length; i++) {
|
for (i = 0; i < this.fileNames.missing.length; i++) {
|
||||||
importerMenu.AddSubItem (missingFilesGroup, this.fileNames.missing[i]);
|
importerMenu.AddSubItem (missingFilesGroup, this.fileNames.missing[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var infoGroup = AddDefaultGroup (importerMenu, 'Information');
|
var infoGroup = AddDefaultGroup (importerMenu, 'Information', 'informationmenuitem');
|
||||||
AddInformation (infoGroup, jsonData);
|
AddInformation (infoGroup, jsonData);
|
||||||
|
|
||||||
var materialsGroup = AddDefaultGroup (importerMenu, 'Materials');
|
var materialsGroup = AddDefaultGroup (importerMenu, 'Materials', 'materialsmenuitem');
|
||||||
var material;
|
var material;
|
||||||
for (i = 0; i < jsonData.materials.length; i++) {
|
for (i = 0; i < jsonData.materials.length; i++) {
|
||||||
material = jsonData.materials[i];
|
material = jsonData.materials[i];
|
||||||
AddMaterial (importerMenu, materialsGroup, material);
|
AddMaterial (importerMenu, materialsGroup, material);
|
||||||
}
|
}
|
||||||
|
|
||||||
var meshesGroup = AddDefaultGroup (importerMenu, 'Meshes');
|
var meshesGroup = AddDefaultGroup (importerMenu, 'Meshes', 'meshesmenuitem');
|
||||||
var mesh;
|
var mesh;
|
||||||
for (i = 0; i < jsonData.meshes.length; i++) {
|
for (i = 0; i < jsonData.meshes.length; i++) {
|
||||||
mesh = jsonData.meshes[i];
|
mesh = jsonData.meshes[i];
|
||||||
@ -350,6 +366,7 @@ ImporterApp.prototype.Generate = function (progressBar)
|
|||||||
onFinish : function () {
|
onFinish : function () {
|
||||||
importerApp.GenerateMenu ();
|
importerApp.GenerateMenu ();
|
||||||
importerApp.inGenerate = false;
|
importerApp.inGenerate = false;
|
||||||
|
importerApp.SetReadyForTest ();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -357,12 +374,13 @@ ImporterApp.prototype.Generate = function (progressBar)
|
|||||||
var jsonData = importerApp.viewer.GetJsonData ();
|
var jsonData = importerApp.viewer.GetJsonData ();
|
||||||
importerApp.viewer.SetJsonData (JSM.MergeJsonDataMeshes (jsonData));
|
importerApp.viewer.SetJsonData (JSM.MergeJsonDataMeshes (jsonData));
|
||||||
}
|
}
|
||||||
importerApp.viewer.ShowAllMeshes (environment);
|
importerApp.viewer.ShowAllMeshes (environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
var jsonData = this.viewer.GetJsonData ();
|
var jsonData = this.viewer.GetJsonData ();
|
||||||
if (jsonData.materials.length === 0 || jsonData.meshes.length === 0) {
|
if (jsonData.materials.length === 0 || jsonData.meshes.length === 0) {
|
||||||
this.GenerateError ('Failed to open file. Maybe something is wrong with your file.');
|
this.GenerateError ('Failed to open file. Maybe something is wrong with your file.');
|
||||||
|
this.SetReadyForTest ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,6 +444,7 @@ ImporterApp.prototype.ShowHideMesh = function (meshIndex)
|
|||||||
|
|
||||||
ImporterApp.prototype.ProcessFiles = function (fileList, isUrl)
|
ImporterApp.prototype.ProcessFiles = function (fileList, isUrl)
|
||||||
{
|
{
|
||||||
|
this.ClearReadyForTest ();
|
||||||
this.dialog.Close ();
|
this.dialog.Close ();
|
||||||
if (this.inGenerate) {
|
if (this.inGenerate) {
|
||||||
return;
|
return;
|
||||||
@ -455,6 +474,7 @@ ImporterApp.prototype.ProcessFiles = function (fileList, isUrl)
|
|||||||
processorFunc (userFiles, {
|
processorFunc (userFiles, {
|
||||||
onError : function () {
|
onError : function () {
|
||||||
myThis.GenerateError ('No readable file found. You can open 3ds, obj and stl files.');
|
myThis.GenerateError ('No readable file found. You can open 3ds, obj and stl files.');
|
||||||
|
myThis.SetReadyForTest ();
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
onReady : function (fileNames, jsonData) {
|
onReady : function (fileNames, jsonData) {
|
||||||
|
|||||||
@ -55,6 +55,9 @@ ImporterMenu.prototype.AddSubItem = function (parent, name, parameters)
|
|||||||
|
|
||||||
var menuContent = null;
|
var menuContent = null;
|
||||||
if (parameters !== undefined && parameters !== null) {
|
if (parameters !== undefined && parameters !== null) {
|
||||||
|
if (parameters.id !== undefined && parameters.id !== null) {
|
||||||
|
menuItem.attr ('id', parameters.id);
|
||||||
|
}
|
||||||
if (parameters.openCloseButton !== undefined && parameters.openCloseButton !== null) {
|
if (parameters.openCloseButton !== undefined && parameters.openCloseButton !== null) {
|
||||||
menuContent = $('<div>').addClass ('menugroup').appendTo (parent);
|
menuContent = $('<div>').addClass ('menugroup').appendTo (parent);
|
||||||
var isOpen = parameters.openCloseButton.isOpen;
|
var isOpen = parameters.openCloseButton.isOpen;
|
||||||
@ -83,6 +86,9 @@ ImporterMenu.prototype.AddSubItem = function (parent, name, parameters)
|
|||||||
|
|
||||||
if (parameters.userButton !== undefined && parameters.userButton !== null) {
|
if (parameters.userButton !== undefined && parameters.userButton !== null) {
|
||||||
var userImage = $('<img>').addClass ('menubutton').attr ('title', parameters.userButton.title).appendTo (menuItem);
|
var userImage = $('<img>').addClass ('menubutton').attr ('title', parameters.userButton.title).appendTo (menuItem);
|
||||||
|
if (parameters.userButton.id !== undefined && parameters.userButton.id !== null) {
|
||||||
|
userImage.attr ('id', parameters.userButton.id);
|
||||||
|
}
|
||||||
if (parameters.userButton.onCreate !== undefined && parameters.userButton.onCreate !== null) {
|
if (parameters.userButton.onCreate !== undefined && parameters.userButton.onCreate !== null) {
|
||||||
parameters.userButton.onCreate (userImage, parameters.userButton.userData);
|
parameters.userButton.onCreate (userImage, parameters.userButton.userData);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user