org.netbeans.jemmy.operators.JSpinnerOperator Java Examples

The following examples show how to use org.netbeans.jemmy.operators.JSpinnerOperator. 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: SpinnerDemoTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void changeValues(JFrameOperator jfo, int spinnerIndex) throws Exception {
    JSpinnerOperator spinner = new JSpinnerOperator(jfo, spinnerIndex);
    JTextFieldOperator jtfo = new JTextFieldOperator(spinner);
    float originalFieldValue = decimalFormat.parse(jtfo.getText()).floatValue();
    float finalFieldValue;

    // increment by one the value via spinner
    spinner.getIncreaseOperator().push();
    finalFieldValue = decimalFormat.parse(jtfo.getText()).floatValue();

    // check that the value was increased
    assertTrue("Increment Spinner " + spinner
            + " (originalFieldValue, actual value: " + originalFieldValue + " "
            + "< finalFieldValue, actual value = " + finalFieldValue + ")",
            originalFieldValue < finalFieldValue);

    // decrease value via spinner
    spinner.getDecreaseOperator().push();
    finalFieldValue = decimalFormat.parse(jtfo.getText()).floatValue();

    // check that the value was decrimented
    assertTrue("Decrement Spinner " + spinner
            + " (originalFieldValue, actual value: " + originalFieldValue + " "
            + ">= finalFieldValue, actual value = " + finalFieldValue + ")",
            originalFieldValue >= finalFieldValue);
}
 
Example #2
Source File: JSpinnerDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void scroll(ComponentOperator oper, ScrollAdjuster adj) {
    JButtonOperator increaseButton = ((JSpinnerOperator) oper).getIncreaseOperator();
    JButtonOperator decreaseButton = ((JSpinnerOperator) oper).getDecreaseOperator();
    if (adj.getScrollDirection() == ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION) {
        return;
    }
    int originalDirection = adj.getScrollDirection();
    while (adj.getScrollDirection() == originalDirection) {
        if (originalDirection == ScrollAdjuster.INCREASE_SCROLL_DIRECTION) {
            increaseButton.push();
        } else {
            decreaseButton.push();
        }
    }
}
 
Example #3
Source File: AllLanguageTabsAndIndentsOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JSpinnerOperator getNumberOfSpacesPerIndent() {
    if (numberOfSpacesPerIndent == null) {
        numberOfSpacesPerIndent = formattingOperator.getSpinnerOperatorByLabel("Number of Spaces per Indent:");
        storeDefaultValue(Settings.NUMBEROFSPACES);
    }
    return numberOfSpacesPerIndent;
}
 
Example #4
Source File: AllLanguageTabsAndIndentsOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JSpinnerOperator getTabSize() {
    if (tabSize == null) {
        tabSize = formattingOperator.getSpinnerOperatorByLabel("Tab Size:");
        storeDefaultValue(Settings.TABSIZE);
    }
    return tabSize;
}
 
Example #5
Source File: AllLanguageTabsAndIndentsOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public JSpinnerOperator getRightMargin() {
    if (rightMargin == null) {
        rightMargin = formattingOperator.getSpinnerOperatorByLabel("Right Margin:");
        storeDefaultValue(Settings.RIGHTMARGIN);
    }
    return rightMargin;

}
 
Example #6
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 #7
Source File: IndentCasesTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void setIndent(int number){
    OptionsOperator options = OptionsOperator.invoke();
    options.selectEditor();
    new JTabbedPaneOperator(options).selectPage("Formatting");
    JLabelOperator label = new JLabelOperator(options, "Number");
    JSpinner spinner = (JSpinner) label.getLabelFor();
    JSpinnerOperator spinnerOp = new JSpinnerOperator(spinner);
    spinnerOp.getNumberSpinner().scrollToValue(number);
    options.ok();
}
 
