org.netbeans.jemmy.operators.JListOperator Java Examples

The following examples show how to use org.netbeans.jemmy.operators.JListOperator. 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: testInsertDatabase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void InsertDatabaseTable( ) throws Exception
{
  startTest( );

  // Get editor
  EditorOperator eoPHP = new EditorOperator( "index.php" );
  eoPHP.setCaretPosition( "}", false );
  TypeCode(eoPHP, " ");
  Sleep( 1000 );
  InvokeInsert( eoPHP );
  Sleep( 1000 );

  JDialogOperator jdInsetter = new JDialogOperator( );
  JListOperator jlList = new JListOperator( jdInsetter );

  ClickListItemNoBlock( jlList, 1, 1 );

  JDialogOperator jdGenerator = new JDialogOperator( "Select Table and Columns" );

  JButtonOperator jbCancel = new JButtonOperator( jdGenerator, "Cancel" );
  jbCancel.pushNoBlock( );
  jdGenerator.waitClosed( );

  endTest( );
}
 
Example #2
Source File: GenerateCodeOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Opens requested code generation dialog
 * @param type Displayname of menu item
 * @param editor Operator of editor window where should be menu opened
 * @return true is item is found, false elsewhere
 */
public static boolean openDialog(String type, EditorOperator editor) {
    new EventTool().waitNoEvent(1000);
    editor.pushKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK);
    JDialogOperator jdo = new JDialogOperator();
    new EventTool().waitNoEvent(1000);
    JListOperator list = new JListOperator(jdo);        
    ListModel lm = list.getModel();
    for (int i = 0; i < lm.getSize(); i++) {
        CodeGenerator cg  = (CodeGenerator) lm.getElementAt(i);
        if(cg.getDisplayName().equals(type)) {
            list.setSelectedIndex(i);
            jdo.pushKey(KeyEvent.VK_ENTER);
            new EventTool().waitNoEvent(1000);
            return true;
        }
    }
    return false;        
}
 
Example #3
Source File: CommonUtilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Adds GlassFish server using path from glassfish.home property
 */
public static void addApplicationServer() {

    String glassfishHome = System.getProperty("glassfish.home");
    
    if (glassfishHome == null) {
        throw new Error("Can't add GlassFish server. glassfish.home property is not set.");
    }

    String addServerMenuItem = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle", "LBL_Add_Server_Instance"); // Add Server...
    String addServerInstanceDialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.wizard.Bundle", "LBL_ASIW_Title"); //"Add Server Instance"

    RuntimeTabOperator rto = RuntimeTabOperator.invoke();
    Node serversNode = new Node(rto.getRootNode(), "Servers");
    // Let's check whether GlassFish is already added
    if (!serversNode.isChildPresent("GlassFish")) {
        // There is no GlassFish node so we'll add it
        serversNode.performPopupActionNoBlock(addServerMenuItem);
        WizardOperator addServerInstanceDialog = new WizardOperator(addServerInstanceDialogTitle);
        new JListOperator(addServerInstanceDialog, 1).selectItem("GlassFish Server");
        addServerInstanceDialog.next();
        new JTextFieldOperator(addServerInstanceDialog).setText(glassfishHome);
        addServerInstanceDialog.next();
        addServerInstanceDialog.finish();
    }
}
 
Example #4
Source File: CommonUtilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void addTomcatServer() {
    String appServerPath = System.getProperty("tomcat.installRoot");
    
    if (appServerPath == null) {
        throw new Error("Can't add tomcat server. tomcat.installRoot property is not set.");
    }
    
    String addServerMenuItem = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle", "LBL_Add_Server_Instance"); // Add Server...
    String addServerInstanceDialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.wizard.Bundle", "LBL_ASIW_Title"); //"Add Server Instance"
    String nextButtonCaption = Bundle.getStringTrimmed("org.openide.Bundle", "CTL_NEXT");
    String finishButtonCaption = Bundle.getStringTrimmed("org.openide.Bundle", "CTL_FINISH");

    RuntimeTabOperator rto = RuntimeTabOperator.invoke();
    Node serversNode = new Node(rto.getRootNode(), "Servers");
    // Let's check whether GlassFish is already added
    if (!serversNode.isChildPresent("Tomcat")) {
        serversNode.performPopupActionNoBlock(addServerMenuItem);
        NbDialogOperator addServerInstanceDialog = new NbDialogOperator(addServerInstanceDialogTitle);
        new JListOperator(addServerInstanceDialog, 1).selectItem("Tomcat");
        new JButtonOperator(addServerInstanceDialog, nextButtonCaption).push();
        new JTextFieldOperator(addServerInstanceDialog, 1).setText(appServerPath);
        new JCheckBoxOperator(addServerInstanceDialog,1).changeSelection(false);
        new JButtonOperator(addServerInstanceDialog, finishButtonCaption).push();
    }
}
 
