Browse Source

Remove duplicated code.

Bentley James Oakes 6 years ago
parent
commit
3dc3e8f35e
1 changed files with 1 additions and 348 deletions
  1. 1 348
      tests/05_creating_dsl.js

+ 1 - 348
tests/05_creating_dsl.js

@@ -728,354 +728,7 @@ module.exports = {
 
 
     },
-
-
-    'Create CS model': function (client) {
-
-        let filename = '/Formalisms/__LanguageSyntax__/ConcreteSyntax/ConcreteSyntax.defaultIcons.metamodel';
-        test_utils.load_toolbar(client, [filename]);
-
-        let classIcon = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\.metamodel\\/IconIcon";
-        client.waitForElementPresent(classIcon, 2000, "Check for class icon...");
-        client.click(classIcon);
-
-        let canvas = "#div_canvas";
-        client.waitForElementPresent(canvas, 1000, "Checking for canvas...");
-
-        let test_folder = "autotest";
-        let name_field = "#tr_typename > td:nth-child(2) > textarea";
-        let num_elements = 0;
-
-        //BUILD CLASSES
-        let icon_type = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\/IconIcon\\/";
-
-        let start_x = 200;
-        let x_diff = 250;
-        let x_coords = [start_x, start_x + x_diff, start_x + 2 * x_diff];
-
-        let start_y = 150;
-        let y_diff = 180;
-        let y_coords = [start_y, start_y + y_diff, start_y + 2 * y_diff];
-
-        let num_classes = x_coords.length * y_coords.length;
-
-        num_elements = model_building_utils.create_classes(client, x_coords, y_coords, num_elements, icon_type);
-
-        //SET NAMES FOR CLASSES
-        for (let i = 0; i < num_classes; i++) {
-            let class_name = "Class" + String.fromCharCode(65 + i) + "Icon";
-            let attrs = {};
-            attrs[name_field] = class_name;
-            model_building_utils.set_attribs(client, i, attrs, icon_type);
-        }
-
-        // BUILD TEXT FOR ICONS
-        let textIcon = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\.metamodel\\/TextIcon";
-        let textType = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\/TextIcon\\/";
-        let textContent_field = "#tr_textContent > td:nth-child(2) > textarea";
-
-        client.waitForElementPresent(textIcon, 2000, "Check for text icon...");
-        client.click(textIcon);
-
-        for (let i = 0; i < num_classes; i++) {
-
-            let text = "Class" + String.fromCharCode(65 + i);
-
-            let textDiv = model_building_utils.build_div(textType, num_elements);
-            let iconDiv = model_building_utils.build_div(icon_type, i);
-
-            let attrs = {};
-            attrs[textContent_field] = text;
-
-            client
-                .pause(300)
-                .moveToElement(canvas, 20, 200)
-                .mouseButtonClick('right')
-                .pause(500)
-                .waitForElementPresent(textDiv, 500, "Created text: " + textDiv);
-
-            model_building_utils.set_attribs(client, num_elements, attrs, textType);
-
-            num_elements++;
-
-            client.moveToElement(textDiv, 10, 10)
-                .mouseButtonClick('left')
-                .pause(300)
-                .mouseButtonDown('left')
-                .pause(300);
-
-            model_building_utils.move_to_element_ratio(client, iconDiv, 35, 15);
-            client.mouseButtonUp('left');
-
-            model_building_utils.click_off(client);
-
-            //inner link counts as an element
-            num_elements++;
-        }
-
-
-        // BUILD SYMBOLS FOR ICONS
-        let symbols = ["PathIcon", "CircleIcon", "StarIcon", "PolygonIcon", "EllipseIcon", "EllipseIcon", "RectangleIcon", "ImageIcon"];
-        let getIcon = function (type) {
-            return "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\.metamodel\\/" + type;
-        };
-        let getType = function (type) {
-            return "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\/" + type + "\\/";
-        };
-
-        for (let i = 0; i < num_classes; i++) {
-
-            let currSymbol = symbols[i % symbols.length];
-            client.waitForElementPresent(getIcon(currSymbol), 2000, "Check for symbol icon...");
-            client.click(getIcon(currSymbol));
-
-
-            let symbolDiv = model_building_utils.build_div(getType(currSymbol), num_elements);
-            let iconDiv = model_building_utils.build_div(icon_type, i);
-
-
-            client
-                .pause(300)
-                .moveToElement(canvas, 50, 200)
-                .mouseButtonClick('right')
-                .pause(1000)
-                .waitForElementPresent(symbolDiv, 500, "Created symbol: " + symbolDiv);
-
-            model_building_utils.click_off(client);
-
-            num_elements++;
-
-            model_building_utils.move_to_element_ratio(client, symbolDiv, 50, 50);
-            client
-                .mouseButtonClick('left')
-                .pause(300)
-                .mouseButtonDown('left')
-                .pause(300);
-
-            model_building_utils.move_to_element_ratio(client, iconDiv, 50, 55);
-            client.pause(300).mouseButtonUp('left');
-
-            model_building_utils.click_off(client);
-
-            //inner link counts as an element
-            num_elements++;
-        }
-
-        // BUILD LINKS
-        let linkIcon = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\.metamodel\\/LinkIcon";
-        let linkType = "#\\/Formalisms\\/__LanguageSyntax__\\/ConcreteSyntax\\/ConcreteSyntax\\.defaultIcons\\/LinkIcon\\/";
-        let link_typename_field = "#tr_typename > td:nth-child(2) > textarea";
-
-        let link_y_coords = [];
-        let link_x_coords = [start_x + 3 * x_diff, start_x + 4 * x_diff];
-
-        for (let i = 0; i < assocs.length / 2; i++) {
-            link_y_coords.push(start_y + i * y_diff);
-        }
-
-        client.waitForElementPresent(linkIcon, 2000, "Check for link icon...");
-        client.click(linkIcon);
-
-        let num_elements_before = num_elements;
-        model_building_utils.create_classes(client, link_x_coords, link_y_coords, num_elements, linkType);
-
-        //SET NAMES FOR LINKS
-        for (let i = 0; i < assocs.length; i++) {
-            let link_name = assocs[i][2] + "Link";
-            let attrs = {};
-            attrs[link_typename_field] = link_name;
-            model_building_utils.set_attribs(client, num_elements_before + i, attrs, linkType);
-        }
-
-        //remove unneeded elements
-        model_building_utils.delete_element(client, model_building_utils.build_div(icon_type, 4));
-        model_building_utils.delete_element(client, model_building_utils.build_div(linkType, 50));
-
-
-        let folder_name = "autotest";
-        model_building_utils.save_model(client, folder_name, "autotestCS.model");
-
-        model_building_utils.compile_model(client, "CS", folder_name, "autotest.defaultIcons.metamodel");
-
-        client.pause(1000);
-
-    },
-
-    'Create model': function (client) {
-
-        let test_toolbar = '/autotest/autotest.defaultIcons.metamodel';
-        test_utils.load_toolbar(client, [test_toolbar]);
-
-        let class_names = [];
-        for (let i = 0; i < 9; i++) {
-            let class_name = "Class" + String.fromCharCode(65 + i) + "Icon";
-
-            if (class_name == "ClassEIcon") {
-                continue; //skip ClassEIcon
-            }
-            class_names.push(class_name);
-        }
-
-        //BUILD CLASSES
-        let class_icon = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2e metamodel\\2f ";
-        let class_type = "#\\2f autotest\\2f autotest\\2e defaultIcons\\2f ";
-
-        let start_x = 200;
-        let x_diff = 300;
-        let x_coords = [start_x, start_x + x_diff, start_x + 2 * x_diff];
-
-        let start_y = 150;
-        let y_diff = 180;
-        let y_coords = [start_y, start_y + y_diff, start_y + 2 * y_diff];
-
-        let coords = [];
-        for (let x of x_coords) {
-            for (let y of y_coords) {
-                coords.push([x, y]);
-            }
-        }
-
-        let num_elements = 0;
-        let element_map = {};
-
-        for (let i = 0; i < class_names.length; i++) {
-            let class_name = class_names[i];
-            let class_btn = class_icon + class_name;
-
-            client.waitForElementPresent(class_btn, 2000, "Check for class icon: " + class_btn);
-            client.click(class_btn);
-
-            let class_div = class_type + class_name + "\\2f ";
-
-            let built_class_div = model_building_utils.create_class(client, coords[i][0], coords[i][1], num_elements, class_div);
-
-            element_map[class_name] = built_class_div;
-
-            num_elements++;
-
-        }
-
-        model_building_utils.click_off(client);
-
-        // BUILD ASSOCIATIONS
-        for (let assoc of assocs) {
-            let from_class_name = "Class" + String.fromCharCode(65 + assoc[0]) + "Icon";
-            let to_class_name = "Class" + String.fromCharCode(65 + assoc[1]) + "Icon";
-
-            if (from_class_name == "ClassEIcon") {
-                from_class_name = "ClassHIcon";
-            }
-
-            if (to_class_name == "ClassEIcon") {
-                from_class_name = "ClassFIcon";
-            }
-
-            //select the text of the class
-            let text_div = " > text:nth-child(1)";
-            let from_class_div = element_map[from_class_name] + text_div;
-            let to_class_div = element_map[to_class_name] + text_div;
-
-            // console.log(from_class_div);
-            // console.log(to_class_div);
-
-
-            let isContainAssoc = assoc[3];
-            if (!isContainAssoc) {
-                model_building_utils.move_to_element_ratio(client, from_class_div, 20, 50);
-                client.mouseButtonDown('right');
-                model_building_utils.move_to_element_ratio(client, to_class_div, 80, 50);
-                client.mouseButtonUp('right').pause(2000);
-            } else {
-                model_building_utils.move_to_element_ratio(client, to_class_div, 30, 50);
-                client.mouseButtonClick('left').pause(300);
-                client.mouseButtonDown('left');
-                model_building_utils.move_to_element_ratio(client, from_class_div, 50, 120);
-                client.mouseButtonUp('left').pause(300);
-            }
-
-            num_elements++;
-
-            model_building_utils.click_off(client);
-
-        }
-
-        //SCALE AND ROTATE TESTS
-        let scale_element_div = "#\\/autotest\\/autotest\\.defaultIcons\\/ClassDIcon\\/3\\.instance";
-        model_building_utils.move_to_element_ratio(client, scale_element_div, 50, 50);
-        client.mouseButtonClick('left').pause(300);
-        //client.setValue(scale_element_div, client.Keys.CONTROL);
-
-        //TODO: Can't send CONTROL key
-        client.execute(function () {
-            GeometryUtils.showGeometryControlsOverlay();
-        }, [], null);
-
-
-        let resize_btn_div = "#resize_btn";
-        let resizeH_btn_div = "#resizeH_btn";
-        let resizeW_btn_div = "#resizeW_btn";
-        let rotate_btn_div = "#rotate_btn";
-        let ok_btn_div = "#ok_btn";
-
-        model_building_utils.scroll_geometry_element(client, resize_btn_div, 120, 8);
-        model_building_utils.scroll_geometry_element(client, resizeH_btn_div, -120, 4);
-        model_building_utils.scroll_geometry_element(client, resizeW_btn_div, -120, 4);
-        model_building_utils.scroll_geometry_element(client, rotate_btn_div, 120, 8);
-        client.click(ok_btn_div).pause(500);
-
-        model_building_utils.click_off(client);
-
-        //SET ATTRIBUTES
-
-        let IClass = "#\\/autotest\\/autotest\\.defaultIcons\\/ClassIIcon\\/";
-
-        let AAttribs = {};
-        AAttribs['int'] = 123;
-        AAttribs['string'] = "bonjour";
-        AAttribs['float'] = "123.456";
-        AAttribs['boolean'] = false;
-
-        let attribs = {};
-        for (let [key, value] of Object.entries(AAttribs)) {
-            let new_key = "#tr_" + key + " > td:nth-child(2) > textarea:nth-child(1)";
-            attribs[new_key] = value;
-        }
-        //TODO: Set other attribs
-        let div_suffix = " > text";
-        model_building_utils.set_attribs(client, 7, attribs, IClass, div_suffix, [1, 1]);
-
-
-        // VERIFY MODEL
-        let verify_btn = "#\\/Toolbars\\/MainMenu\\/MainMenu\\.buttons\\.model\\/validateM";
-        let dialog_btn = "#dialog_btn";
-
-        client.waitForElementPresent(verify_btn, 2000, "Find verify button")
-            .click(verify_btn)
-            .waitForElementNotPresent(dialog_btn, 2000, "No constraint violation");
-
-        let new_x = start_x + 3 * x_diff;
-        let class_btn = class_icon + "ClassCIcon";
-        let CClass_type = "#\\/autotest\\/autotest\\.defaultIcons\\/ClassCIcon\\/";
-        client.click(class_btn);
-
-        model_building_utils.create_class(client, new_x, start_y, num_elements, CClass_type);
-        model_building_utils.create_class(client, new_x, start_y + y_diff, num_elements, CClass_type);
-
-        client.click(verify_btn)
-            .waitForElementPresent(dialog_btn, 2000, "Constraint violation")
-            .click(dialog_btn).pause(1000);
-
-        model_building_utils.click_off(client);
-
-
-        // SAVE INSTANCE MODEL
-        let folder_name = "autotest";
-        model_building_utils.save_model(client, folder_name, "autotest_instance.model");
-
-        client.pause(1000);
-
-
-    },
+    
 
     after: function (client) {
         client.end();