org.netbeans.jemmy.operators.JTableOperator Java Examples

The following examples show how to use org.netbeans.jemmy.operators.JTableOperator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Property.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Waits for property with given name in specified property sheet.
 * @param propSheetOper PropertySheetOperator where to find property.
 * @param name property display name
 */
private Node.Property waitProperty(final PropertySheetOperator propSheetOper, final String name) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object param) {
                Node.Property property = null;
                JTableOperator table = propSheetOper.tblSheet();
                for(int row=0;row<table.getRowCount();row++) {
                    if(table.getValueAt(row, 1) instanceof Node.Property) {
                        property = (Node.Property)table.getValueAt(row, 1);
                        if(propSheetOper.getComparator().equals(property.getDisplayName(), name)) {
                            return property;
                        }
                    }
                }
                return null;
            }
            public String getDescription() {
                return("Wait property "+name);
            }
        });
        return (Node.Property)waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
}
 
Example #2
Source File: ApplicationActionsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testInvokeWindow() {
    new Action("Window|Other|Application Actions",null).perform();  // NOI18N
    waitAMoment();

    // invoke edit dialog for first action in table
    JTableOperator tableOp = new JTableOperator(getTopComponent());
    tableOp.clickOnCell(1, 1);   // select first row in table

    // invoke edit dialog
    new JButtonOperator(getTopComponent(), "Edit Action").pushNoBlock();  // NOI18N
    waitAMoment();

    
    // closing edit dialog
    new JButtonOperator(new NbDialogOperator("Edit Action Properties"), "OK").pushNoBlock();  // NOI18N
}
 
Example #3
Source File: AntSanityTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that it is possible to add watches.
 */
public void newWatch() throws IllegalAccessException, InvocationTargetException, InvalidExpressionException {
    Node projectNode = new ProjectsTabOperator().getProjectRootNode(DEBUG_TEST_PROJECT_ANT);
    Node testFile = new Node(new SourcePackagesNode(projectNode), "advanced|VariablesTest.java");
    new OpenAction().perform(testFile);
    EditorOperator eo = new EditorOperator("VariablesTest.java");
    eo.setCaretPositionToLine(49);
    new ToggleBreakpointAction().perform();
    MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
    stt.start();
    new DebugJavaFileAction().perform(testFile);
    stt.waitText("Thread main stopped at VariablesTest.java:49");
    stt.stop();
    new ActionNoBlock("Debug|New Watch...", null).perform();
    NbDialogOperator newWatchDialog = new NbDialogOperator("New Watch");
    new JEditorPaneOperator(newWatchDialog, 0).setText("n");
    newWatchDialog.ok();
    TopComponentOperator variablesView = new TopComponentOperator(new ContainerOperator(MainWindowOperator.getDefault(), VIEW_CHOOSER), "Variables");
    JTableOperator variablesTable = new JTableOperator(variablesView);
    assertEquals("n", variablesTable.getValueAt(0, 0).toString());
    org.openide.nodes.Node.Property property = (org.openide.nodes.Node.Property) variablesTable.getValueAt(0, 2);
    assertEquals("50", property.getValue());
    JPopupMenuOperator menu = new JPopupMenuOperator(variablesTable.callPopupOnCell(0, 0));
    menu.pushMenu("Delete All");
}
 
Example #4
Source File: AntSanityTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Evaluates simple expression during debugging session.
 */