Example #5
Source File: actionsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 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: BeansTestCase.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public boolean openDialog(EditorOperator operator) {
    operator.pressKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK);
    JDialogOperator jdo = new JDialogOperator();        
    JListOperator list = new JListOperator(jdo);
    ListModel lm = list.getModel();
    for (int i = 0; i < lm.getSize(); i++) {
        CodeGenerator cg  = (CodeGenerator) lm.getElementAt(i);
        if(cg.getDisplayName().equals("Add Property...")) {
            list.setSelectedIndex(i);
            jdo.pushKey(KeyEvent.VK_ENTER);                
            new EventTool().waitNoEvent(250);
            return true;
        }
    }
    fail("Dialog not found");
    return false;
}
 
Example #7
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 #8
Source File: GenerateCodeOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Compares list of items provided in the Insert Code dialog with the list of expected items
 * @param editor Operator of editor window where should Insert Code should be caled
 * @param items Expected items
 * @return true if both list are the same, false otherwise
 */
public static boolean containsItems(EditorOperator editor, String ... items) {
    Set<String> actItems = new HashSet<String>();
    List<String> expItems = Arrays.asList(items);
    editor.pushKey(KeyEvent.VK_INSERT, KeyEvent.ALT_DOWN_MASK);
    JDialogOperator jdo = new JDialogOperator();        
    JListOperator list = new JListOperator(jdo);
    ListModel lm = list.getModel();
    for (int i = 0; i < lm.getSize(); i++) {
        CodeGenerator cg  = (CodeGenerator) lm.getElementAt(i);
        actItems.add(cg.getDisplayName());
        if(!expItems.contains(cg.getDisplayName())) return false;
    }
    for (String string : expItems) {
        if(!actItems.contains(string)) return false;            
    }
    return true;       
}
 
Example #9
Source File: CodeTemplatesOperator.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: JListMouseDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Clicks on a list item.
 *
 * @param oper an operator to click on.
 * @param index item index.
 * @param modifiers a combination of {@code InputEvent.*_MASK} fields.
 */
protected void clickOnItem(final JListOperator oper, final int index, final int modifiers) {
    if (!QueueTool.isDispatchThread()) {
        oper.scrollToItem(index);
    }
    queueTool.invokeSmoothly(new QueueTool.QueueAction<Void>("Path selecting") {
        @Override
        public Void launch() {
            Rectangle rect = oper.getCellBounds(index, index);
            DriverManager.getMouseDriver(oper).
                    clickMouse(oper,
                            rect.x + rect.width / 2,
                            rect.y + rect.height / 2,
                            1, Operator.getDefaultMouseButton(), modifiers,
                            oper.getTimeouts().create("ComponentOperator.MouseClickTimeout"));
            return null;
        }
    });
}
 
Example #11
Source File: JComboMouseDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void selectItem(ComponentOperator oper, int index) {
    JComboBoxOperator coper = (JComboBoxOperator) oper;
    //1.5 workaround
    if (System.getProperty("java.specification.version").compareTo("1.4") > 0) {
        queueTool.setOutput(oper.getOutput().createErrorOutput());
        queueTool.waitEmpty(10);
        queueTool.waitEmpty(10);
        queueTool.waitEmpty(10);
    }
    //end of 1.5 workaround
    if (!coper.isPopupVisible()) {
        if (UIManager.getLookAndFeel().getClass().getName().equals("com.sun.java.swing.plaf.motif.MotifLookAndFeel")) {
            oper.clickMouse(oper.getWidth() - 2, oper.getHeight() / 2, 1);
        } else {
            DriverManager.getButtonDriver(coper.getButton()).
                    push(coper.getButton());
        }
    }
    JListOperator list = new JListOperator(coper.waitList());
    list.copyEnvironment(coper);
    list.setVisualizer(new EmptyVisualizer());
    coper.getTimeouts().sleep("JComboBoxOperator.BeforeSelectingTimeout");
    DriverManager.getListDriver(list).
            selectItem(list, index);
}
 
Example #12
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 #13
Source File: TestFontSettings.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 #14
Source File: AddMethodTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 #15
Source File: TestIssues.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 #16
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 #17
Source File: NewProjectTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * This method should be used when category is too complicated and couldn't
 * be used as golden file's filename.
 *
 * @param categoryName
 * @param goldenFileName
 * @param newProjectOperator
 * @return
 */
