public void testLinkWithEditorForNewlyFormalizedComponent() {
    Component_c component =
        Component_c.ComponentInstance(
            modelRoot,
            new ClassQueryInterface_c() {

              public boolean evaluate(Object candidate) {
                return ((Component_c) candidate).getName().equals(testDomain.getName());
              }
            });
    assertNotNull(component);
    m_bp_tree.collapseAll();
    if (!component.Isformal()) formalizeComponent(component);
    waitForTransaction();
    m_bp_view.setLinkWithEditor(true);
    ExternalEntityPackage_c eepkg = ExternalEntityPackage_c.getOneS_EEPKOnR36(testDomain);
    Selection.getInstance().clear();
    Selection.getInstance().addToSelection(eepkg);
    m_bp_view.setFocus();
    m_bp_tree.refresh();
    while (PlatformUI.getWorkbench().getDisplay().readAndDispatch()) ;
    Object[] elementsAfterSelection = m_bp_tree.getExpandedElements();
    boolean result = false;
    for (int i = 0; i < elementsAfterSelection.length; i++) {
      if (elementsAfterSelection[i].equals(component)) {
        result = true;
      }
    }
    assertTrue(
        "The tree was not expanded for formal component children when link with editor was set.",
        result);
  }
  public static boolean enableDelete(IStructuredSelection graphicalSelection) {

    boolean enableDel = false;
    List<Object> elements = new ArrayList<Object>();
    IStructuredSelection selection = Selection.getInstance().getStructuredSelection();

    if (!selection.isEmpty()) {
      if (graphicalSelection.getFirstElement() instanceof DiagramEditPart) return false;
      enableDel = true;
      // Iterate through removing elements that are only graphical
      for (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {
        Object current = iter.next();
        if (current instanceof GraphicalElement_c) {
          GraphicalElement_c ge = (GraphicalElement_c) current;
          if (ge.getRepresents() == null) {
            elements.add(current);
            Selection.getInstance().removeFromSelection(ge);
          }
        }
      }
    }

    selection = Selection.getInstance().getStructuredSelection();
    if (!selection.isEmpty()) {
      // Check the remaining items against the usual DeleteAction,
      enableDel = DeleteAction.canDeleteAction();
    }

    // Add the graphical only elements back to the selection
    for (int i = 0; i < elements.size(); ++i) {
      Selection.getInstance().addToSelection(elements.get(i));
    }

    return enableDel;
  }
Ejemplo n.º 3
0
 /** Creates a new domain with the given name, for the given system. */
 public static void createNewModel(String domainName, SystemModel_c sys) {
   NewDomainWizard ndw = new NewDomainWizard();
   Selection.getInstance().clear();
   Selection.getInstance().addToSelection(sys);
   ndw.init(null, Selection.getInstance().getStructuredSelection());
   ndw.addPages();
   WizardDialog dialog =
       new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), ndw);
   dialog.create();
   WizardNewDomainCreationPage wndcp = (WizardNewDomainCreationPage) ndw.getStartingPage();
   wndcp.setDomainNameFieldValue(domainName);
   wndcp.setUseTemplate(false);
   ndw.setContainer(null);
   ndw.performFinish();
 }
  public void testSendInterfaceOperationWithReturnOutOfLongDele() {
    ModelRoot[] roots = Ooaofooa.getInstancesUnderSystem(projectName);
    Function_c testFunc = null;
    for (int i = 0; i < roots.length; i++) {
      testFunc = Function_c.FunctionInstance(roots[i], new Function_by_name_c("LongDelegation"));
      if (testFunc != null) {
        break;
      }
    }
    assertNotNull(testFunc);

    Selection.getInstance().setSelection(new StructuredSelection(m_sys));
    runVerifier();

    BPDebugUtils.executeElement(testFunc);

    DebugUITestUtilities.waitForExecution();

    DebugUITestUtilities.waitForBPThreads(m_sys);
    DebugUITestUtilities.waitForExecution();

    String expectedConsoleText =
        "User invoked function: LongDelegation"
            + "\r\nLogSuccess:  TestDriverComponent has consumed the messsage as expected"
            + "\r\nLogSuccess:  Correct return value from delegated message\r\n";
    String actualConsoleText = DebugUITestUtilities.getConsoleText("null");
    assertEquals(expectedConsoleText, actualConsoleText);
  }
 private void setAndConfirmBreakpoint(NonRootModelElement st) {
   Selection.getInstance().setSelection(new StructuredSelection(st));
   ActivityEditor editor = DebugUITestUtilities.openActivityEditorForSelectedElement();
   editor.setFocus();
   DebugUITestUtilities.setBreakpointAtLine(editor, 2);
   IBreakpointManager bpm = DebugPlugin.getDefault().getBreakpointManager();
   IBreakpoint[] bps = bpm.getBreakpoints();
   assertTrue("Breakpoint not set", bps.length == 1);
 }
  public void testSendInterfaceSignalOverDele() {
    ModelRoot root = Ooaofooa.getInstance("/Delegation/models/Delegation/System/System.xtuml");
    Function_c testFunc = Function_c.FunctionInstance(root, new Function_by_name_c("sendSignal"));
    assertNotNull(testFunc);

    Selection.getInstance().setSelection(new StructuredSelection(m_sys));
    runVerifier();

    BPDebugUtils.executeElement(testFunc);

    DebugUITestUtilities.waitForExecution();

    DebugUITestUtilities.waitForBPThreads(m_sys);
    DebugUITestUtilities.waitForExecution();

    String expectedConsoleText =
        "User invoked function: sendSignal\r\nLogSuccess:  LevelOneDelegationComponent has consumed the messsage as expected\r\nLogSuccess:  LevelTwoDelegationComponent has consumed the messsage as expected\r\n";
    String actualConsoleText = DebugUITestUtilities.getConsoleText("null");
    assertEquals(expectedConsoleText, actualConsoleText);
  }
  private void runVerifier() {
    Package_c[] pkgs = Package_c.getManyEP_PKGsOnR1401(m_sys);
    NonRootModelElement[] selectedElement = null;
    NonRootModelElement[] compRefs = null;
    NonRootModelElement[] components = null;
    for (Package_c pkg : pkgs) {
      if (pkg.getName().equalsIgnoreCase("system")) {
        components = Component_c.getManyC_CsOnR8001(PackageableElement_c.getManyPE_PEsOnR8000(pkg));
        assertNotNull(components);
        compRefs =
            ComponentReference_c.getManyCL_ICsOnR8001(
                PackageableElement_c.getManyPE_PEsOnR8000(pkg));
        assertNotNull(compRefs);
        selectedElement = new NonRootModelElement[components.length + compRefs.length];
        System.arraycopy(components, 0, selectedElement, 0, components.length);
        System.arraycopy(compRefs, 0, selectedElement, components.length, compRefs.length);
      }
    }
    openPerspectiveAndView(
        "com.mentor.nucleus.bp.debug.ui.DebugPerspective",
        BridgePointPerspective.ID_MGC_BP_EXPLORER);
    Selection.getInstance().setSelection(new StructuredSelection(components));
    Menu menu = m_bp_tree.getControl().getMenu();
    assertTrue(
        "The Launch Verifier action was not present for a component.",
        UITestingUtilities.checkItemStatusInContextMenu(menu, "Launch Verifier", "", false));
    MenuItem launchVerifierItem = DebugUITestUtilities.getLaunchVerifierItem(menu);
    assertNotNull(launchVerifierItem);
    ComponentInstance_c[] engines =
        ComponentInstance_c.ComponentInstanceInstances(components[0].getModelRoot());
    assertTrue(
        "Unexpected test state, there should be no Component Instances.", engines.length == 0);
    TestUtil.debugToDialog(200);
    launchVerifierItem.notifyListeners(SWT.Selection, null);
    TestingUtilities.processDisplayEvents();

    menu = m_bp_tree.getControl().getMenu();
    assertFalse(
        "The Launch Verifier action was present for an unassigned imported component.",
        UITestingUtilities.menuItemExists(menu, "", "Launch Verifier"));
  }
  public void testSendInterfaceOperationWithReturnOverLongDele() {
    ModelRoot root = Ooaofooa.getInstance("/Delegation/models/Delegation/System/System.xtuml");
    Function_c testFunc =
        Function_c.FunctionInstance(root, new Function_by_name_c("longdelegationWithReturn"));
    assertNotNull(testFunc);

    Selection.getInstance().setSelection(new StructuredSelection(m_sys));
    runVerifier();

    BPDebugUtils.executeElement(testFunc);

    DebugUITestUtilities.waitForExecution();

    DebugUITestUtilities.waitForBPThreads(m_sys);
    DebugUITestUtilities.waitForExecution();

    String expectedConsoleText =
        "User invoked function: longdelegationWithReturn"
            + "\r\nLogSuccess:  FourOfFourDelegation has consumed the messsage as expected"
            + "\r\nLogSuccess:  Correct return value from delegated message\r\n";
    String actualConsoleText = DebugUITestUtilities.getConsoleText("null");
    assertEquals(expectedConsoleText, actualConsoleText);
  }
  private void checkTransitionActionBreakPoint(final String transName, String expResultFile) {
    Package_c cp =
        Package_c.getOneEP_PKGOnR1405(
            m_sys,
            new ClassQueryInterface_c() {

              @Override
              public boolean evaluate(Object candidate) {
                return ((Package_c) candidate).getName().equals("Components");
              }
            });
    assertNotNull(cp);

    Component_c component =
        Component_c.getOneC_COnR8001(
            PackageableElement_c.getManyPE_PEsOnR8000(cp),
            new ClassQueryInterface_c() {

              @Override
              public boolean evaluate(Object candidate) {
                return ((Component_c) candidate).getName().equals("TransitionActionTestGlobals");
              }
            });
    assertNotNull(component);

    // launch the component
    DebugUITestUtilities.setLogActivityAndLaunchForElement(
        component, m_bp_tree.getControl().getMenu(), m_sys.getName());
    // select the transition to be tested
    Transition_c trans =
        Transition_c.TransitionInstance(
            component.getModelRoot(),
            new ClassQueryInterface_c() {
              public boolean evaluate(Object candidate) {
                return ((Transition_c) candidate).Get_name().contains(transName);
              }
            });
    assertNotNull(trans);
    Selection.getInstance().clear();
    Selection.getInstance().addToSelection(trans);
    // set a breakpoint at line 2
    ActivityEditor editor = DebugUITestUtilities.openActivityEditorForSelectedElement();

    DebugUITestUtilities.setBreakpointAtLine(editor, 2);

    Function_c setup =
        Function_c.getOneS_SYNCOnR8001(
            PackageableElement_c.getManyPE_PEsOnR8000(
                Package_c.getManyEP_PKGsOnR8001(
                    PackageableElement_c.getManyPE_PEsOnR8003(component))),
            new ClassQueryInterface_c() {

              public boolean evaluate(Object candidate) {
                return ((Function_c) candidate).getName().equals("setup");
              }
            });
    assertNotNull(setup);

    openPerspectiveAndView(
        "com.mentor.nucleus.bp.debug.ui.DebugPerspective",
        BridgePointPerspective.ID_MGC_BP_EXPLORER);

    BPDebugUtils.executeElement(setup);

    DebugUITestUtilities.waitForExecution();

    Function_c test =
        Function_c.getOneS_SYNCOnR8001(
            PackageableElement_c.getManyPE_PEsOnR8000(
                Package_c.getManyEP_PKGsOnR8001(
                    PackageableElement_c.getManyPE_PEsOnR8003(component))),
            new ClassQueryInterface_c() {

              public boolean evaluate(Object candidate) {
                return ((Function_c) candidate).getName().equals("test");
              }
            });
    assertNotNull(test);

    BPDebugUtils.executeElement(test);

    DebugUITestUtilities.waitForExecution();

    ComponentInstance_c engine = ComponentInstance_c.getOneI_EXEOnR2955(component);
    assertNotNull(engine);

    // wait for the execution to complete
    DebugUITestUtilities.waitForBPThreads(m_sys);

    // compare the trace
    File expectedResults =
        new File(m_workspace_path + "expected_results/verifier/" + expResultFile);
    String expected_results = TestUtil.getTextFileContents(expectedResults);
    // get the text representation of the debug tree
    String actual_results = DebugUITestUtilities.getConsoleText(expected_results);
    assertEquals(expected_results, actual_results);
  }