public void evaluateExpression() throws IllegalAccessException, InvocationTargetException, InterruptedException, InvalidExpressionException {
    TopComponentOperator variablesView = new TopComponentOperator(new ContainerOperator(MainWindowOperator.getDefault(), VIEW_CHOOSER), "Variables");
    JToggleButtonOperator showEvaluationResultButton = new JToggleButtonOperator(variablesView, 0);
    showEvaluationResultButton.clickMouse();
    TopComponentOperator evaluationResultView = new TopComponentOperator("Evaluation Result");
    new Action("Debug|Evaluate Expression...", null).perform();
    TopComponentOperator expressionEvaluator = new TopComponentOperator("Evaluate Expression");
    JEditorPaneOperator expressionEditor = new JEditorPaneOperator(expressionEvaluator);
    new EventTool().waitNoEvent(1000);
    expressionEditor.setText("\"If n is: \" + n + \", then n + 1 is: \" + (n + 1)");
    JPanel buttonsPanel = (JPanel) expressionEvaluator.getComponent(2);
    JButton expressionEvaluatorButton = (JButton) buttonsPanel.getComponent(1);
    assertEquals("Evaluate code fragment (Ctrl + Enter)", expressionEvaluatorButton.getToolTipText());
    expressionEvaluatorButton.doClick();
    JTableOperator variablesTable = new JTableOperator(evaluationResultView);
    assertValue(variablesTable, 0, 2, "\"If n is: 50, then n + 1 is: 51\"");
    assertEquals("\"If n is: \" + n + \", then n + 1 is: \" + (n + 1)", variablesTable.getValueAt(0, 0).toString().trim());
}
 
Example #5
Source File: ThreadBreakpointsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public void testThreadBreakpointCreation() {        
    //open source
    Node beanNode = new Node(new SourcePackagesNode(Utilities.testProjectName), "examples.advanced|MemoryView.java"); //NOI18N
    new OpenAction().performAPI(beanNode);
    EditorOperator eo = new EditorOperator("MemoryView.java");
    try {
        eo.clickMouse(50,50,1);
    } catch (Throwable t) {
        System.err.println(t.getMessage());
    }
    new NewBreakpointAction().perform();
    NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle);
    setBreakpointType(dialog, "Thread");
    dialog.ok();
    Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
    JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
    assertEquals("Thread breakpoint was not created.", "Thread started", jTableOperator.getValueAt(0, 0).toString());
}
 
Example #6
Source File: AntSanityTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that table contains required value in cell with given coordinates.
 * 
 * @param table Table to be used for the search.
 * @param row Row of the cell.
 * @param column Column of the cell.
 * @param value Value to be searched for.
 */
private void assertValue(JTableOperator table, int row, int column, String value) throws IllegalAccessException, InvocationTargetException, InvalidExpressionException {
    org.openide.nodes.Node.Property property = null;
    for (int i = 0; i < 10; i++) {
        property = (org.openide.nodes.Node.Property) table.getValueAt(row, column);
        if (property != null)
            if (!"Evaluating...".equals(property.getValue())) break;
        new EventTool().waitNoEvent(1000);
    }
    assertNotNull(property);
    if (property.getValue() instanceof ObjectVariable) {
        assertEquals(value, ((ObjectVariable) property.getValue()).getToStringValue());
    } else {
        assertEquals(value, property.getValue().toString());
    }
}
 
Example #7
Source File: JTableMouseDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void editCell(ComponentOperator oper, int row, int column, Object value) {
    JTableOperator toper = (JTableOperator) oper;
    toper.scrollToCell(row, column);
    if (!toper.isEditing()
            || toper.getEditingRow() != row
            || toper.getEditingColumn() != column) {
        clickOnCell((JTableOperator) oper, row, column, 2);
    }
    JTextComponentOperator textoper
            = new JTextComponentOperator((JTextComponent) toper.
                    waitSubComponent(new JTextComponentOperator.JTextComponentFinder()));
    TextDriver text = DriverManager.getTextDriver(JTextComponentOperator.class);
    text.clearText(textoper);
    text.typeText(textoper, value.toString(), 0);
    DriverManager.getKeyDriver(oper).
            pushKey(textoper, KeyEvent.VK_ENTER, 0,
                    oper.getTimeouts().
                    create("ComponentOperator.PushKeyTimeout"));
}
 
