Package net.mindengine.galen.page

Examples of net.mindengine.galen.page.PageElement


  }

  @Override
  public void check(PageValidation pageValidation, String objectName, SpecDirectionPosition spec) throws ValidationErrorException {
   
    PageElement mainObject = pageValidation.findPageElement(objectName);
       
        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


    private static final int PRECISION = GalenConfig.getConfig().getIntProperty("spec.colorscheme.precision", 256, 8, 256);
    private static final int TEST_RANGE = GalenConfig.getConfig().getIntProperty("spec.colorscheme.testrange", 6, 0, 256);

    @Override
    public void check(PageValidation pageValidation, String objectName, SpecColorScheme spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
        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");
        }
View Full Code Here

public abstract class SpecValidationSize<T extends SpecRange> extends SpecValidation<T> {

    @Override
    public void check(PageValidation pageValidation, String objectName, T spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
       
        checkAvailability(mainObject, objectName);
       
        int realValue = getSizeValue(mainObject);
       
        Range range = convertRange(spec.getRange(), pageValidation);
       
        if (!range.holds(realValue)) {
                throw new ValidationErrorException()
                    .withErrorArea(new ErrorArea(mainObject.getArea(), objectName))
                    .withMessage(format("\"%s\" %s is %dpx %s", objectName, getUnitName(), realValue, range.getErrorMessageSuffix()));
        }
    }
View Full Code Here

        PageValidation pageValidation = new PageValidation(browser, browser.getPage(), pageSpec, null, null);

        PageDump pageDump = new PageDump();
        pageDump.setTitle(browser.getPage().getTitle());
        for (String objectName : objectNames) {
            PageElement pageElement = pageValidation.findPageElement(objectName);

            if (pageElement.isVisible() && pageElement.getArea() != null) {
                PageDump.Element element = new PageDump.Element(objectName, pageElement.getArea().toIntArray(), pageElement.getText());

                if (pageElement.isPresent() && pageElement.isVisible() && isWithinArea(pageElement, maxWidth, maxHeight)) {
                    element.setHasImage(true);
                }
                pageDump.addElement(element);
            }
        }
View Full Code Here

public class SpecValidationVisible extends SpecValidation<SpecVisible> {

    @Override
    public void check(PageValidation pageValidation, String objectName, SpecVisible spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
        checkAvailability(mainObject, objectName);
    }
View Full Code Here

public class SpecValidationContains extends SpecValidation<SpecContains> {

    @Override
    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

            }
            else {
                currentObject = new LayoutObject();
                currentObject.setName(objectName);
               
                PageElement objectPageElement = pageValidation.findPageElement(objectName);
                if (objectPageElement != null && objectPageElement.isVisible()) {
                    currentObject.setArea(objectPageElement.getArea());
                }
               
                currentSection.getObjects().add(currentObject);
                cachedPageTestObjectsMap.put(objectName, currentObject);
            }
        }
        else {
            LayoutObject parentObject = currentObject;
            currentObject = new LayoutObject(parentObject);
            currentObject.setName(objectName);
           
            PageElement objectPageElement = pageValidation.findPageElement(objectName);
            if (objectPageElement != null && objectPageElement.isVisible()) {
                currentObject.setArea(objectPageElement.getArea());
            }
        }
    }
View Full Code Here

public class SpecValidationAbsent extends SpecValidation<SpecAbsent>{

    @Override
    public void check(PageValidation pageValidation, String objectName, SpecAbsent spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
        if (mainObject == null) {
            throw new ValidationErrorException(String.format(OBJECT_WITH_NAME_S_IS_NOT_DEFINED_IN_PAGE_SPEC, objectName));
        }
        else if (mainObject.isPresent() && mainObject.isVisible()) {
            throw new ValidationErrorException()
                .withErrorArea(new ErrorArea(mainObject.getArea(), objectName))
                .withMessage(format("\"%s\" is not absent on page", objectName));
        }
    }
View Full Code Here

*/
public abstract class SpecValidationGeneral<T extends SpecComplex> extends SpecValidation<T>{

    @Override
    public void check(PageValidation pageValidation, String objectName, T spec) throws ValidationErrorException {
        PageElement mainObject = pageValidation.findPageElement(objectName);
        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 class SpecValidationCss extends SpecValidationText<SpecCss> {

    @Override
    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 = "";
        }

        checkValue(spec, objectName, realText, "css property \"" + spec.getCssPropertyName() + "\"", area);
View Full Code Here

TOP

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

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.