Search in sources :

Example 1 with GUITest

use of org.fest.swing.annotation.GUITest in project aspro by JMMC-OpenDev.

the class AsproDocJUnitTest method m003_captureWindCompass.

/**
 * Capture the main panel with wind compass enabled
 */
@Test
@GUITest
public void m003_captureWindCompass() {
    // enable wind restriction:
    window.checkBox("jCheckBoxWind").check();
    final WindWidget windWidget = robot().finder().findByName("WindWidget", WindWidget.class);
    GuiActionRunner.execute(new GuiTask() {

        @Override
        protected void executeInEDT() {
            windWidget.setValue(60d);
        }
    });
    // waits for computation to finish :
    AsproTestUtils.checkRunningTasks();
    // Capture observability plot :
    getMainTabbedPane().selectTab(SettingPanel.TAB_OBSERVABILITY);
    saveScreenshot(window, "Aspro2-wind-obs.png");
    final JPanelFixture panel = window.panel("observabilityPanel");
    // enable detailed plot :
    panel.checkBox("jCheckBoxDetailedOutput").check();
    // waits for computation to finish :
    AsproTestUtils.checkRunningTasks();
    // see HD 1234
    panel.scrollBar("scroller").scrollToMaximum();
    // Capture observability plot of detailed plot :
    saveScreenshot(getMainTabbedPane(), "Aspro2-wind-obs-det.png");
    // see ETA TAU (moon) [0 to 14]
    panel.scrollBar("scroller").scrollTo(8);
    // Capture observability plot of detailed plot :
    saveScreenshot(getMainTabbedPane(), "Aspro2-moon-obs-det.png");
    // disable detailed plot :
    panel.checkBox("jCheckBoxDetailedOutput").uncheck();
    // disable wind restriction:
    GuiActionRunner.execute(new GuiTask() {

        @Override
        protected void executeInEDT() {
            windWidget.setValue(0d);
        }
    });
    window.checkBox("jCheckBoxWind").uncheck();
    // waits for computation to finish :
    AsproTestUtils.checkRunningTasks();
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) JPanelFixture(org.fest.swing.fixture.JPanelFixture) WindWidget(fr.jmmc.aspro.gui.util.WindWidget) GUITest(org.fest.swing.annotation.GUITest) Test(org.junit.Test) GUITest(org.fest.swing.annotation.GUITest)

Example 2 with GUITest

use of org.fest.swing.annotation.GUITest in project aspro by JMMC-OpenDev.

the class AsproDocJUnitTest method m021_shouldOpenSampleWithCalibrators.

/**
 * Test Open file "Aspro2_sample_with_calibrators.asprox"
 */
@Test
@GUITest
public void m021_shouldOpenSampleWithCalibrators() {
    openObservation("Aspro2_sample_with_calibrators.asprox");
    window.list("jListTargets").selectItem("HD 1583 (cal)");
    // waits for computation to finish :
    AsproTestUtils.checkRunningTasks();
    // Capture observability plot :
    showPlotTab(SettingPanel.TAB_OBSERVABILITY, "Aspro2-calibrators-obs.png");
    // Capture UV Coverage plot :
    showPlotTab(SettingPanel.TAB_UV_COVERAGE, "Aspro2-calibrators-uv.png");
    // Export OIFits / OB :
    exportOIFits();
    exportOB();
    // target editor with calibrators :
    window.button("jButtonTargetEditor").click();
    final DialogFixture dialog = window.dialog(withTitle("Target Editor").andShowing());
    dialog.requireVisible();
    dialog.moveToFront();
    dialog.tabbedPane().selectTab(TargetEditorDialog.TAB_MODELS);
    dialog.tree().selectPath("Models/HD 1583 (cal)/disk1");
    saveScreenshot(dialog, "Aspro2-calibrators-Model.png");
    dialog.tabbedPane().selectTab(TargetEditorDialog.TAB_TARGETS);
    dialog.tree().selectPath("Targets/HIP1234/HD 1583 (cal)");
    saveScreenshot(dialog, "Aspro2-calibrators-Target.png");
    // close dialog :
    dialog.button(JButtonMatcher.withText("Cancel")).click();
}
Also used : DialogFixture(org.fest.swing.fixture.DialogFixture) GUITest(org.fest.swing.annotation.GUITest) Test(org.junit.Test) GUITest(org.fest.swing.annotation.GUITest)