Example #8
Source File: FieldBreakpointsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public void testFieldBreakpointCreation() {        
    //open source
    Node beanNode = new Node(new SourcePackagesNode(Utilities.testProjectName), "examples.advanced|MemoryView.java"); //NOI18N
    new OpenAction().performAPI(beanNode);
    EditorOperator eo = new EditorOperator("MemoryView.java");
    try {
        eo.clickMouse(50,50,1);
    } catch (Throwable t) {
        System.err.println(t.getMessage());
    }
    NbDialogOperator dialog = Utilities.newBreakpoint(36, 36);
    setBreakpointType(dialog, "Field");
    new JEditorPaneOperator(dialog, 0).setText("examples.advanced.MemoryView");
    new JEditorPaneOperator(dialog, 1).setText("msgMemory");
    new JComboBoxOperator(dialog, 2).selectItem(Bundle.getString("org.netbeans.modules.debugger.jpda.ui.breakpoints.Bundle", "LBL_Field_Breakpoint_Type_Access"));
    dialog.ok();
    Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
    JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
    assertEquals("Field breakpoint was not created.", "Field MemoryView.msgMemory access", jTableOperator.getValueAt(0, 0).toString());
}
 
Example #9
Source File: ViewsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testViewsHeapWalker1() {        
    EditorOperator eo = new EditorOperator("MemoryView.java");
    new EventTool().waitNoEvent(500);
    Utilities.toggleBreakpoint(eo, 92);
    Utilities.startDebugger();
    Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
    Utilities.showDebuggerView(Utilities.classesViewTitle);
    TopComponentOperator tco = new TopComponentOperator(Utilities.classesViewTitle);
    JTableOperator jTableOperator = new JTableOperator(tco);
    JComboBoxOperator filter = new JComboBoxOperator(tco);
    filter.clearText();
    filter.enterText("example");
    filter.pushKey(KeyEvent.VK_ENTER);
    new EventTool().waitNoEvent(500);
    assertEquals("MemoryView class is not in classes", "examples.advanced.MemoryView", Utilities.removeTags(jTableOperator.getValueAt(0,0).toString()));
    assertEquals("Instances number is wrong", "1 (0%)", Utilities.removeTags(jTableOperator.getValueAt(0,2).toString()));
}
 
Example #10
Source File: ViewsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testViewsHeapWalker2() {
    EditorOperator eo = new EditorOperator("MemoryView.java");
    new EventTool().waitNoEvent(500);
    Utilities.toggleBreakpoint(eo, 92);
    Utilities.startDebugger();
    Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
    Utilities.showDebuggerView(Utilities.classesViewTitle);

    TopComponentOperator tco = new TopComponentOperator(Utilities.classesViewTitle);
    JTableOperator jTableOperator = new JTableOperator(tco);
    JComboBoxOperator filter = new JComboBoxOperator(tco);
    JPopupMenuOperator popup = new JPopupMenuOperator(jTableOperator.callPopupOnCell(0, 0));
    popup.pushMenuNoBlock("Show in Instances View");
    filter.clearText();
    filter.pushKey(KeyEvent.VK_ENTER);
    new EventTool().waitNoEvent(500);
}
 
Example #11
Source File: ViewsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testViewsSessions() {            
    EditorOperator eo = new EditorOperator("MemoryView.java");
    new EventTool().waitNoEvent(500);
    Utilities.toggleBreakpoint(eo, 92);
    Utilities.startDebugger();
    Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
    Utilities.showDebuggerView(Utilities.sessionsViewTitle);
    JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.sessionsViewTitle));
    assertEquals("examples.advanced.MemoryView", Utilities.removeTags(jTableOperator.getValueAt(0,0).toString()));
    try {
        org.openide.nodes.Node.Property property = (org.openide.nodes.Node.Property)jTableOperator.getValueAt(0,1);
        assertEquals("Stopped", Utilities.removeTags(property.getValue().toString()));
        property = (org.openide.nodes.Node.Property)jTableOperator.getValueAt(0,2);
        assertEquals("org.netbeans.api.debugger.Session localhost:examples.advanced.MemoryView", Utilities.removeTags(property.getValue().toString()));
    } catch (Exception ex) {
        ex.printStackTrace();
        assertTrue(ex.getClass()+": "+ex.getMessage(), false);
    }
}
 
