Java Code Examples for org.netbeans.jemmy.operators.JTabbedPaneOperator#selectPage()

The following examples show how to use org.netbeans.jemmy.operators.JTabbedPaneOperator#selectPage() . 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 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 2
Source File: ParserIssueTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testBuild() {
    //open existing Java SE project
    Project p = (Project) ProjectSupport.openProject(new File(getDataDir(), "projects/Sample"));
    //set Ant verbosity level to "Debug"
    OptionsOperator oo = OptionsOperator.invoke();
    oo.selectJava();
    JTabbedPaneOperator jtpo = new JTabbedPaneOperator(oo);
    jtpo.selectPage("Ant"); // NOI18N
    JComboBoxOperator jcbo = new JComboBoxOperator(oo);
    jcbo.selectItem("Debug");
    oo.ok();
    //open output window
    new OutputWindowViewAction().perform();
    //build project
    Node n = ProjectsTabOperator.invoke().getProjectRootNode("Sample"); 
    new BuildJavaProjectAction().perform(n);
    try {
        Thread.sleep(10000);
    } catch (InterruptedException ie) {
        //ignore
    }
    String output = new OutputTabOperator("Sample").getText();
    assertTrue("build action output: \n" + output, output.contains("BUILD SUCCESSFUL")); //NOI18N
}
 
Example 3
Source File: SurroundTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testNoLogging() {
       String file = "Surround";
openSourceFile("org.netbeans.test.java.hints.HintsTest",file);        
       OptionsOperator oo = OptionsOperator.invoke();
       oo.selectEditor();
       JTabbedPaneOperator jtpo = new JTabbedPaneOperator(oo);
       jtpo.selectPage("Hints");
       JSplitPaneOperator jspo = new JSplitPaneOperator(oo);       
       JTreeOperator jto = new JTreeOperator(jtpo);                        
       selectHintNode(jto,"errors","Surround with try-catch");
       JCheckBoxOperator chbox1 = new JCheckBoxOperator(new ContainerOperator((Container)jspo.getRightComponent()),"Use org.openide.util.Exceptions.printStackTrace" );        
       chBoxSetSelected(chbox1, false);        
       JCheckBoxOperator chbox2 = new JCheckBoxOperator(new ContainerOperator((Container)jspo.getRightComponent()),"Use java.util.logging.Logger");        
       chBoxSetSelected(chbox2, false);        
       oo.ok();        
       new EventTool().waitNoEvent(1000);
       editor = new EditorOperator(file);
editor.setCaretPosition(18,1);
String pattern = ".*"+
       "try \\{.*"+
       "    FileReader fr = new FileReader\\(\"file\"\\);.*"+
       "\\} catch \\(FileNotFoundException ex\\) \\{.*"+
       "    ex.printStackTrace\\(\\);.*"+
       "\\}.*";        
       useHint("Surround Statement",new String[]{"Add throws","Surround Block","Surround Statement"},pattern);
   }
 
Example 4
Source File: SurroundTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testLoggerLogging() {
       String file = "Surround";
openSourceFile("org.netbeans.test.java.hints.HintsTest",file);        
       OptionsOperator oo = OptionsOperator.invoke();
       oo.selectEditor();
       JTabbedPaneOperator jtpo = new JTabbedPaneOperator(oo);
       jtpo.selectPage("Hints");
       JSplitPaneOperator jspo = new JSplitPaneOperator(oo);       
       JTreeOperator jto = new JTreeOperator(jtpo);
       selectHintNode(jto,"errors","Surround with try-catch");                
       JCheckBoxOperator chbox1 = new JCheckBoxOperator(new ContainerOperator((Container)jspo.getRightComponent()),"Use org.openide.util.Exceptions.printStackTrace" );
       chBoxSetSelected(chbox1, false);
       JCheckBoxOperator chbox2 = new JCheckBoxOperator(new ContainerOperator((Container)jspo.getRightComponent()),"Use java.util.logging.Logger");
       chBoxSetSelected(chbox2, true);
       oo.ok();
       new EventTool().waitNoEvent(1000);
       editor = new EditorOperator(file);
editor.setCaretPosition(18,1);
String pattern = ".*"+
       "try \\{.*"+
       "    FileReader fr = new FileReader\\(\"file\"\\);.*"+
       "\\} catch \\(FileNotFoundException ex\\) \\{.*"+
       "    Logger.getLogger\\(Surround.class.getName\\(\\)\\).log\\(Level.SEVERE, null, ex\\);.*"+
       "\\}.*";        
       useHint("Surround Statement",new String[]{"Add throws","Surround Block","Surround Statement"},pattern);
   }
 
Example 5
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 6
Source File: DefaultVisualizer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Switches tabs to make the component visible.
 *
 * @param tabOper an operator representing a tabbed pane.
 * @param target a component - target to be made visible.
 */
protected void switchTab(JTabbedPaneOperator tabOper, Component target) {
    int tabInd = 0;
    for (int j = 0; j < tabOper.getTabCount(); j++) {
        if (target == tabOper.getComponentAt(j)) {
            tabInd = j;
            break;
        }
    }
    if (tabOper.getSelectedIndex() != tabInd) {
        tabOper.selectPage(tabInd);
    }
}
 
