Forráskód Böngészése

Fix error with loading transformations, and add test for Pacman transformation.

Bentley James Oakes 7 éve
szülő
commit
090d2a51bf

+ 4 - 0
mt/mtworker.py

@@ -7,6 +7,7 @@ from ws import WebSocket
 from ptcal.ptcal import PyTCoreAbstractionLayer
 from ptcal.utils import Utilities as utils
 
+import traceback
 
 '''
 	message handler thread: mtworkers delegate the handling of each message they
@@ -184,6 +185,9 @@ class mtworkerThread(threading.Thread) :
 					self._ptcal.loadTransforms(transfs)
 					self._postMessage(msg['resp'],{'statusCode':200})
 			except Exception as e :
+				print("Exception: " + str(e))
+				traceback.print_exc()
+
 				self._postMessage(
 					msg['resp'],
 					{'statusCode':500,

+ 1 - 1
mt/ptcal/motifcontext.py

@@ -147,7 +147,7 @@ class MotifContext(TransformationContext) :
 							branchID=edge['dest']
 							def f(e) :
 								return e['src'] == branchID
-							branchRuleID=list(filter(f,self.t['edges'])[0]['dest'])
+							branchRuleID=list(filter(f,self.t['edges']))[0]['dest']
 
 							rule = self.ruleIdentifier(self.t['nodes'],branchRuleID)
 

+ 39 - 0
tests/07_pacman_transformation_test.js

@@ -0,0 +1,39 @@
+//NOTE: REQUIRES DSL FROM PREVIOUS TEST
+
+let test_utils = require('./test_utils');
+let model_building_utils = require('./model_building_utils');
+
+module.exports = {
+
+    beforeEach: function (client, done) {
+        client.url('http://localhost:8124/atompm').pause(300).maximizeWindow(done);
+    },
+
+    'Login': function (client) {
+
+        test_utils.login(client);
+    },
+
+    'Execute Transformation': function (client) {
+        model_building_utils.load_model(client, "Formalisms/Pacman", "sample.model");
+
+        model_building_utils.load_transformation(client, "Formalisms/Pacman/OpSem", "T_Pacman_Simulation.model");
+
+        let run_button = "#\\2f Toolbars\\2f TransformationController\\2f TransformationController\\2e buttons\\2e model\\2f play";
+        client.click(run_button);
+
+        client.pause(5000);
+
+        let pacman = "html body.default_style div#rootDiv.rootDiv div#contentDiv.contentDiv div#div_container.container div#div_canvas.canvas svg g#/Formalisms/Pacman/Pacman.defaultIcons/PacmanIcon/55.instance.clickable";
+
+        client.waitForElementNotPresent(pacman, 60000, "Pacman killed");
+
+    },
+
+    after: function (client) {
+        client.end();
+    },
+
+
+};
+

+ 23 - 16
tests/model_building_utils.js

@@ -151,6 +151,22 @@ function click_off(client) {
         .mouseButtonClick('left');
 }
 
+function navigate_to_folder(client, folder_name) {
+
+    let root_button = "#navbar_\\2f";
+    client.waitForElementPresent(root_button, 1000, "Find root button")
+        .click(root_button);
+
+    let folder_path = folder_name.split("/");
+
+    for (let f of folder_path) {
+        let folder_name_div = "#" + f;
+        client.click(folder_name_div);
+        client.pause(500);
+    }
+
+}
+
 function load_model(client, folder_name, model_name) {
 
     let load_button = "#\\2f Toolbars\\2f MainMenu\\2f MainMenu\\2e buttons\\2e model\\2f loadModel";
@@ -159,12 +175,7 @@ function load_model(client, folder_name, model_name) {
         .click(load_button)
         .waitForElementPresent("#dialog_btn", 1000, "Load menu opens");
 
-    let root_button = "#navbar_\\2f";
-    client.waitForElementPresent(root_button, 1000, "Find root button")
-        .click(root_button);
-
-    let folder_name_div = "#" + folder_name;
-    client.click(folder_name_div);
+    navigate_to_folder(client, folder_name);
 
     client.click("#" + fix_selector(model_name))
         .pause(200)
@@ -216,6 +227,10 @@ function save_model(client, folder_name, model_name) {
     );
 }
 
+function load_transformation(client, folder_name, model_name) {
+    compile_model(client, "transform", folder_name, model_name)
+}
+
 function compile_model(client, compile_type, folder_name, model_name) {
 
     let button = "";
@@ -235,16 +250,7 @@ function compile_model(client, compile_type, folder_name, model_name) {
         .click(button)
         .waitForElementPresent("#dialog_btn", 2000, button_name + " menu opens");
 
-    let root_button = "#navbar_\\2f";
-    client.waitForElementPresent(root_button, 1000, "Find root button")
-        .click(root_button);
-
-    let folder_div = "#" + folder_name;
-    client.element('css selector', folder_div, function (result) {
-        if (result.status != -1) {
-            client.click(folder_div);
-        }
-    });
+    navigate_to_folder(client, folder_name);
 
     let new_file_text = "#new_file";
     let model_div = "#" + fix_selector(model_name);
@@ -308,6 +314,7 @@ module.exports = {
     save_model,
     load_model,
     compile_model,
+    load_transformation,
     scroll_geometry_element,
     move_element
 };