Переглянути джерело

Test all models and toolbars.

Bentley James Oakes 7 роки тому
батько
коміт
d22ebe5fbf
4 змінених файлів з 42 додано та 15 видалено
  1. 1 0
      client/gui_utils.js
  2. 3 3
      tests/03_model_test.js
  3. 1 2
      tests/04_toolbar_test.js
  4. 37 10
      tests/test_utils.js

+ 1 - 0
client/gui_utils.js

@@ -653,6 +653,7 @@ GUIUtils = function(){
 					callback(input); 
 				}
 			});
+			ok.attr("id", "dialog_btn");
 			ok.html('ok');
 			dialog.append(ok);
 		}

+ 3 - 3
tests/03_model_test.js

@@ -27,9 +27,9 @@ module.exports = {
         test_utils.load_model(client, filenames);
     },
 
-    // 'Load all models' : function (client) {
-    //     test_utils.getFiles(client, user, '/**/*.model', test_utils.load_model);
-    // },
+    'Load all models' : function (client) {
+        test_utils.getFiles(client, user, '/**/*.model', test_utils.load_model);
+    },
 
     after : function (client) {
         client.end();

+ 1 - 2
tests/04_toolbar_test.js

@@ -24,8 +24,7 @@ module.exports = {
         test_utils.getFiles(client, user, '/**/*.buttons.model', test_utils.load_toolbar);
 
         console.log("Testing metamodels...");
-        let failing_files = ['/Formalisms/__Templates__/ConcreteSyntaxTemplate.defaultIcons.metamodel'];
-        test_utils.getFiles(client, user, '/**/*Icons.metamodel', test_utils.load_toolbar, failing_files);
+        test_utils.getFiles(client, user, '/**/*Icons.metamodel', test_utils.load_toolbar);
 
         console.log("Testing pattern metamodels...");
         test_utils.getFiles(client, user, '/**/*Icons.pattern.metamodel', test_utils.load_toolbar);

+ 37 - 10
tests/test_utils.js

@@ -5,7 +5,7 @@ function login(client) {
         }, [], null
     );
 
-    client.pause(300);
+    client.pause(500);
 
     client.getTitle(function (title) {
         this.assert.ok(title.includes("AToMPM - [Unnamed]"), "AToMPM is opened");
@@ -21,11 +21,25 @@ function load_model(client, fnames) {
             }, [name], null
         );
 
-        client.pause(500);
+        client.pause(1000);
 
-        client.getTitle(function (title) {
-            this.assert.ok(title.includes(name), "Check for model: " + name);
+        client.element('css selector', '#dialog_btn', function (result) {
+            if (result.status != -1) {
+                //Dialog has popped up, so check the text and click the button
+                client.assert.containsText("#div_dialog_0", "File not found");
+                client.click("#dialog_btn");
+
+                //client.verify.ok(false, "File: " + name + " failed to load!"); //don't stop testing
+                console.error("File: " + name + " failed to load!");
+
+            } else {
+                //Model loaded, so check the title
+                client.getTitle(function (title) {
+                    this.assert.ok(title.includes(name), "Check for model: " + name);
+                });
+            }
         });
+
     }
 
 }
@@ -43,19 +57,32 @@ function load_toolbar(client, fnames) {
         let toolbar_name = name.replace(/\//g, "\\2f ").replace(/\./g, "\\2e ");
         toolbar_name = "#div_toolbar_" + toolbar_name;
 
-        client.waitForElementPresent(toolbar_name, 2000, "Check for toolbar: " + name);
-    }
+        client.element('css selector', '#dialog_btn', function (result) {
+            if (result.status != -1) {
+                //Dialog has popped up, so check the text and click the button
+                client.assert.containsText("#div_dialog_0", "File not found");
+                client.click("#dialog_btn");
+
+                //client.verify.ok(false, "File: " + name + " failed to load!"); //don't stop testing
+                console.error("File: " + name + " failed to load!");
+            } else {
+                //Toolbar loaded, so check for it
+                client.waitForElementPresent(toolbar_name, 2000, "Check for toolbar: " + name);
+            }
+        });
+
+            }
 
 }
 
 let user = "./users/testuser/";
 let glob = require('glob');
 
-let getFiles = function (client, dir, pattern, load_function, failing_files) {
-    glob(dir + pattern, callback(client, load_function, failing_files));
+let getFiles = function (client, dir, pattern, load_function, files_to_skip) {
+    glob(dir + pattern, callback(client, load_function, files_to_skip));
 };
 
-function callback(client, load_function, failing_files) {
+function callback(client, load_function, files_to_skip) {
     return function (err, res) {
         if (err) {
             assert(false, "Error in reading directory: " + user + "Toolbars");
@@ -67,7 +94,7 @@ function callback(client, load_function, failing_files) {
                 fn = "\/" + fn.replace(user, "");
 
                 //skip files we know will fail
-                if (failing_files == undefined || !failing_files.includes(fn)) {
+                if (files_to_skip == undefined || !files_to_skip.includes(fn)) {
                     filenames.push(fn);
                 }
             }