Example #12
Source File: ViewsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testViewsSources() {        
    EditorOperator eo = new EditorOperator("MemoryView.java");
    new EventTool().waitNoEvent(500);
    Utilities.toggleBreakpoint(eo, 92);
    Utilities.startDebugger();
    Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
    Utilities.showDebuggerView(Utilities.sourcesViewTitle);
    JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.sourcesViewTitle));
    String debugAppSource = "debugTestProject" + java.io.File.separator + "src (Project debugTestProject)";
    boolean jdk = false, project = false;
    for (int i=0;i < jTableOperator.getRowCount();i++) {
        String src = Utilities.removeTags(jTableOperator.getValueAt(i,0).toString());
        if (src.endsWith("src.zip")) {
            jdk=true;
        } else if (src.endsWith(debugAppSource)) {
            project = true;
        }
    }
    assertTrue("JDK source root is not shown in threads view", jdk);
    assertTrue("MemoryView source root is not shown in threads view", project);
}
 
Example #13
Source File: MethodBreakpointsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public void testMethodBreakpointCreation() {                
    EditorOperator eo = new EditorOperator("MemoryView.java");
    try {
        eo.clickMouse(50,50,1);
    } catch (Throwable t) {
        System.err.println(t.getMessage());
    }
    NbDialogOperator dialog = Utilities.newBreakpoint(92);
    setBreakpointType(dialog, "Method");
    new JEditorPaneOperator(dialog, 0).setText("examples.advanced.MemoryView");
    new JEditorPaneOperator(dialog, 1).setText("updateStatus()");
    dialog.ok();
    Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
    JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
    assertEquals("Method MemoryView.updateStatus", jTableOperator.getValueAt(0, 0).toString());
}
 
Example #14
Source File: KeyMapOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public boolean unassignAlternativeShortcutToAction(String actionName, String shortcutStr) {
    System.out.println("[TEST_DEBUG]");
    System.out.println("[TEST_DEBUG] ### Unassigning alternative shortcut for " + actionName + " - Started");
    String tmpStr = actionSearchByName().getText();
    searchActionName(actionName);
    JTableOperator tab = actionsTable();
    TableModel tm = tab.getModel();
    String _str;
    System.out.println("[TEST_DEBUG]  Found " + tab.getRowCount() + " actions matching action pattern: " + actionName);
    for (int i = 0; i < tab.getRowCount(); i++) {
        _str = tm.getValueAt(i, 0).toString();
        System.out.println("[TEST_DEBUG]  Examining action " + _str + ", which is no. " + (i + 1) + "in the table...");
        if (_str.toLowerCase().startsWith(actionName.toLowerCase()) && tm.getValueAt(i, 1).toString().toLowerCase().equals(shortcutStr.toLowerCase())) {
            System.out.println("[TEST_DEBUG]  Action " + actionName + "was found");
            JListOperator jli = clickShortcutEllipsisButton(tab, i);
            jli.clickOnItem("Clear");
            sleep(100);
            System.out.println("[TEST_DEBUG] ### Unassigning alternative shortcut for " + actionName + " - OK");
            break;
        }
    }
    searchActionName(tmpStr);
    return true;
}
 
Example #15
Source File: AntSanityTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Sets line 280 breakpoint, disables it and then continues to run to cursor
 * at line 283.
 */
public void runToCursor() {
    EditorOperator eo = new EditorOperator("MemoryView.java");
    eo.setCaretPositionToLine(280);
    new ToggleBreakpointAction().perform();
    JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(BREAKPOINTS_VIEW));
    jTableOperator.waitCell("Line MemoryView.java:280", 1, 0);
    new JPopupMenuOperator(jTableOperator.callPopupOnCell(1, 0)).pushMenu("Disable");
    MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
    stt.start();
    eo.makeComponentVisible();
    eo.setCaretPositionToLine(283);
    new RunToCursorAction().perform();
    stt.waitText("Thread main stopped at MemoryView.java:283.");
    stt.stop();
    assertEquals(new EditorOperator("MemoryView.java").getLineNumber(), 283);
}
 
Example #16
Source File: SessionsOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Calls Make Current popup on given session. It throws TimeoutExpiredException
 * if session with given name not found.
 *
 * @param sessionName display name of session
 */
