Java Code Examples for org.netbeans.jemmy.operators.JListOperator#selectItem()
The following examples show how to use
org.netbeans.jemmy.operators.JListOperator#selectItem() .
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: CodeTemplatesOperator.java From netbeans with Apache License 2.0 | 6 votes |
public CodeTemplatesOperator setContext(Set<String> set) { JTabbedPaneOperator tabbedPane = getTabbedPane(); tabbedPane.selectPage("Contexts"); ContainerOperator<JEditorPane> selectedComponent = new ContainerOperator<>((Container)tabbedPane.getSelectedComponent()); JListOperator list = new JListOperator(selectedComponent); for (int i = 0; i < list.getModel().getSize(); i++) { JCheckBox checkBox = (JCheckBox) list.getRenderedComponent(i); String contextName = checkBox.getText(); list.scrollToItem(i); if(!checkBox.isSelected() && set.contains(contextName)) { list.selectItem(i); } else if(checkBox.isSelected() && !set.contains(contextName)) { list.selectItem(i); } } return this; }
Example 2
Source File: Utils.java From netbeans with Apache License 2.0 | 6 votes |
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: TestFontSettings.java From netbeans with Apache License 2.0 | 6 votes |
public void testChangeFontSize(){ openFile(newFileName); FontPaneOperator fontOper = initializeFontChanging(); JListOperator fontSizes = fontOper.fontSizes(); fontSizes.selectItem("12"); assertTrue(getRootRuleText().contains("font-size: ")); assertTrue(getRootRuleText().contains("12")); JComboBoxOperator fontUnits = fontOper.fontSizeUnits(); // assertTrue(fontUnits.isEnabled()); fontUnits.selectItem("mm"); assertTrue(getRootRuleText(), getRootRuleText().contains("font-size: 12mm")); fontSizes.selectItem("large"); fontUnits = fontOper.fontSizeUnits(); // assertFalse(fontUnits.isEnabled()); assertTrue(getRootRuleText().contains("font-size: large")); fontSizes.selectItem(0);// <NOT SET> assertFalse(getRootRuleText().contains("font-size")); }
Example 4
Source File: AddMethodTest.java From netbeans with Apache License 2.0 | 6 votes |
protected void fillExceptions(NbDialogOperator dialog) { if (exceptions != null) { new JTabbedPaneOperator(dialog).selectPage("Exceptions"); for (int i = 0; i < exceptions.length; i++) { new JButtonOperator(dialog, "Add").pushNoBlock(); NbDialogOperator findTypeOper = new NbDialogOperator("Find Type"); new JTextFieldOperator(findTypeOper).setText(exceptions[i]); // wait for list populated JListOperator typesListOper = new JListOperator(findTypeOper); if (exceptions[i].equals("Exception")) { // need to select correct item between other matches typesListOper.selectItem("Exception (java.lang)"); } else { typesListOper.selectItem(exceptions[i]); } findTypeOper.ok(); } } }
Example 5
Source File: actionsTest.java From netbeans with Apache License 2.0 | 6 votes |
/** Test case 5 * org.netbeans.modules.form.actions.InstallToPaletteAction */ public void testBeans() throws InterruptedException { String beanName = "MyBean"; createForm("Bean Form", beanName); Thread.sleep(3000); inspector = new ComponentInspectorOperator(); Node beanNode = new Node(prn, "Source Packages|" + PACKAGE_NAME + "|" + beanName); beanNode.select(); new ActionNoBlock(null, "Tools|Add to Palette...").perform(beanNode); Thread.sleep(2000); NbDialogOperator jdo = new NbDialogOperator("Select Palette Category"); JListOperator jlo = new JListOperator(jdo); jlo.selectItem("Beans"); jdo.btOK().push(); Thread.sleep(3000); }
Example 6
Source File: TestIssues.java From netbeans with Apache License 2.0 | 6 votes |
public void test105562(){/*move end bracket, 105574 end semicolon should be added*/ String insertion = "h2{font-size: 10px }\n"; EditorOperator eop = openFile(newFileName); eop.setCaretPositionToLine(1); eop.insert(insertion); eop.setCaretPositionToLine(1); waitUpdate(); StyleBuilderOperator styleOper= new StyleBuilderOperator("h2").invokeBuilder(); FontPaneOperator fontPane = (FontPaneOperator) styleOper.setPane(FONT); JListOperator fontFamilies = fontPane.fontFamilies(); fontFamilies.selectItem(3); waitUpdate(); String selected = fontFamilies.getSelectedValue().toString(); String text = eop.getText(); assertFalse("END BRACKET IS MOVED",text.contains(insertion)); String rule = text.substring(0, text.indexOf('}')); assertTrue("SEMICOLON ADDED", rule.contains("font-size: 10px;")); assertTrue("FONT FAMILY SOULD BE GENERATED INSIDE RULE",rule.contains("font-family: "+selected)); }
Example 7
Source File: ScriptingUtilities.java From netbeans with Apache License 2.0 | 5 votes |
public static void verifyAndResolveMissingWebServer(String projectName, String serverName) { ProjectRootNode projectNode = new ProjectsTabOperator().getProjectRootNode(projectName); if(!isServerMissingMenuAvaialable(projectName)) { return; } projectNode.performPopupActionNoBlock(menuItemName); NbDialogOperator missingServerDialog = new NbDialogOperator(dialogName); JListOperator serversList = new JListOperator(missingServerDialog); serversList.selectItem(serverName); missingServerDialog.ok(); }
Example 8
Source File: ProfilerValidationTest.java From visualvm with GNU General Public License v2.0 | 5 votes |
/** * 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 9
Source File: SyntaxHighlightTest.java From netbeans with Apache License 2.0 | 5 votes |
public void changeSetting(int category,int color) { OptionsOperator odop = OptionsOperator.invoke(); odop.selectFontAndColors(); JTabbedPaneOperator jtpo = new JTabbedPaneOperator(odop, "Syntax"); jtpo.selectPage(0); JListOperator jlo = new JListOperator(jtpo, 0); jlo.selectItem(category); JComboBoxOperator jcbo = new JComboBoxOperator(jtpo, 1); //change FG jcbo.selectItem(color); //select fg color JButtonOperator okOperator = new JButtonOperator(odop, "OK"); okOperator.push(); //confirm OD }
Example 10
Source File: AbbreviationsAddRemovePerformer.java From netbeans with Apache License 2.0 | 5 votes |
public static void useHint(final EditorOperator editor, final int lineNumber, String hintPrefix) throws InterruptedException { Object annots = new Waiter(new Waitable() { public Object actionProduced(Object arg0) { Object[] annotations = editor.getAnnotations(lineNumber); if (annotations.length == 0) { return null; } else { return annotations; } } public String getDescription() { return "Waiting for annotations for current line"; } }).waitAction(null); editor.pressKey(KeyEvent.VK_ENTER, KeyEvent.ALT_DOWN_MASK); JListOperator jlo = new JListOperator(MainWindowOperator.getDefault()); int index = -1; ListModel model = jlo.getModel(); for (int i = 0; i < model.getSize(); i++) { Object element = model.getElementAt(i); String desc = getText(element); if (desc.startsWith(hintPrefix)) { index = i; } } assertTrue("Requested hint not found", index != -1); jlo.selectItem(index); jlo.pushKey(KeyEvent.VK_ENTER); }
Example 11
Source File: TestFontSettings.java From netbeans with Apache License 2.0 | 5 votes |
private void addItem(StyleBuilderOperator.EditFontOperator fontOperator, int order){ JListOperator fonts = fontOperator.fonts(); int selected = new Random().nextInt(getSize(fonts)-1)+1;//IGNORE <NOT SET> fonts.selectItem(selected); String selectedItem = fonts.getSelectedValue().toString(); fontOperator.add(); assertEquals("ITEMS ADDED", order, getSize(fontOperator.selected())); assertEquals("ADDED ITEM", selectedItem, getItems(fontOperator.selected()).get(order-1)); }
Example 12
Source File: TestFontSettings.java From netbeans with Apache License 2.0 | 5 votes |
public void testChangeFontFamily(){ openFile(newFileName); FontPaneOperator fontOper = initializeFontChanging(); JListOperator fontFamilies = fontOper.fontFamilies(); int familiesCount = getSize(fontFamilies); fontFamilies.selectItem(new Random().nextInt(familiesCount-1)+1);// IGNORE <NOT SET> waitUpdate(); String selected = fontFamilies.getSelectedValue().toString(); assertTrue("CHANGED FONT", getRootRuleText().contains(selected)); assertTrue("CHANGED FONT", getRootRuleText().contains("font-family:")); fontFamilies.selectItem(0);// <NOT SET> assertFalse("CHANGED FONT", getRootRuleText().contains("font-family:")); }
Example 13
Source File: ProfilerValidationTest.java From netbeans with Apache License 2.0 | 5 votes |
/** * 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 14
Source File: RemoveSurroundingTest.java From netbeans with Apache License 2.0 | 5 votes |
private void dumpAndSelect(int row, int col, int select) { oper.setCaretPosition(row, col); oper.pressKey(KeyEvent.VK_BACK_SPACE, KeyEvent.ALT_DOWN_MASK); JDialogOperator jdo = new JDialogOperator(MainWindowOperator.getDefault()); JListOperator jlo = new JListOperator(jdo); ListModel model = jlo.getModel(); int i; for (i = 0; i < model.getSize(); i++) { Object item = model.getElementAt(i); if(item instanceof CodeDeleter) { CodeDeleter codeDeleter = (CodeDeleter) item; ref(codeDeleter.getDisplayName()); HighlightsSequence highlights = codeDeleter.getHighlight().getHighlights(0, oper.getText().length()); while(highlights.moveNext()) { ref(highlights.getStartOffset()+" "+highlights.getEndOffset()); AttributeSet attributes = highlights.getAttributes(); Enumeration<?> attributeNames = attributes.getAttributeNames(); while(attributeNames.hasMoreElements()) { Object nextElement = attributeNames.nextElement(); ref(nextElement+" "+attributes.getAttribute(nextElement)); } } } } if(select>-1) { jlo.selectItem(select); ref(oper.getText()); } }
Example 15
Source File: CodeTemplatesTest.java From netbeans with Apache License 2.0 | 5 votes |
private void invokeTemplateAsHint(EditorOperator editor, final String description) { final String blockTemplatePrefix = "<html>Surround with "; new EventTool().waitNoEvent(500); editor.pressKey(KeyEvent.VK_ENTER, KeyEvent.ALT_DOWN_MASK); new EventTool().waitNoEvent(500); JListOperator jlo = new JListOperator(MainWindowOperator.getDefault()); ListModel model = jlo.getModel(); int i; for (i = 0; i < model.getSize(); i++) { Object item = model.getElementAt(i); String hint = "n/a"; if (item instanceof SurroundWithFix) { hint = ((SurroundWithFix) item).getText(); } if (hint.startsWith(blockTemplatePrefix + description)) { System.out.println("Found at "+i+" position: "+hint); break; } } if (i == model.getSize()) { fail("Template not found in the hint popup"); } new EventTool().waitNoEvent(2000); jlo.selectItem(i); new EventTool().waitNoEvent(500); }
Example 16
Source File: testPalette.java From netbeans with Apache License 2.0 | 4 votes |
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; }
Example 17
Source File: AcceptanceTestCaseXSD.java From netbeans with Apache License 2.0 | 4 votes |
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 18
Source File: AcceptanceTestCaseXSD.java From netbeans with Apache License 2.0 | 4 votes |
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." ); }