private void oneCategoryTest(String categoryName, String goldenFileName) throws InterruptedException {
    npwo = NewProjectWizardOperator.invoke();
    File goldenfile = getGoldenFile("newproject", goldenFileName);
    ArrayList<String> permanentProjects = Utilities.parseFileByLines(goldenfile);
    wait(2000);
    npwo.selectCategory(categoryName);
    JListOperator jlo = npwo.lstProjects();
    ArrayList<String> actualProjects = new ArrayList<String>();
    actualProjects.add(categoryName); /// add category as the first item
    actualProjects.addAll(getProjectsList(jlo));

    compareAndAssert(permanentProjects, actualProjects);
}
 
Example #18
Source File: ListDemoTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void waitModelSize(JListOperator listOp, int size) {
    listOp.waitState(new ComponentChooser() {
        public boolean checkComponent(Component comp) {
            return getUIValue(listOp, (JList list) -> list.getModel().getSize()) == size;
        }
        public String getDescription() {
            return "Model size to be equal to " + size;
        }
    });
}
 
Example #19
Source File: JListMouseDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void selectItems(ComponentOperator oper, int[] indices) {
    clickOnItem((JListOperator) oper, indices[0]);
    for (int i = 1; i < indices.length; i++) {
        clickOnItem((JListOperator) oper, indices[i], InputEvent.CTRL_MASK);
    }
}
 
Example #20
Source File: SwingViewTest.java    From SimpleMVC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void when_remove_button_clicked_then_calls_removeAction() {
    init_ListWithOneItem();
    JFrameOperator root = getRootFrame();
    new JListOperator(root, 0).selectItem(0);

    pushButton(root, REMOVE_BUTTON);

    verify(controller).removeAction(ANY_STRING);
}
 
Example #21
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 #22
Source File: SwingViewTest.java    From SimpleMVC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void when_last_item_is_removed_then_remove_button_is_disabled() {
    Model model = new Model();
    model.addDatum(ANY_STRING);
    view.setModel(model);
    JFrameOperator root = getRootFrame();

    new JListOperator(root, 0).selectItem(0);
    JButtonOperator removeButton = findButton(root, REMOVE_BUTTON);
    removeButton.doClick();

    assertFalse("Remove button must be disabled", removeButton.isEnabled());
}
 
Example #23
Source File: SyntaxHighlightTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #24
Source File: AbbreviationsAddRemovePerformer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #25
Source File: TestFontSettings.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #26
Source File: SwingViewTest.java    From SimpleMVC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void when_item_in_list_is_select_then_remove_button_is_enabled() {
    init_ListWithOneItem();
    JFrameOperator root = getRootFrame();

    new JListOperator(root, 0).selectItem(0);

    JButtonOperator removeButton = findButton(root, REMOVE_BUTTON);
    assertTrue("Remove button must be enabled", removeButton.isEnabled());
}
 
Example #27
Source File: SwingViewTest.java    From SimpleMVC with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void when_no_item_in_list_is_select_then_remove_button_is_disabled() {
    init_ListWithOneItem();
    JFrameOperator root = getRootFrame();

    new JListOperator(root, 0).clearSelection();

    JButtonOperator removeButton = findButton(root, REMOVE_BUTTON);
    assertFalse("Remove button must be disabled", removeButton.isEnabled());
}
 
Example #28
Source File: TestFontSettings.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #29
Source File: CSSTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected List<String> getItems(JListOperator listOperator){
    JList jList = (JList) listOperator.getSource();
    int listOperatorSize = getSize(listOperator);
    List<String> result = new ArrayList<String>(listOperatorSize);
    for (int i=0; i <listOperatorSize ;i++){
        result.add(jList.getModel().getElementAt(i).toString());
    }
    return result;
}
 
Example #30
Source File: KeyMapOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JListOperator clickShortcutEllipsisButton(JTableOperator tab, int row) {
        TableModel tm = tab.getModel();
        TableCellRenderer cellRenderer = tab.getCellRenderer(row, 2);
        Rectangle cellRect = tab.getCellRect(row, 1, true);
        //org.netbeans.modules.options.keymap.ShortcutCellPanel sc = (org.netbeans.modules.options.keymap.ShortcutCellPanel) tm.getValueAt(row, 1);
//        final JButton button = sc.getButton();
//        int x = button.getX() + button.getWidth() / 2;
//        int y = button.getY() + button.getHeight() / 2;
        Rectangle r = tab.getCellRect(row, 1, false);
        tab.clickMouse(r.x + r.width-3, r.y + (r.height/2), 1);
        System.out.println("[TEST_DEBUG]  Pressed [...] button on row " + (row + 1));
        return new JListOperator(new JPopupMenuOperator());
    }