public void makeCurrent(final String sessionName) {
    final JTableOperator table = new JTableOperator(this);
    table.waitState(new ComponentChooser() {
        @Override
        public boolean checkComponent(Component comp) {
            for (int i = 0; i < table.getRowCount(); i++) {
                String text = table.getValueAt(i, 0).toString();
                if (table.getComparator().equals(text, sessionName)) {
                    table.clickOnCell(i, 0, 2);
                    return true;
                }
            }
            return false;
        }

        @Override
        public String getDescription() {
            return "Session " + sessionName + " in table of sessions";
        }
    });
}
 
Example #17
Source File: Property.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Waits for index-th property in specified property sheet.
 * @param propSheetOper PropertySheetOperator where to find property.
 * @param index index (row number) of property inside property sheet
 *              (starts at 0). If there are categories shown in property sheet,
 *              rows occupied by their names must by added to index.
 */
private Node.Property waitProperty(final PropertySheetOperator propSheetOper, final int index) {
    try {
        Waiter waiter = new Waiter(new Waitable() {
            public Object actionProduced(Object param) {
                JTableOperator table = propSheetOper.tblSheet();
                if(table.getRowCount() <= index) {
                    // If table is empty or index out of bounds, 
                    // it returns null to wait until table is populated by values
                    return null;
                }
                Object property = table.getValueAt(index, 1);
                if(property instanceof Node.Property) {
                    return (Node.Property)property;
                } else {
                    throw new JemmyException("On row "+index+" in table there is no property");
                }
            }
            public String getDescription() {
                return("Wait property on row "+index+" in property sheet.");
            }
        });
        //waiter.setOutput(TestOut.getNullOutput());
        return (Node.Property)waiter.waitAction(null);
    } catch (InterruptedException e) {
        throw new JemmyException("Interrupted.", e);
    }
}
 
Example #18
Source File: AddMethodTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void fillParameters(NbDialogOperator dialog) {
    if (parameters != null) {
        new JTabbedPaneOperator(dialog).selectPage("Parameters");
        JTableOperator operator = new JTableOperator(dialog);

        for (int i = 0; i < parameters.length; i++) {
            new JButtonOperator(dialog, "Add").push();
            int rowCount = operator.getRowCount();
            // use setValueAt for combo box because changeCellObject may accidentally close dialog
            operator.setValueAt(parameters[i][0], rowCount - 1, 1);
            // use changeCellObject for text field to confirm changes
            operator.changeCellObject(rowCount - 1, 0, parameters[i][1]);
        }
    }
}
 
Example #19
Source File: WsValidation.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void removeHandlers(NbDialogOperator ndo, String[] handlers) {
    //Confirm Handler Configuration Change
    String changeTitle = Bundle.getStringTrimmed("org.netbeans.modules.websvc.spi.support.Bundle", "TTL_CONFIRM_DELETE");
    JTableOperator jto = new JTableOperator(ndo);
    for (int i = 0; i < handlers.length; i++) {
        jto.selectCell(jto.findCellRow(handlers[i]), jto.findCellColumn(handlers[i]));
        //Remove
        new JButtonOperator(ndo, "Remove").pushNoBlock();
        new NbDialogOperator(changeTitle).yes();
    }
}
 
Example #20
Source File: AbbreviationsAddRemovePerformer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testAllAbbrev() throws Exception {
    Abbreviations abbrevs = Abbreviations.invoke("Java");
    JTableOperator templateTable = abbrevs.getTemplateTable();
    TableModel model = templateTable.getModel();        
    for (int i = 0; i < model.getRowCount(); i++) {
        String abb = model.getValueAt(i, 0).toString();
        String exp = model.getValueAt(i, 1).toString();
        getRef().println(abb);
        getRef().println(exp);
    }
    abbrevs.ok();
}
 