Example 7
Source File: ToggleButtonDemoTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test() throws Exception {
    new ClassReference(ToggleButtonDemo.class.getCanonicalName()).startApplication();

    JFrameOperator mainFrame = new JFrameOperator(ToggleButtonDemo.class.getAnnotation(DemoProperties.class).value());
    JTabbedPaneOperator tabPane = new JTabbedPaneOperator(mainFrame);

    // Radio Button Toggles
    testRadioButtons(getBorderTitledJPanelOperator(mainFrame, TEXT_RADIO_BUTTONS), 3, null);
    testRadioButtons(getBorderTitledJPanelOperator(mainFrame, IMAGE_RADIO_BUTTONS), 3, null);
    testRadioButtons(getLabeledContainerOperator(mainFrame, PAD_AMOUNT), 3, (t, i) -> DEFAULT.equals(t));

    // switch to the Check Boxes Tab
    tabPane.selectPage(CHECK_BOXES);

    // Check Box Toggles
    ContainerOperator<?> textCheckBoxesJPanel = getBorderTitledJPanelOperator(mainFrame, TEXT_CHECKBOXES);
    testCheckBox(textCheckBoxesJPanel, CHECK1, false);
    testCheckBox(textCheckBoxesJPanel, CHECK2, false);
    testCheckBox(textCheckBoxesJPanel, CHECK3, false);

    ContainerOperator<?> imageCheckBoxesJPanel = getBorderTitledJPanelOperator(mainFrame, IMAGE_CHECKBOXES);
    testCheckBox(imageCheckBoxesJPanel, CHECK1, false);
    testCheckBox(imageCheckBoxesJPanel, CHECK2, false);
    testCheckBox(imageCheckBoxesJPanel, CHECK3, false);

    ContainerOperator<?> displayOptionsContainer = getLabeledContainerOperator(mainFrame, DISPLAY_OPTIONS);
    testCheckBox(displayOptionsContainer, PAINT_BORDER, false);
    testCheckBox(displayOptionsContainer, PAINT_FOCUS, true);
    testCheckBox(displayOptionsContainer, ENABLED, true);
    testCheckBox(displayOptionsContainer, CONTENT_FILLED, true);

    // Direction Button Toggles
    testToggleButtons(mainFrame);
}
 
Example 8
Source File: TabbedPaneDemoTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testTabs(JFrameOperator mainFrame, String tabPlacement) throws Exception {
    ContainerOperator<?> rbCont = getLabeledContainerOperator(mainFrame, TAB_PLACEMENT);
    new JRadioButtonOperator(rbCont, tabPlacement).doClick();

    final String[] tabTitles = new String[]{CAMILLE, MIRANDA, EWAN, BOUNCE};
    for (int i = 0; i < tabTitles.length; i++) {
        String pageTitle = tabTitles[i];
        JTabbedPaneOperator tabOperator = new JTabbedPaneOperator(mainFrame);
        tabOperator.setVerification(true);
        tabOperator.selectPage(pageTitle);
    }
}
 
Example 9
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 10
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 11
Source File: HintsTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void setInPlaceCreation(boolean inPlace) {
    OptionsOperator oo = OptionsOperator.invoke();
    oo.selectEditor();
    JTabbedPaneOperator jtpo = new JTabbedPaneOperator(oo);
    jtpo.selectPage("Hints");
    JSplitPaneOperator jspo = new JSplitPaneOperator(oo);
    JTreeOperator jto = new JTreeOperator(jtpo);
    selectHintNode(jto, "errors", "Create Local Variable");
    JCheckBoxOperator chbox1 = new JCheckBoxOperator(new ContainerOperator((Container) jspo.getRightComponent()), "Create Local Variable In Place");
    chBoxSetSelected(chbox1, inPlace);
    oo.ok();
}
 
Example 12
Source File: GuiTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean excludedContains(String item) {
    int delay = 1000;
    OptionsOperator oo = null;            
    try {
        oo = OptionsOperator.invoke();
        oo.selectEditor();
        JTabbedPane jtp = (JTabbedPane) oo.findSubComponent(new JTabbedPaneOperator.JTabbedPaneFinder());
        JTabbedPaneOperator jtpo = new JTabbedPaneOperator(jtp);
        Container page = (Container) jtpo.selectPage("Code Completion");
        ContainerOperator jco = new ContainerOperator(page);
        new EventTool().waitNoEvent(delay);
        
        JComboBox jcb = (JComboBox) jco.findSubComponent(new JComboBoxOperator.JComboBoxFinder());
        JComboBoxOperator jcbo = new JComboBoxOperator(jcb);       
        jcbo.selectItem("text/x-java");
        new EventTool().waitNoEvent(delay);
        
        JList jl = (JList) jco.findSubComponent(new JListOperator.JListFinder());
        JListOperator jlo = new JListOperator(jl);
        for (int i = 0; i < jlo.getModel().getSize(); i++) {
            String actItem = jlo.getModel().getElementAt(i).toString();
            if(item.equals(actItem)) {
                return true;
            }                
        }
        return false;
        
    } finally {
        if(oo!=null) {
            oo.close();
        }
    }
}
 
