Search in sources :

Example 1 with ToolBarController

use of org.mycore.iview.tests.controller.ToolBarController in project mycore by MyCoRe-Org.

the class ImageOverviewIT method testImageOverview.

@Test
public /**
 * Checks if the image overview works
 * @throws IOException
 * @throws InterruptedException
 */
void testImageOverview() throws IOException, InterruptedException {
    this.setTestName(getClassname() + "-testImageOverview");
    this.getDriver();
    this.getAppController().openViewer(this.getDriver(), getTestDerivate());
    ImageViewerController controller = this.getViewerController();
    ToolBarController tbController = controller.getToolBarController();
    ImageOverviewController ioController = controller.getImageOverviewController();
    tbController.pressButton(ToolBarController.BUTTON_ID_ZOOM_IN);
    tbController.pressButton(ToolBarController.BUTTON_ID_SIDEBAR_CONTROLL);
    tbController.clickElementById(ImageOverviewController.IMAGE_OVERVIEW_SELECTOR);
    Thread.sleep(500);
    int greenPixelCount = clickImgAndCountColor(ioController, getGreenLabel(), Color.GREEN);
    int redPixelCount = clickImgAndCountColor(ioController, getRedLabel(), Color.RED);
    ioController.scrollSidbar(getDriver(), 250);
    int bluePixelCount = clickImgAndCountColor(ioController, getBlueLabel(), Color.BLUE);
    ioController.scrollSidbar(getDriver(), 250);
    int redPixelCountRGB = clickImgAndCountColor(ioController, getRgbLabel(), Color.RED);
    int greenPixelCountRGB = clickImgAndCountColor(ioController, getRgbLabel(), Color.GREEN);
    int bluePixelCountRGB = clickImgAndCountColor(ioController, getRgbLabel(), Color.BLUE);
    String messagePattern = "There should be less red pixels in the rgb screenshot than in the red ({0} > {1})";
    assertLess(redPixelCount, redPixelCountRGB, messagePattern);
    messagePattern = "There should be less green pixels in the rgb screenshot than in the green ({0} > {1})";
    assertLess(greenPixelCount, greenPixelCountRGB, messagePattern);
    messagePattern = "There should be less blue pixels in the rgb screenshot than in the blue ({0} > {1})";
    assertLess(bluePixelCount, bluePixelCountRGB, messagePattern);
}
Also used : ImageOverviewController(org.mycore.iview.tests.controller.ImageOverviewController) ImageViewerController(org.mycore.iview.tests.controller.ImageViewerController) ToolBarController(org.mycore.iview.tests.controller.ToolBarController) Test(org.junit.Test)

Example 2 with ToolBarController

use of org.mycore.iview.tests.controller.ToolBarController in project mycore by MyCoRe-Org.

the class ImageSectionIT method testImageZoom.

@Test
public /**
 * Checks if the zoom button works!
 * @throws IOException
 * @throws InterruptedException
 */