Example 3 with GUITest

use of org.fest.swing.annotation.GUITest in project aspro by JMMC-OpenDev.

the class AsproDocJUnitTest method m024_shouldOpenSampleWithAOTargetGroup.

/**
 * Test Open file "Aspro2_sample_AO_on_SiriusB.asprox" (Target Group Form)
 */
@Test
@GUITest
public void m024_shouldOpenSampleWithAOTargetGroup() {
    final Frame frame = window.target;
    final Point ref = frame.getLocation();
    final DisplayMode mode = frame.getGraphicsConfiguration().getDevice().getDisplayMode();
    try {
        window.moveTo(new Point(mode.getWidth() - frame.getWidth(), ref.y));
        Preferences.getInstance().setPreference(Preferences.MODEL_IMAGE_LUT, ColorModels.COLOR_MODEL_ASPRO);
        openObservation("Aspro2_sample_AO_on_SiriusB.asprox");
        // Capture observability plot :
        showPlotTab(SettingPanel.TAB_OBSERVABILITY, "Aspro2-GroupAO-obs.png");
        // target editor with calibrators :
        window.button("jButtonTargetEditor").click();
        final DialogFixture dialog = window.dialog(withTitle("Target Editor").andShowing());
        dialog.requireVisible();
        dialog.moveToFront();
        dialog.tabbedPane().selectTab(TargetEditorDialog.TAB_GROUPS);
        dialog.tree(TargetGroupForm.TREE_GROUPS).selectPath("Groups/AO Star/Sirius A");
        // highlight group information:
        dialog.tree(TargetGroupForm.TREE_GROUPS).selectPath("Groups/AO Star");
        // waits for computation to finish :
        AsproTestUtils.checkRunningTasks();
        saveScreenshot(dialog, "Aspro2-GroupAO.png");
        // close dialog :
        dialog.button(JButtonMatcher.withText("Cancel")).click();
        window.list("jListTargets").selectItem("Sirius B");
        // select UV tab:
        getMainTabbedPane().selectTab(SettingPanel.TAB_UV_COVERAGE);
        // waits for computation to finish :
        AsproTestUtils.checkRunningTasks();
        enableTooltips(true);
        // move the mouse on Status Warning:
        // note: check window margin issue (gnome3):
        robot().moveMouse(window.component(), 760, 215);
        // let tooltip appear:
        pauseMedium();
        saveScreenshotWithMousePointer(window, "Aspro2-GroupAO-status.png");
    } catch (PreferencesException pe) {
        logger.error("setPreference failed", pe);
    } finally {
        enableTooltips(false);
        try {
            Preferences.getInstance().setPreference(Preferences.MODEL_IMAGE_LUT, Preferences.DEFAULT_IMAGE_LUT);
        } catch (PreferencesException pe) {
            logger.error("setPreference failed", pe);
        }
        // restore position:
        window.moveTo(ref);
    }
}
Also used : DisplayMode(java.awt.DisplayMode) Frame(java.awt.Frame) DialogFixture(org.fest.swing.fixture.DialogFixture) Point(java.awt.Point) PreferencesException(fr.jmmc.jmcs.data.preference.PreferencesException) GUITest(org.fest.swing.annotation.GUITest) Test(org.junit.Test) GUITest(org.fest.swing.annotation.GUITest)

Example 4 with GUITest

use of org.fest.swing.annotation.GUITest in project aspro by JMMC-OpenDev.

the class AsproDocJUnitTest method m010_shouldOpenFeedbackReport.

/**
 * Test Feedback report
 */