Example #21
Source File: KeyMapOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean assignAlternativeShortcutToAction(String actionName, boolean ctrl, boolean shift, boolean alt, int Key, boolean expectedAlreadyAssigned, boolean reassign) {
    boolean retval = false;
    System.out.println("[TEST_DEBUG]");
    System.out.println("[TEST_DEBUG] ### Assigning alternative shortcut for " + actionName + " - Started");
    int mask = buildKeyModifierMask(ctrl, alt, shift);
    String tmpStr = actionSearchByName().getText();
    searchActionName(actionName);
    JTableOperator tab = actionsTable();
    TableModel tm = tab.getModel();
    String _str;
    System.out.println("[TEST_DEBUG]  Found " + tab.getRowCount() + " actions matching action pattern: " + actionName);
    for (int i = 0; i < tab.getRowCount(); i++) {
        _str = tm.getValueAt(i, 0).toString();
        System.out.println("[TEST_DEBUG]  Examining action " + _str + ", which is no. " + (i + 1) + "in the table...");
        if (_str.toLowerCase().equals(actionName.toLowerCase())) {
            System.out.println("[TEST_DEBUG]  Action " + actionName + "was found");
            JListOperator jli = clickShortcutEllipsisButton(tab, i);
            retval = true;
            try {
                jli.clickOnItem("Add Alternative");
            } catch (Exception e) {
                retval = false;
            }
            sleep(100);
            injectKeyBinding(tab, Key, mask);
            if (expectedAlreadyAssigned) {
                if (reassign) {
                    new NbDialogOperator("Conflicting Shortcut Dialog").yes();
                } else {
                    new NbDialogOperator("Conflicting Shortcut Dialog").cancel();
                }
            }
            sleep(100);
            System.out.println("[TEST_DEBUG] ### Assigning alternative shortcut for " + actionName + " - OK");
            break;
        }
    }
    searchActionName(tmpStr);
    return retval;
}
 
Example #22
Source File: JTableMouseDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Clicks on JTable cell.
 *
 * @param oper Table operator.
 * @param row Cell row index.
 * @param column Cell column index.
 * @param clickCount Count to click.
 */
protected void clickOnCell(final JTableOperator oper, final int row, final int column, final int clickCount) {
    queueTool.invokeSmoothly(new QueueTool.QueueAction<Void>("Path selecting") {
        @Override
        public Void launch() {
            Point point = oper.getPointToClick(row, column);
            DriverManager.getMouseDriver(oper).
                    clickMouse(oper, point.x, point.y, clickCount,
                            Operator.getDefaultMouseButton(),
                            0,
                            oper.getTimeouts().create("ComponentOperator.MouseClickTimeout"));
            return null;
        }
    });
}
 
Example #23
Source File: EditorWindowOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Pushes down arrow control button in top right corner intended to 
 * show list of opened documents and selects document with given name
 * in the list.
 */
public static void selectDocument(String name) {
    btDown().push();
    JTableOperator tableOper = new JTableOperator(MainWindowOperator.getDefault());
    int row = tableOper.findCellRow(name);
    if (row > -1) {
        tableOper.selectCell(row, 0);
    } else {
        throw new JemmyException("Cannot select document \"" + name + "\".");
    }
}
 
Example #24
Source File: KeyMapOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public boolean assignShortcutToAction(String actionName, boolean ctrl, boolean shift, boolean alt, int Key, boolean expectedAlreadyAssigned, boolean reassign) {
    System.out.println("[TEST_DEBUG]");
    System.out.println("[TEST_DEBUG] ### Reassigning shortcut for " + actionName + " - Started");
    int mask = buildKeyModifierMask(ctrl, alt, shift);
    String tmpStr = actionSearchByName().getText();
    searchActionName(actionName);
    JTableOperator tab = actionsTable();
    TableModel tm = tab.getModel();
    String _str;
    System.out.println("[TEST_DEBUG]  Found " + tab.getRowCount() + " actions matching action pattern: " + actionName);
    for (int i = 0; i < tab.getRowCount(); i++) {
        _str = tm.getValueAt(i, 0).toString();
        System.out.println("[TEST_DEBUG]  Examining action \"" + _str + "\", which is no. " + (i + 1) + " in the table...");
        if (_str.toLowerCase().equals(actionName.toLowerCase())) {
            System.out.println("[TEST_DEBUG]  -> action \"" + _str + "\" (" + actionName + ") was found");
            sleep(100);
            tab.clickForEdit(i, 1);
            sleep(100);
            injectKeyBinding(tab, Key, mask);
            if (expectedAlreadyAssigned) {
                if (reassign) {
                    new NbDialogOperator("Conflicting Shortcut Dialog").yes();
                } else {
                    new NbDialogOperator("Conflicting Shortcut Dialog").cancel();
                }
            }
            sleep(100);
            break;
        }
    }
    searchActionName(tmpStr);
    System.out.println("[TEST_DEBUG] ### Reassigning shortcut for " + actionName + " - OK");
    return true;
}
 