void testImageZoom() throws IOException, InterruptedException {
    this.setTestName(getClassname() + "-testImageZoom");
    this.getDriver();
    this.getAppController().openViewer(this.getDriver(), getTestDerivate());
    ImageViewerController controller = this.getViewerController();
    ToolBarController tbController = controller.getToolBarController();
    tbController.selectPictureWithOrder(getStartImage());
    tbController.pressButton(ToolBarController.BUTTON_ID_ZOOM_WIDTH);
    Thread.sleep(DELAY_TIME);
    BufferedImage notZoomed = ControllerUtil.getScreenshot(getDriver(), this.getClassname() + "-notZoomed");
    int redPixelCountNotZoomed = getColorCount(notZoomed, Color.RED);
    int greenPixelCountNotZoomed = getColorCount(notZoomed, Color.GREEN);
    // -
    tbController.pressButton(ToolBarController.BUTTON_ID_ZOOM_IN);
    Thread.sleep(DELAY_TIME);
    BufferedImage zoomed = ControllerUtil.getScreenshot(getDriver(), this.getClassname() + "-zoomed");
    int redPixelCountZoomed = getColorCount(zoomed, Color.RED);
    int greenPixelCountZoomed = getColorCount(zoomed, Color.GREEN);
    int bluePixelCountZoomed = getColorCount(zoomed, Color.BLUE);
    String message1Pattern = "There should be less red pixels in the zoomed screenshot than in the not zoomed ({0} > {1})";
    assertLess(redPixelCountNotZoomed, redPixelCountZoomed, message1Pattern);
    String message2Pattern = "There should be less green pixels in the not zoomed screenshot than in the zoomed ({0} < {1})";
    assertLess(greenPixelCountZoomed, greenPixelCountNotZoomed, message2Pattern);
    // -
    tbController.pressButton(ToolBarController.BUTTON_ID_ZOOM_IN);
    Thread.sleep(DELAY_TIME);
    BufferedImage zoomed2 = ControllerUtil.getScreenshot(getDriver(), this.getClassname() + "-zoomed2");
    int greenPixelCountZoomed2 = getColorCount(zoomed2, Color.GREEN);
    int bluePixelCountZoomed2 = getColorCount(zoomed2, Color.BLUE);
    String message3Pattern = "There should be less blue pixels in the zoomed screenshot than in the zoomed2 ({0} > {1})";
    assertLess(bluePixelCountZoomed2, bluePixelCountZoomed, message3Pattern);
    String message4Pattern = "There should be less green pixels in the zoomed2 screenshot than in the zoomed ({0} > {1})";
    assertLess(greenPixelCountZoomed, greenPixelCountZoomed2, message4Pattern);
    // -
    tbController.pressButton(ToolBarController.BUTTON_ID_ZOOM_OUT);
    Thread.sleep(DELAY_TIME);
    BufferedImage zoomed3 = ControllerUtil.getScreenshot(getDriver(), this.getClassname() + "zoomed3");
    int greenPixelCountZoomed3 = getColorCount(zoomed3, Color.GREEN);
    int bluePixelCountZoomed3 = getColorCount(zoomed3, Color.BLUE);
    int redPixelCountZoomed3 = getColorCount(zoomed3, Color.RED);
    String message5Pattern = "There should be less green pixels in the zoomed2 screenshot than in the zoomed3 ({0} > {1})";
    assertLess(greenPixelCountZoomed3, greenPixelCountZoomed2, message5Pattern);
    String message6Pattern = "There should be less blue pixels in the zoomed3 screenshot than in the zoomed2 ({0} > {1})";
    assertLess(bluePixelCountZoomed2, bluePixelCountZoomed3, message6Pattern);
    // -
    tbController.pressButton(ToolBarController.BUTTON_ID_ZOOM_OUT);
    Thread.sleep(DELAY_TIME);
    BufferedImage zoomed4 = ControllerUtil.getScreenshot(getDriver(), this.getClassname() + "zoomed4");
    int greenPixelCountZoomed4 = getColorCount(zoomed4, Color.GREEN);
    int bluePixelCountZoomed4 = getColorCount(zoomed4, Color.BLUE);
    int redPixelCountZoomed4 = getColorCount(zoomed4, Color.RED);
    tbController.pressButton(ToolBarController.BUTTON_ID_ZOOM_OUT);
    Thread.sleep(DELAY_TIME);
    String message7Pattern = "There should be less blue pixels in the zoomed4 screenshot than in the zoomed3 ({0} > {1})";
    assertLess(bluePixelCountZoomed3, bluePixelCountZoomed4, message7Pattern);
    String message8Pattern = "There should be less green pixels in the zoomed4 screenshot than in the zoomed3 ({0} > {1})";
    assertLess(greenPixelCountZoomed3, greenPixelCountZoomed4, message8Pattern);
    String message9Pattern = "There should be less red pixels in the zoomed3 screenshot than in the zoomed4 ({0} > {1})";
    assertLess(redPixelCountZoomed4, redPixelCountZoomed3, message9Pattern);
}
Also used : ImageViewerController(org.mycore.iview.tests.controller.ImageViewerController) ToolBarController(org.mycore.iview.tests.controller.ToolBarController) BufferedImage(java.awt.image.BufferedImage) Test(org.junit.Test)

Example 3 with ToolBarController

use of org.mycore.iview.tests.controller.ToolBarController in project mycore by MyCoRe-Org.

the class NavbarIT method testNavigationPrev.

@Test
public void testNavigationPrev() throws InterruptedException {
    this.setTestName(getClassname() + "-testStructureOverview");
    this.getDriver();
    this.getAppController().openViewer(this.getDriver(), getTestDerivate());
    ImageViewerController controller = this.getViewerController();
    ToolBarController tbController = controller.getToolBarController();
    int redPixelCountRGB = selectImgAndCountColor(tbController, getRgbLabel(), Color.RED);
    int greenPixelCountRGB = selectImgAndCountColor(tbController, getRgbLabel(), Color.GREEN);
    int bluePixelCountRGB = selectImgAndCountColor(tbController, getRgbLabel(), Color.BLUE);
    int bluePixelCount = selectPrevImgAndCountColor(tbController, getBlueLabel(), Color.BLUE);
    int greenPixelCount = selectPrevImgAndCountColor(tbController, getGreenLabel(), Color.GREEN);
    int redPixelCount = selectPrevImgAndCountColor(tbController, getRedLabel(), Color.RED);
    String messagePattern = "There should be less red pixels in the rgb screenshot than in the red ({0} > {1})";
    assertLess(redPixelCount, redPixelCountRGB, messagePattern);
    messagePattern = "There should be less green pixels in the rgb screenshot than in the green ({0} > {1})";
    assertLess(greenPixelCount, greenPixelCountRGB, messagePattern);
    messagePattern = "There should be less blue pixels in the rgb screenshot than in the blue ({0} > {1})";
    assertLess(bluePixelCount, bluePixelCountRGB, messagePattern);
}
Also used : ImageViewerController(org.mycore.iview.tests.controller.ImageViewerController) ToolBarController(org.mycore.iview.tests.controller.ToolBarController) Test(org.junit.Test)

