Java Code Examples for org.netbeans.jemmy.operators.JTableOperator#getRowCount()

The following examples show how to use org.netbeans.jemmy.operators.JTableOperator#getRowCount() . 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: 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 2
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 3
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 4
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void deleteAllBreakpoints() {
    showDebuggerView(breakpointsViewTitle);
    JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(breakpointsViewTitle));
    if (jTableOperator.getRowCount() > 0) {
        new JPopupMenuOperator(jTableOperator.callPopupOnCell(0, 0)).pushMenu(Bundle.getString("org.netbeans.modules.debugger.ui.models.Bundle", "CTL_BreakpointAction_DeleteAll_Label"));
    }
}
 
Example 5
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void deleteAllWatches() {
    showDebuggerView(watchesViewTitle);
    JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(watchesViewTitle));
    if (jTableOperator.getRowCount() > 0) {
        new JPopupMenuOperator(jTableOperator.callPopupOnCell(0, 0)).pushMenu(Bundle.getString("org.netbeans.modules.debugger.ui.models.Bundle", "CTL_WatchAction_DeleteAll"));
    }
}
 
Example 6
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void endAllSessions() {
    showDebuggerView(sessionsViewTitle);
    JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(sessionsViewTitle));
    if (jTableOperator.getRowCount() > 0) {
        new JPopupMenuOperator(jTableOperator.callPopupOnCell(0, 0)).pushMenu(Bundle.getString("org.netbeans.modules.debugger.ui.models.Bundle", "CTL_SessionAction_FinishAll_Label"));
    }
}
 
Example 7
Source File: CodeTemplatesOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public List<String[]> dumpTemplatesTable() {
    List<String[]> res = new LinkedList<>();
    JTableOperator tableOperator = getTemplatesTable();
    for (int i = 0; i < tableOperator.getRowCount(); i++) {
        String[] items = new String[3];
        for (int j = 0; j < 3; j++) {
            items[j] = (String) tableOperator.getValueAt(i, j);
        }
        res.add(items);
    }
    return res;
}
 
Example 8
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( );
}
 
Example 9
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 10
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 11
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 12
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 13
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 14
Source File: Autoupdate.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void CheckInstalled( )
{
  startTest( );

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

  JDialogOperator jdPlugins = new JDialogOperator( "Plugins" );

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

  // HERE THE TESTS

  // Click reload and wait results
  JButtonOperator jbReload = new JButtonOperator( jdPlugins, "Reload Catalog" );
  jbReload.push( );
  Sleep( 5000 );
  boolean bRedo = true;
  int iCount = 0;
  while( bRedo )
  {
    try
    {
      Sleep( 1000 );
      new JLabelOperator( jdPlugins, "Checking for updates in " );
      if( 60 <= ++iCount )
        fail( "Reloading is too long." );
    }
    catch( JemmyException ex )
    {
      bRedo = false;
    }
  }

  // Check buttons
  JButtonOperator jbUninstall = new JButtonOperator( jdPlugins, "Uninstall" );

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

  for( int i = 0; i < 10; i++ )
  {
    // Check uninstall disabled
    if( jbUninstall.isEnabled( ) )
      fail( "Uninstall button enabled without selection." );
    // Click first column
    jtTable.clickOnCell( i, 0 );
    // Check uninstall enabled
    if( !jbUninstall.isEnabled( ) )
      fail( "Uninstall button disabled with selection." );

    // Check 
      // ToDo

    // Click first column
    jtTable.clickOnCell( i, 0 );
    // Check uninstall disabled
    if( jbUninstall.isEnabled( ) )
      fail( "Uninstall button enabled without selection." );
  }

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

  endTest( );
}
 
Example 15
Source File: Autoupdate.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void CheckAvailablePlugins( )
{
  startTest( );

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

  JDialogOperator jdPlugins = new JDialogOperator( "Plugins" );

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

  Sleep( 1000 );

  // Check buttons
  JButtonOperator jbReload = new JButtonOperator( jdPlugins, "Reload Catalog" );
  JButtonOperator jbInstall = new JButtonOperator( jdPlugins, "Install" );

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

  for( int i = 0; i < iOriginalRows; i++ )
  {
    // Check install disabled
    if( jbInstall.isEnabled( ) )
      fail( "Install button enabled without selection." );
    // Click first column
    jtTable.clickOnCell( i, 0 );
    // Check install enabled
    if( !jbInstall.isEnabled( ) )
      fail( "Install button disabled with selection." );

    // Check 
      // ToDo

    // Click first column
    jtTable.clickOnCell( i, 0 );
    // Check install disabled
    if( jbInstall.isEnabled( ) )
      fail( "Install button enabled without selection." );
  }

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