Java Code Examples for org.netbeans.jemmy.operators.JListOperator#findItemIndex()

The following examples show how to use org.netbeans.jemmy.operators.JListOperator#findItemIndex() . 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: AddAndRemoveBeansTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Tests removing beans using popup menu from palette
 */
public void testRemovingBeansFromPalette() {
    openFile("clear_Frame.java");

    ComponentPaletteOperator palette = new ComponentPaletteOperator();
    palette.expandBeans();
    palette.collapseSwingContainers();
    palette.collapseSwingMenus();
    palette.collapseSwingWindows();
    palette.collapseAWT();
    palette.collapseSwingControls();

    JListOperator list = palette.lstComponents();
    list.clickOnItem(NONVISUAL_BEAN_NAME, new Operator.DefaultStringComparator(true, false));

    // TODO: I'm not able to invoke popup menu :(
    int i = list.findItemIndex(NONVISUAL_BEAN_NAME, new Operator.DefaultStringComparator(true, false));
    p(i);

    Component[] comps = list.getComponents();
    p(comps.length);
    for (Component comp : comps) {
        p(comp.toString());
    }
}
 
Example 2
Source File: Utils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void stepChooseComponet( String name, TestData data )
{
    JFrameOperator installerMain = new JFrameOperator(MAIN_FRAME_TITLE);

    new JButtonOperator(installerMain, "Customize...").push();
    JDialogOperator customizeInstallation = new JDialogOperator("Customize Installation");
    JListOperator featureList = new JListOperator(customizeInstallation);
    featureList.selectItem(name);

    featureList.pressKey(KeyEvent.VK_SPACE);

    // Check prelude
    data.m_bPreludePresents = ( -1 != featureList.findItemIndex( "Prelude" ) );

    new JButtonOperator(customizeInstallation, "OK").push();
}
 
Example 3
Source File: Utils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void CheckPrelude( TestData data )
{
    JFrameOperator installerMain = new JFrameOperator(MAIN_FRAME_TITLE);

    new JButtonOperator(installerMain, "Customize...").push();
    JDialogOperator customizeInstallation = new JDialogOperator("Customize Installation");
    JListOperator featureList = new JListOperator(customizeInstallation);

    // Check prelude
    data.m_bPreludePresents = ( -1 != featureList.findItemIndex( "Prelude" ) );

    new JButtonOperator(customizeInstallation, "OK").push();
}
 
Example 4
Source File: AcceptanceTestCaseXSD.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void AddItInternal(
    int iColumn,
    String sItName,
    String sMenuToAdd,
    String sRadioName,
    String sTypePath,
    String sAddedName
  )
{
  // Swicth to Schema view
  new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("View|Editors|Schema");

  // Select first column, Attributes
  SchemaMultiView opMultiView = new SchemaMultiView( JAXB_PACKAGE_NAME + ".xsd" );
  opMultiView.switchToSchema( );
  opMultiView.switchToSchemaColumns( );
  JListOperator opList = opMultiView.getColumnListOperator( iColumn );
  opList.selectItem( sItName );

  // Right click on Reference Schemas
  int iIndex = opList.findItemIndex( sItName );
  Point pt = opList.getClickPoint( iIndex );
  opList.clickForPopup( pt.x, pt.y );

  // Click Add Attribute...
  JPopupMenuOperator popup = new JPopupMenuOperator( );
  popup.pushMenuNoBlock( sMenuToAdd + "..." );

  // Get dialog
  JDialogOperator jadd = new JDialogOperator( sMenuToAdd.replace( "|", " " ) );

  // Set unique name
  JTextFieldOperator txt = new JTextFieldOperator( jadd, 0 );
  txt.setText( sAddedName );

  // Use existing definition
  if( null != sRadioName )
  {
    JRadioButtonOperator jex = new JRadioButtonOperator( jadd, sRadioName );
    jex.setSelected( true );
  }

  // Get tree
  if( null != sTypePath )
  {
    JTreeOperator jtree = new JTreeOperator( jadd, 0 );
    TreePath path = jtree.findPath( sTypePath );
  
    jtree.selectPath( path );
    jtree.clickOnPath( path );
  }

  // Close
  JButtonOperator jOK = new JButtonOperator( jadd, "OK" ); // TODO : OK
  jOK.push( );
  jadd.waitClosed( );

  // Check attribute was added successfully
  opList = opMultiView.getColumnListOperator( iColumn + 1 );
  iIndex = opList.findItemIndex( sAddedName );
  if( -1 == iIndex )
    fail( "It was not added." );

}
 