Example #25
Source File: PluginsOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Selects plugins in the table.
 * @param pluginNames array of plugin names to be selected
 */
public void selectPlugins(String[] pluginNames) {
    JTableOperator tableOper = table();
    for (int i = 0; i < pluginNames.length; i++) {
        String name = pluginNames[i];
        int row = tableOper.findCellRow(name, new DefaultStringComparator(true, true), 1, 0);
        if(row == -1) {
            throw new JemmyException("Plugin "+name+" not found.");
        }
        tableOper.selectCell(row, 1);
        tableOper.clickOnCell(row, 0);
    }
}
 
Example #26
Source File: Property.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public int getRow() {
    JTableOperator table = this.propertySheetOper.tblSheet();
    for(int row=0;row<table.getRowCount();row++) {
        if(table.getValueAt(row, 1) instanceof Node.Property) {
            if(this.property == (Node.Property)table.getValueAt(row, 1)) {
                return row;
            }
        }
    }
    throw new JemmyException("Cannot determine row number of property \""+getName()+"\"");
}
 
Example #27
Source File: Property.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Opens custom property editor for the property by click on "..." button.
 * It checks whether this property supports custom editor by method
 * {@link #supportsCustomEditor}.
 */
public void openEditor() {
    final JTableOperator table = propertySheetOper.tblSheet();
    // Need to request focus before selection because invokeCustomEditor action works
    // only when table is focused
    table.makeComponentVisible();
    table.requestFocus();
    table.waitHasFocus();
    // run action in a separate thread in AWT (no block)
    new Thread(new Runnable() {

        @Override
        public void run() {
            new QueueTool().invokeSmoothly(new Runnable() {

                @Override
                public void run() {
                    // need to select property first
                    ((javax.swing.JTable) table.getSource()).changeSelection(getRow(), 0, false, false);
                    if (supportsCustomEditor()) {
                        // find action
                        Action customEditorAction = ((JComponent) table.getSource()).getActionMap().get("invokeCustomEditor");  // NOI18N
                        customEditorAction.actionPerformed(new ActionEvent(table.getSource(), 0, null));
                    }
                }
            });
        }
    }, "Thread to open custom editor no block").start(); // NOI18N
}
 
Example #28
Source File: ProfilerValidationTest.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test Profiler options.
 */
public void testOptions() {
    OptionsOperator options = OptionsOperator.invoke();
    options.selectJava();
    JTabbedPaneOperator tabbedPane = new JTabbedPaneOperator(options);
    tabbedPane.selectPage("Profiler");
    JListOperator categoriesOper = new JListOperator(options);
    // General category
    assertEquals("Wrong profiling port.", 5140, new JSpinnerOperator(options).getValue());
    // manage calibration data
    new JButtonOperator(options, "Manage").pushNoBlock();
    NbDialogOperator manageOper = new NbDialogOperator("Manage Calibration data");
    JTableOperator platformsOper = new JTableOperator(manageOper);
    platformsOper.selectCell(0, 0);
    new JButtonOperator(manageOper, "Calibrate").pushNoBlock();
    new NbDialogOperator("Information").ok();
    manageOper.closeByButton();
    // reset
    new JButtonOperator(options, "Reset").push();
    // Snapshots category
    categoriesOper.selectItem("Snapshots");
    JLabelOperator lblSnapshotOper = new JLabelOperator(options, "When taking snapshot:");
    assertEquals("Wrong value for " + lblSnapshotOper.getText(), "Open snapshot", new JComboBoxOperator((JComboBox) lblSnapshotOper.getLabelFor()).getSelectedItem());
    JLabelOperator lblOpenOper = new JLabelOperator(options, "Open automatically:");
    assertEquals("Wrong value for " + lblOpenOper.getText(), "On first saved snapshot", new JComboBoxOperator((JComboBox) lblOpenOper.getLabelFor()).getSelectedItem());
    // Engine category
    categoriesOper.selectItem("Engine");
    JLabelOperator lblSamplingOper = new JLabelOperator(options, "Sampling frequency");
    assertEquals("Wrong value for " + lblSamplingOper.getText(), 10, new JSpinnerOperator((JSpinner) lblSamplingOper.getLabelFor()).getValue());
    options.cancel();
}
 
Example #29
Source File: ProfilerValidationTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Test Profiler options.
 */
public void testOptions() {
    OptionsOperator options = OptionsOperator.invoke();
    options.selectJava();
    JTabbedPaneOperator tabbedPane = new JTabbedPaneOperator(options);
    tabbedPane.selectPage("Profiler");
    JListOperator categoriesOper = new JListOperator(options);
    // General category
    assertEquals("Wrong profiling port.", 5140, new JSpinnerOperator(options).getValue());
    // manage calibration data
    new JButtonOperator(options, "Manage").pushNoBlock();
    NbDialogOperator manageOper = new NbDialogOperator("Manage Calibration data");
    JTableOperator platformsOper = new JTableOperator(manageOper);
    platformsOper.selectCell(0, 0);
    new JButtonOperator(manageOper, "Calibrate").pushNoBlock();
    new NbDialogOperator("Information").ok();
    manageOper.closeByButton();
    // reset
    new JButtonOperator(options, "Reset").push();
    // Snapshots category
    categoriesOper.selectItem("Snapshots");
    JLabelOperator lblSnapshotOper = new JLabelOperator(options, "When taking snapshot:");
    assertEquals("Wrong value for " + lblSnapshotOper.getText(), "Open snapshot", new JComboBoxOperator((JComboBox) lblSnapshotOper.getLabelFor()).getSelectedItem());
    JLabelOperator lblOpenOper = new JLabelOperator(options, "Open automatically:");
    assertEquals("Wrong value for " + lblOpenOper.getText(), "On first saved snapshot", new JComboBoxOperator((JComboBox) lblOpenOper.getLabelFor()).getSelectedItem());
    // Engine category
    categoriesOper.selectItem("Engine");
    JLabelOperator lblSamplingOper = new JLabelOperator(options, "Sampling frequency");
    assertEquals("Wrong value for " + lblSamplingOper.getText(), 10, new JSpinnerOperator((JSpinner) lblSamplingOper.getLabelFor()).getValue());
    options.cancel();
}
 
Example #30
Source File: Autoupdate.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void CheckDownloaded( )
{
  startTest( );

  // Open
  new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenuNoBlock("Tools|Plugins");

  JDialogOperator jdPlugins = new JDialogOperator( "Plugins" );

  JTabbedPaneOperator jtTabs = new JTabbedPaneOperator( jdPlugins, 0 );
  jtTabs.setSelectedIndex( jtTabs.findPage( "Downloaded" ) );

  // Check buttons
  JButtonOperator jbAdd = new JButtonOperator( jdPlugins, "Add Plugins..." );
  JButtonOperator jbInstall = new JButtonOperator( jdPlugins, "Install" );

  // Check table
  JTableOperator jtTable = new JTableOperator( jdPlugins, 0 );
  int iOriginalRows = jtTable.getRowCount( );

  // Close by button
  JButtonOperator jbClose = new JButtonOperator( jdPlugins, "Close" );
  jbClose.push( );
  jdPlugins.waitClosed( );

  endTest( );
}