@Test
@GUITest
public void m010_shouldOpenFeedbackReport() {
    // hack to solve focus trouble in menu items :
    window.menuItemWithPath("Help").focus();
    window.menuItemWithPath("Help", "Report Feedback to JMMC...").click();
    final DialogFixture dialog = window.dialog(withTitle("Feedback Report ").andShowing());
    dialog.requireVisible();
    dialog.moveToFront();
    final JTextComponentFixture emailField = dialog.textBox(JTextComponentMatcher.withText(FAKE_EMAIL));
    // hide my email address :
    emailField.setText("type your email address here");
    saveScreenshot(dialog, "Aspro2-FeebackReport.png");
    // restore my preferences :
    emailField.setText(FAKE_EMAIL);
    // close dialog :
    dialog.close();
    // reset email preference:
    defineEmailPref(CURRENT_EMAIL);
}
Also used : DialogFixture(org.fest.swing.fixture.DialogFixture) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) GUITest(org.fest.swing.annotation.GUITest) Test(org.junit.Test) GUITest(org.fest.swing.annotation.GUITest)

Example 5 with GUITest

use of org.fest.swing.annotation.GUITest in project aspro by JMMC-OpenDev.

the class AsproDocJUnitTest method m006_shouldShowUVCoverage.

/**
 * Test UV coverage plot
 */
@Test
@GUITest
public void m006_shouldShowUVCoverage() {
    // Capture UV Coverage plot :
    getMainTabbedPane().selectTab(SettingPanel.TAB_UV_COVERAGE);
    final BufferedImage image = takeScreenshotOf(window);
    saveImage(image, "Aspro2-screen.png");
    // TODO : refactor that code :
    // miniature for aspro web page : 350px width :
    final int width = 350;
    final int height = Math.round(1f * width * image.getHeight() / image.getWidth());
    // use Lanczos3 resampler and soft unsharp mask :
    final ResampleOp resampleOp = new ResampleOp(width, height);
    resampleOp.setUnsharpenMask(AdvancedResizeOp.UnsharpenMask.Soft);
    final BufferedImage rescaledImage = resampleOp.filter(image, null);
    saveImage(rescaledImage, "Aspro2-screen-small.png");
    // export PDF :
    exportPDF();
    try {
        enableTooltips(true);
        // move the mouse on one uv measurement:
        // note: check window margin issue (gnome3):
        robot().moveMouse(window.component(), 690, 590);
        // let tooltip appear:
        pauseMedium();
        saveScreenshotWithMousePointer(window, "Aspro2-uv.png");
    } finally {
        enableTooltips(false);
    }
    // Export OIFits / OB :
    exportOIFits();
    exportOB();
}
Also used : ResampleOp(com.mortennobel.imagescaling.ResampleOp) BufferedImage(java.awt.image.BufferedImage) Point(java.awt.Point) GUITest(org.fest.swing.annotation.GUITest) Test(org.junit.Test) GUITest(org.fest.swing.annotation.GUITest)

Aggregations

GUITest (org.fest.swing.annotation.GUITest)20 Test (org.junit.Test)20 JPanelFixture (org.fest.swing.fixture.JPanelFixture)9 DialogFixture (org.fest.swing.fixture.DialogFixture)6 Point (java.awt.Point)4 JSpinnerFixture (org.fest.swing.fixture.JSpinnerFixture)4 PreferencesException (fr.jmmc.jmcs.data.preference.PreferencesException)3 Dimension (java.awt.Dimension)3 GuiTask (org.fest.swing.edt.GuiTask)3 Frame (java.awt.Frame)2 JFormattedTextField (javax.swing.JFormattedTextField)2 FrameFixture (org.fest.swing.fixture.FrameFixture)2 ResampleOp (com.mortennobel.imagescaling.ResampleOp)1 TargetEditorDialog (fr.jmmc.aspro.gui.TargetEditorDialog)1 WindWidget (fr.jmmc.aspro.gui.util.WindWidget)1 Dialog (java.awt.Dialog)1 DisplayMode (java.awt.DisplayMode)1 BufferedImage (java.awt.image.BufferedImage)1 JList (javax.swing.JList)1 GenericTypeMatcher (org.fest.swing.core.GenericTypeMatcher)1