Example 5
Source File: AcceptanceTestCaseXSD.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void RefreshSchemaFile( )
{
  startTest( );

  // TODO : Add elements using design.
  // TEMPORARY : Using Schema view
  new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("View|Editors|Schema");
  AddItInternal(
      0,
      "Elements",
      "Add Element",
      "Use Existing Type",
      "Built-in Types|string",
      "NewElementForRefresh"
    );

  // Save All
  WaitSaveAll( );
  new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("File|Save All");

  // Invoke Refresh
  ProjectsTabOperator pto = ProjectsTabOperator.invoke( );

  ProjectRootNode prn = pto.getProjectRootNode( TEST_JAVA_APP_NAME );
  prn.select( );

  Node bindingNode = new Node( prn, "JAXB Binding|" + JAXB_BINDING_NAME + "|" + JAXB_PACKAGE_NAME + ".xsd" );
  bindingNode.select( );
  bindingNode.performPopupAction( "Refresh" );

  // TODO : check result
  // TEMPORARY : Using Schema view
  try { Thread.sleep( 1000 ); } catch( InterruptedException ex ) { }
  SchemaMultiView opMultiView = new SchemaMultiView( JAXB_PACKAGE_NAME + ".xsd" );
  JListOperator opList = opMultiView.getColumnListOperator( 0 );
  opList.selectItem( "Elements" );
  opList = opMultiView.getColumnListOperator( 1 );
  int iIndex = opList.findItemIndex( "NewElementForRefresh" );
  if( -1 != iIndex )
  {
    fail( "Element still presents after schema Refresh." );
  }

  // Back to schema?
  new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenu("View|Editors|Schema");

  endTest( );
}
 
Example 6
Source File: testPalette.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void DragSomething(
    String sFile,
    String sLocation,
    String sComponent
  )
{
  // Locate coords of HTML code
  EditorOperator eoPHP = new EditorOperator( sFile );
  eoPHP.setCaretPosition( sLocation, false );

 int iX = 0, iY = 0;

 JEditorPaneOperator txt = eoPHP.txtEditorPane( );
 JEditorPane epane =  ( JEditorPane )txt.getSource( );
 try
 {
   Rectangle rct = epane.modelToView( epane.getCaretPosition( ) );
   iX = rct.x;
   iY = rct.y;
 }
 catch( BadLocationException ex )
 {
   fail( "Unable to detect destination location." );
 }

 //TopComponentOperator top = new TopComponentOperator( "EmptyPHPWebPage.php" );
 TopComponentOperator pal = new TopComponentOperator( "Palette" );
 JListOperator list = new JListOperator( pal, 0 );

 ListModel lmd = list.getModel( );
 int iIndex = list.findItemIndex( sComponent );
 list.selectItem( iIndex );
 Point pt = list.getClickPoint( iIndex );

 MouseRobotDriver m_mouseDriver = new MouseRobotDriver(new Timeout("", 500));
 m_mouseDriver.moveMouse( list, pt.x, pt.y );
 m_mouseDriver.pressMouse( InputEvent.BUTTON1_MASK, 0 );
 m_mouseDriver.enterMouse( txt );
 m_mouseDriver.dragMouse( txt, iX, iY, InputEvent.BUTTON1_MASK, 0 );
 m_mouseDriver.releaseMouse( InputEvent.BUTTON1_MASK, 0 );

 return;
}