Package net.mindengine.galen.page

Examples of net.mindengine.galen.page.Rect


        StringCharReader reader = new StringCharReader(text);
        for (int i=0;i<numbers.length; i++) {
            numbers[i] = new ExpectNumber().read(reader).intValue();
        }

        return new Rect(numbers);
    }
View Full Code Here


    public void check(PageValidation pageValidation, String objectName, T spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
       
        checkAvailability(mainObject, objectName);
       
        Rect area = mainObject.getArea();
        String realText = mainObject.getText();
        if (realText == null) {
            realText = "";
        }
View Full Code Here

        checkAvailability(mainObject, objectName);
       
        PageElement secondObject = pageValidation.findPageElement(spec.getObject());
        checkAvailability(secondObject, spec.getObject());
       
        Rect mainArea = mainObject.getArea();
        Rect secondArea = secondObject.getArea();
        int offset = getOffset(mainArea, secondArea);
       
       
        Range range = convertRange(spec.getRange(), pageValidation);
       
View Full Code Here

        return String.format("vertically %s", spec.getAlignment().toString());
    }

    @Override
    protected int getOffset(SpecVertically spec, PageElement mainObject, PageElement childObject) {
        Rect mainArea = mainObject.getArea();
        Rect childArea = childObject.getArea();
       
        switch(spec.getAlignment()) {
        case CENTERED:
            return Math.abs(childArea.getLeft() + (childArea.getWidth() / 2) - (mainArea.getLeft() + (mainArea.getWidth() / 2)));
        case LEFT:
            return Math.abs(childArea.getLeft() - mainArea.getLeft());
        case RIGHT:
            return Math.abs(childArea.getLeft() + childArea.getWidth() - (mainArea.getLeft() + mainArea.getWidth()));
        case ALL:
            return Math.max(Math.abs(childArea.getLeft() - mainArea.getLeft()), Math.abs(childArea.getWidth() - mainArea.getWidth()));
        }
        return 0;
    }
View Full Code Here

        return String.format("horizontally %s", spec.getAlignment().toString());
    }

    @Override
    protected int getOffset(SpecHorizontally spec, PageElement mainObject, PageElement childObject) {
        Rect mainArea = mainObject.getArea();
        Rect childArea = childObject.getArea();
       
        switch(spec.getAlignment()) {
        case CENTERED:
            return Math.abs(childArea.getTop() + (childArea.getHeight() / 2) - (mainArea.getTop() + (mainArea.getHeight() / 2)));
        case TOP:
            return Math.abs(childArea.getTop() - mainArea.getTop());
        case BOTTOM:
            return Math.abs(childArea.getTop() + childArea.getHeight() - (mainArea.getTop() + mainArea.getHeight()));
        case ALL:
            return Math.max(Math.abs(childArea.getTop() - mainArea.getTop()), Math.abs(childArea.getHeight() - mainArea.getHeight()));
        }
        return 0;
    }
View Full Code Here

        checkAvailability(mainObject, objectName);

       
        BufferedImage pageImage = pageValidation.getPage().getScreenshotImage();
       
        Rect area = mainObject.getArea();
        if (pageImage.getWidth() < area.getLeft() + area.getWidth() || pageImage.getHeight() < area.getTop() + area.getHeight()) {
            throw new ValidationErrorException()
                .withErrorArea(new ErrorArea(area, objectName))
                .withMessage("Can't fetch image for \"object\" as it is outside of screenshot");
        }
       
       
       
       
       
        Spectrum spectrum;
        try {
            spectrum = Rainbow4J.readSpectrum(pageImage, new Rectangle(area.getLeft(), area.getTop(), area.getWidth(), area.getHeight()), PRECISION);
        } catch (Exception e) {
            throw new ValidationErrorException(String.format("Couldn't fetch spectrum for \"%s\"", objectName));
        }
       
        List<String> messages = new LinkedList<String>();
View Full Code Here

        String value = IOUtils.toString(Galen.class.getResourceAsStream(resourceName));
        FileUtils.writeStringToFile(destFile, value);
    }

    private static boolean isWithinArea(PageElement element, Integer maxWidth, Integer maxHeight) {
        Rect area = element.getArea();
        if (maxWidth != null && maxHeight != null) {
            return maxWidth * maxHeight > area.getWidth() * area.getHeight();
        }
        else if (maxWidth != null) {
            return maxWidth > area.getWidth();
        }
        else if (maxHeight != null) {
            return maxHeight > area.getHeight();
        }
        else return true;
    }
View Full Code Here

    public void check(PageValidation pageValidation, String objectName, SpecContains spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
       
        checkAvailability(mainObject, objectName);
       
        Rect objectArea = mainObject.getArea();
       
        List<String> childObjects = fetchChildObjets(spec.getChildObjects(), pageValidation.getPageSpec());

       
        List<ErrorArea> errorAreas = new LinkedList<ErrorArea>();
        List<String> errorMessages = new LinkedList<String>();
       
        for (String childObjectName : childObjects) {
            PageElement childObject = pageValidation.findPageElement(childObjectName);
            if (childObject != null) {
                if (!childObject.isPresent()) {
                    throw new ValidationErrorException()
                        .withMessage(format(OBJECT_S_IS_ABSENT_ON_PAGE, childObjectName));
                }
                else if (!childObject.isVisible()) {
                    throw new ValidationErrorException()
                        .withMessage(format(OBJECT_S_IS_NOT_VISIBLE_ON_PAGE, childObjectName));
                }
                else {
                    Rect childObjectArea = childObject.getArea();
                    if (!childObjectMatches(spec, objectArea, childObjectArea)) {
                        errorAreas.add(new ErrorArea(childObjectArea, childObjectName));
                        errorMessages.add(format("\"%s\" is outside \"%s\"", childObjectName, objectName));
                    }
                }
View Full Code Here

        checkAvailability(mainObject, objectName);
       
        PageElement secondObject = pageValidation.findPageElement(spec.getObject());
        checkAvailability(secondObject, spec.getObject());
       
        Rect mainArea = mainObject.getArea();
        Rect secondArea = secondObject.getArea();
       
        List<String> messages = new LinkedList<String>();
       
        for (Location location : spec.getLocations()) {
            String message = verifyLocation(mainArea, secondArea, location, pageValidation, spec);
View Full Code Here

    public void check(PageValidation pageValidation, String objectName, SpecCss spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);

        checkAvailability(mainObject, objectName);

        Rect area = mainObject.getArea();
        String realText = mainObject.getCssProperty(spec.getCssPropertyName());
        if (realText == null) {
            realText = "";
        }
View Full Code Here

TOP

Related Classes of net.mindengine.galen.page.Rect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.