Example #8
Source File: JSpinnerDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void scrollToMinimum(final ComponentOperator oper, int orientation) {
    Object minimum = ((JSpinnerOperator) oper).getMinimum();
    if (minimum == null) {
        throw (new JSpinnerOperator.SpinnerModelException("Impossible to get a minimum of JSpinner model.", oper.getSource()));
    }
    scroll(oper, new ScrollAdjuster() {
        @Override
        public int getScrollOrientation() {
            return SwingConstants.VERTICAL;
        }

        @Override
        public String getDescription() {
            return "Spin to minimum";
        }

        @Override
        public int getScrollDirection() {
            if (((JSpinnerOperator) oper).getModel().getPreviousValue() != null) {
                return ScrollAdjuster.DECREASE_SCROLL_DIRECTION;
            } else {
                return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
            }
        }

        @Override
        public String toString() {
            return "scrollToMinimum.ScrollAdjuster{description = " + getDescription() + '}';
        }
    });
}
 
Example #9
Source File: JSpinnerDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void scrollToMaximum(final ComponentOperator oper, int orientation) {
    Object maximum = ((JSpinnerOperator) oper).getMaximum();
    if (maximum == null) {
        throw (new JSpinnerOperator.SpinnerModelException("Impossible to get a maximum of JSpinner model.", oper.getSource()));
    }
    scroll(oper, new ScrollAdjuster() {
        @Override
        public int getScrollOrientation() {
            return SwingConstants.VERTICAL;
        }

        @Override
        public String getDescription() {
            return "Spin to maximum";
        }

        @Override
        public int getScrollDirection() {
            if (((JSpinnerOperator) oper).getModel().getNextValue() != null) {
                return ScrollAdjuster.INCREASE_SCROLL_DIRECTION;
            } else {
                return ScrollAdjuster.DO_NOT_TOUCH_SCROLL_DIRECTION;
            }
        }

        @Override
        public String toString() {
            return "scrollToMaximum.ScrollAdjuster{description = " + getDescription() + '}';
        }
    });
}
 
Example #10
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 #11
Source File: Utils.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Sets a random port for Tomcat server and socket debugger transport. */
public static void setTomcatProperties() throws Exception {
    // "Tools"
    String toolsItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Tools"); // NOI18N
    // "Server Manager"
    String serverManagerItem = Bundle.getStringTrimmed(
            "org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle",
            "CTL_ServerManager");
    new ActionNoBlock(toolsItem + "|" + serverManagerItem, null).perform();
    // "Server Manager"
    String serverManagerTitle = Bundle.getString(
            "org.netbeans.modules.j2ee.deployment.devmodules.api.Bundle",
            "TXT_ServerManager");
    NbDialogOperator serverManagerOper = new NbDialogOperator(serverManagerTitle);
    String j2eeLabel = Bundle.getString(
            "org.netbeans.modules.j2ee.deployment.impl.ui.Bundle",
            "LBL_J2eeServersNode");
    new Node(new JTreeOperator(serverManagerOper), j2eeLabel + "|" + "Bundled Tomcat").select(); // NOI18N
    // set server port
    JSpinnerOperator serverPortOper = new JSpinnerOperator(serverManagerOper, 0);
    // satisfy focus on spinner which causes changes are reflected
    serverPortOper.getNumberSpinner().scrollToValue((Number) serverPortOper.getNextValue());
    serverPortOper.setValue(new Integer(getPort()));
    // set shutdown port
    JSpinnerOperator shutdownPortOper = new JSpinnerOperator(serverManagerOper, 1);
    // satisfy focus on spinner which causes changes are reflected
    shutdownPortOper.getNumberSpinner().scrollToValue((Number) shutdownPortOper.getNextValue());
    shutdownPortOper.setValue(new Integer(getPort()));

    // set socket debugger transport
    // "Startup"
    String startupLabel = Bundle.getString("org.netbeans.modules.tomcat5.customizer.Bundle", "TXT_Startup");
    new JTabbedPaneOperator(serverManagerOper).selectPage(startupLabel);
    // "Socket Port:
    String socketPortLabel = Bundle.getString("org.netbeans.modules.tomcat5.customizer.Bundle", "TXT_SocketPort");
    new JRadioButtonOperator(serverManagerOper, socketPortLabel).setSelected(true);
    // set socket port number
    JSpinnerOperator socketPortOper = new JSpinnerOperator(serverManagerOper, 0);
    // satisfy focus on spinner which causes changes are reflected
    socketPortOper.getNumberSpinner().scrollToValue((Number) socketPortOper.getNextValue());
    socketPort = getPort();
    socketPortOper.setValue(new Integer(socketPort));

    serverManagerOper.close();
}