Example 4 with ToolBarController

use of org.mycore.iview.tests.controller.ToolBarController in project mycore by MyCoRe-Org.

the class NavbarIT method testNavigationNext.

@Test
public void testNavigationNext() throws InterruptedException {
    this.setTestName(getClassname() + "-testStructureOverview");
    this.getDriver();
    this.getAppController().openViewer(this.getDriver(), getTestDerivate());
    ImageViewerController controller = this.getViewerController();
    ToolBarController tbController = controller.getToolBarController();
    int redPixelCountRGB = selectImgAndCountColor(tbController, getRgbLabel(), Color.RED);
    int greenPixelCountRGB = countColor(tbController, getRgbLabel(), Color.GREEN);
    int bluePixelCountRGB = countColor(tbController, getRgbLabel(), Color.BLUE);
    int redPixelCount = selectImgAndCountColor(tbController, getRedLabel(), Color.RED);
    String messagePattern = "There should be less red pixels in the rgb screenshot than in the red ({0} > {1})";
    assertLess(redPixelCount, redPixelCountRGB, messagePattern);
    int greenPixelCount = selectNextImgAndCountColor(tbController, getGreenLabel(), Color.GREEN);
    messagePattern = "There should be less green pixels in the rgb screenshot than in the green ({0} > {1})";
    assertLess(greenPixelCount, greenPixelCountRGB, messagePattern);
    int bluePixelCount = selectNextImgAndCountColor(tbController, getBlueLabel(), Color.BLUE);
    messagePattern = "There should be less blue pixels in the rgb screenshot than in the blue ({0} > {1})";
    assertLess(bluePixelCount, bluePixelCountRGB, messagePattern);
}
Also used : ImageViewerController(org.mycore.iview.tests.controller.ImageViewerController) ToolBarController(org.mycore.iview.tests.controller.ToolBarController) Test(org.junit.Test)

Example 5 with ToolBarController

use of org.mycore.iview.tests.controller.ToolBarController in project mycore by MyCoRe-Org.

the class SideBarIT method testSideBarResize.

@Test
public /**
 * Ignored because https://github.com/mozilla/geckodriver/issues/233
 */
void testSideBarResize() throws Exception {
    this.setTestName(getClassname() + "-testSideBarResize");
    this.getDriver();
    this.getAppController().openViewer(this.getDriver(), getTestDerivate());
    ImageViewerController controller = this.getViewerController();
    ToolBarController tbController = controller.getToolBarController();
    SideBarController sbController = controller.getSideBarController();
    tbController.pressButton(ToolBarController.BUTTON_ID_SIDEBAR_CONTROLL);
    tbController.clickElementById(ImageOverviewController.IMAGE_OVERVIEW_SELECTOR);
    int sbWidthStart = sbController.getSideBarWidth();
    try {
        // Firefox does not support actions so we just let the test pass.
        sbController.dragAndDropByXpath("//div[contains(@class,\"sidebar\")]/span[@class=\"resizer\"]", 50, 0);
    } catch (UnsupportedCommandException e) {
        LOGGER.warn("Driver does not support Actions", e);
        return;
    }
    int sbWidthEnd = sbController.getSideBarWidth();
    assertLess(sbWidthEnd, sbWidthStart, "Sidebar width schould be increased!");
}
Also used : UnsupportedCommandException(org.openqa.selenium.UnsupportedCommandException) SideBarController(org.mycore.iview.tests.controller.SideBarController) ImageViewerController(org.mycore.iview.tests.controller.ImageViewerController) ToolBarController(org.mycore.iview.tests.controller.ToolBarController) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 ImageViewerController (org.mycore.iview.tests.controller.ImageViewerController)8 ToolBarController (org.mycore.iview.tests.controller.ToolBarController)8 SideBarController (org.mycore.iview.tests.controller.SideBarController)3 UnsupportedCommandException (org.openqa.selenium.UnsupportedCommandException)2 BufferedImage (java.awt.image.BufferedImage)1 ImageOverviewController (org.mycore.iview.tests.controller.ImageOverviewController)1 StructureOverviewController (org.mycore.iview.tests.controller.StructureOverviewController)1