Example 13
Source File: CodeTemplatesOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Set<String> getContexts() {
    Set<String> result = new HashSet<>();
    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);            
        if(checkBox.isSelected())  {
            result.add(checkBox.getText());                
        }                         
    }        
    return result;
}
 
Example 14
Source File: CodeTemplatesOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JEditorPaneOperator getEditorOnTab(final String tabName) {
    JTabbedPaneOperator tabbedPane = getTabbedPane();
    tabbedPane.selectPage(tabName);
    ContainerOperator<JEditorPane> selectedComponent = new ContainerOperator<>((Container)tabbedPane.getSelectedComponent());
    JEditorPaneOperator jepo = new JEditorPaneOperator(selectedComponent);
    return jepo;
}
 
Example 15
Source File: CodeTemplatesOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void switchToTemplates() {
    optionsOperator.selectEditor();
    Component findComponent = optionsOperator.findSubComponent(new JTabbedPaneOperator.JTabbedPaneFinder());
    JTabbedPaneOperator tabbedPane = new JTabbedPaneOperator((JTabbedPane) findComponent);
    tabbedPane.selectPage("Code Templates");
    panel = new ContainerOperator<>((Container) tabbedPane.getSelectedComponent());
}
 
Example 16
Source File: AutomaticInternationalizationTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Tests component code with properties Automatic Internationalization =
 * false
 */
public void testAutomaticInternationalizationDisabled() {
    //testAutomaticInternationalization(false);
    OptionsForFormOperator.invoke();
    //add timeout
    waitNoEvent(1000);
    log("Option dialog was opened");

    OptionsForFormOperator options = new OptionsForFormOperator();

    //add timeout
    waitNoEvent(1000);

    options.selectJava();
    waitNoEvent(1000);
    JTabbedPaneOperator jtpo = new JTabbedPaneOperator(options);
    jtpo.selectPage("GUI Builder");
    waitNoEvent(1000);
    
    //add timeout
    waitNoEvent(2000);
    
    JComboBoxOperator jcbo = new JComboBoxOperator(options, 3);

    jcbo.selectItem("Off");

    //Property property = new Property(options.getPropertySheet("Miscellaneous|GUI Builder"), "Automatic Internationalization"); // NOI18N
    //property.setValue(String.valueOf( enabled ? "On" : "Off"));
    options.ok();
    //add timeout
    waitNoEvent(2000);
    log("AutomaticResource Management was set");

    name = createJFrameFile();

    ProjectsTabOperator pto = new ProjectsTabOperator();
    ProjectRootNode prn = pto.getProjectRootNode(DATA_PROJECT_NAME);
    prn.select();

    Node formnode = new Node(prn, "Source Packages|" + PACKAGE_NAME + "|" + name);
    formnode.select();
    log("Form node selected.");

    OpenAction openAction = new OpenAction();
    openAction.perform(formnode);



    ComponentInspectorOperator inspector = new ComponentInspectorOperator();
    inspector.freezeNavigatorAndRun(r);


    inspector = new ComponentInspectorOperator();
    Property prop = new Property(inspector.properties(), "text"); // NOI18N
    prop.setValue("Lancia Lybra");
    log("text component of button was set");
    FormDesignerOperator designer = new FormDesignerOperator(name);
    designer.source();
    designer.design();

    findInCode("jButton1.setText(\"Lancia Lybra\");", designer);

    //designer.design();
    //removeFile(name);

}
 
Example 17
Source File: AutomaticInternationalizationTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Tests component code with properties Automatic Internationalization =
 * true
 */
public void testAutomaticInternationalizationEnabled() {
    //testAutomaticInternationalization(true);
    OptionsForFormOperator.invoke();
    //add timeout
    waitNoEvent(1000);
    log("Option dialog was opened");

    OptionsForFormOperator options = new OptionsForFormOperator();


    //add timeout
    waitNoEvent(1000);

    options.selectJava();
    //add timeout
    waitNoEvent(1000);
    JTabbedPaneOperator jtpo = new JTabbedPaneOperator(options);
    jtpo.selectPage("GUI Builder");
    waitNoEvent(1000);
    JComboBoxOperator jcbo = new JComboBoxOperator(options, 3);

    jcbo.selectItem("On");
    options.ok();
    //add timeout
    waitNoEvent(2000);
    log("AutomaticResource Management was set");

    name = createJFrameFile();
    FormDesignerOperator designer = new FormDesignerOperator(name);
    designer.source();
    designer.design();


    ComponentInspectorOperator inspector = new ComponentInspectorOperator();
    inspector.freezeNavigatorAndRun(r);

    inspector = new ComponentInspectorOperator();
    Property prop = new Property(inspector.properties(), "text"); // NOI18N
    prop.setValue("Lancia Lybra");
    log("text component of button was set");


    findInCode("jButton1.setText(bundle.getString(\"MyJFrame", designer);

    designer.design();
    //removeFile(name);

}