How to use shouldReadSpec_absent method of com.galenframework.tests.speclang2.SpecsReaderV2Test class

Best Galen code snippet using com.galenframework.tests.speclang2.SpecsReaderV2Test.shouldReadSpec_absent

Source:SpecsReaderV2Test.java Github

copy

Full Screen

...334 public void shouldGiveError_aligned_horizontally_left() {335 readSpec("aligned horizontally left");336 }337 @Test338 public void shouldReadSpec_absent() throws IOException {339 Spec spec = readSpec("absent");340 assertThat(spec, instanceOf(SpecAbsent.class));341 assertThat(spec.getOriginalText(), is("absent"));342 }343 @Test344 public void shouldReadSpec_visible() throws IOException {345 Spec spec = readSpec("visible");346 assertThat(spec, instanceOf(SpecVisible.class));347 assertThat(spec.getOriginalText(), is("visible"));348 }349 @Test350 public void shouldReadSpec_width_10px() throws IOException {351 SpecWidth spec = (SpecWidth) readSpec("width 10px");352 assertThat(spec.getRange(), is(Range.exact(10)));353 assertThat(spec.getOriginalText(), is("width 10px"));354 }355 @Test356 public void shouldReadSpec_width_5_to_8px() throws IOException {357 SpecWidth spec = (SpecWidth) readSpec("width 5 to 8px");358 assertThat(spec.getRange(), is(Range.between(5, 8)));359 assertThat(spec.getOriginalText(), is("width 5 to 8px"));360 }361 @Test362 public void shouldReadSpec_width_100_percent_of_other_object_width() throws IOException {363 SpecWidth spec = (SpecWidth) readSpec("width 100% of main-big-container/width");364 assertThat(spec.getRange(), is(Range.exact(100).withPercentOf("main-big-container/width")));365 assertThat(spec.getOriginalText(), is("width 100% of main-big-container/width"));366 }367 @Test368 public void shouldReadSpec_height_10px() throws IOException {369 SpecHeight spec = (SpecHeight) readSpec("height 10px");370 assertThat(spec.getRange(), is(Range.exact(10)));371 assertThat(spec.getOriginalText(), is("height 10px"));372 }373 @Test374 public void shouldReadSpec_height_5_to_8px() throws IOException {375 SpecHeight spec = (SpecHeight) readSpec("height 5 to 8px");376 assertThat(spec.getRange(), is(Range.between(5, 8)));377 assertThat(spec.getOriginalText(), is("height 5 to 8px"));378 }379 @Test(expectedExceptions = SyntaxException.class,380 expectedExceptionsMessageRegExp = "Unexpected token: 1234 px")381 public void shouldGiveError_width_unexcpected_token() {382 readSpec("width 10 to 40 px 1234 px ");383 }384 @Test385 public void shouldReadSpec_text_is_some_text() throws IOException {386 SpecText spec = (SpecText)readSpec("text is \"Some text\"");387 assertThat(spec.getText(), is("Some text"));388 assertThat(spec.getType(), is(SpecText.Type.IS));389 }390 @Test391 public void shouldReadSpec_text_is_some_text_2() throws IOException {392 SpecText spec = (SpecText)readSpec("text is \"Some text\\\" with \\t special \\n symbols\"");393 assertThat(spec.getText(), is("Some text\" with \t special \n symbols"));394 assertThat(spec.getType(), is(SpecText.Type.IS));395 }396 @Test397 public void shouldReadSpec_text_is_empty() throws IOException {398 SpecText spec = (SpecText)readSpec("text is \"\"");399 assertThat(spec.getText(), is(""));400 assertThat(spec.getType(), is(SpecText.Type.IS));401 }402 @Test403 public void shouldReadSpec_text_contains_some_text() throws IOException {404 SpecText spec = (SpecText)readSpec("text contains \"Some text\" ");405 assertThat(spec.getText(), is("Some text"));406 assertThat(spec.getType(), is(SpecText.Type.CONTAINS));407 }408 @Test409 public void shouldReadSpec_text_startsWith_some_text() throws IOException {410 SpecText spec = (SpecText)readSpec("text starts \"Some text\" ");411 assertThat(spec.getText(), is("Some text"));412 assertThat(spec.getType(), is(SpecText.Type.STARTS));413 }414 @Test415 public void shouldReadSpec_text_endssWith_some_text() throws IOException {416 SpecText spec = (SpecText)readSpec("text ends \"Some text\" ");417 assertThat(spec.getText(), is("Some text"));418 assertThat(spec.getType(), is(SpecText.Type.ENDS));419 }420 @Test421 public void shouldReadSpec_text_matches_some_text() throws IOException {422 SpecText spec = (SpecText)readSpec("text matches \"Some * text\" ");423 assertThat(spec.getText(), is("Some * text"));424 assertThat(spec.getType(), is(SpecText.Type.MATCHES));425 }426 @Test427 public void shouldReadSpec_text_lowercase_is() throws IOException {428 SpecText spec = (SpecText)readSpec("text lowercase is \"some text\"");429 assertThat(spec.getText(), is("some text"));430 assertThat(spec.getType(), is(SpecText.Type.IS));431 assertThat(spec.getOperations(), contains("lowercase"));432 }433 @Test434 public void shouldReadSpec_text_lowercase_uppercase_is() throws IOException {435 SpecText spec = (SpecText)readSpec("text lowercase uppercase is \"SOME TEXT\"");436 assertThat(spec.getText(), is("SOME TEXT"));437 assertThat(spec.getType(), is(SpecText.Type.IS));438 assertThat(spec.getOperations(), contains("lowercase", "uppercase"));439 }440 @Test441 public void shouldReadSpec_text_singleline() throws IOException {442 SpecText spec = (SpecText)readSpec("text singleline is \"Some text\"");443 assertThat(spec.getText(), is("Some text"));444 assertThat(spec.getType(), is(SpecText.Type.IS));445 assertThat(spec.getOperations(), contains("singleline"));446 }447 @Test448 public void shouldReadSpec_css_fontsize_is_18px() throws IOException {449 SpecCss spec = (SpecCss)readSpec("css font-size is \"18px\"");450 assertThat(spec.getCssPropertyName(), is("font-size"));451 assertThat(spec.getText(), is("18px"));452 assertThat(spec.getType(), is(SpecText.Type.IS));453 }454 @Test455 public void shouldReadSpec_css_fontsize_starts() throws IOException {456 SpecCss spec = (SpecCss)readSpec("css font-size starts \"18px\"");457 assertThat(spec.getCssPropertyName(), is("font-size"));458 assertThat(spec.getText(), is("18px"));459 assertThat(spec.getType(), is(SpecText.Type.STARTS));460 }461 @Test462 public void shouldReadSpec_css_fontsize_ends() throws IOException {463 SpecCss spec = (SpecCss)readSpec("css font-size ends \"18px\"");464 assertThat(spec.getCssPropertyName(), is("font-size"));465 assertThat(spec.getText(), is("18px"));466 assertThat(spec.getType(), is(SpecText.Type.ENDS));467 }468 @Test469 public void shouldReadSpec_css_fontsize_contains() throws IOException {470 SpecCss spec = (SpecCss)readSpec("css font-size contains \"18px\"");471 assertThat(spec.getCssPropertyName(), is("font-size"));472 assertThat(spec.getText(), is("18px"));473 assertThat(spec.getType(), is(SpecText.Type.CONTAINS));474 }475 @Test476 public void shouldReadSpec_css_fontsize_matches() throws IOException {477 SpecCss spec = (SpecCss)readSpec("css font-size matches \"18px\"");478 assertThat(spec.getCssPropertyName(), is("font-size"));479 assertThat(spec.getText(), is("18px"));480 assertThat(spec.getType(), is(SpecText.Type.MATCHES));481 }482 @Test483 public void shouldReadSpec_above_object_20px() throws IOException {484 SpecAbove spec = (SpecAbove)readSpec("above object 20px");485 assertThat(spec.getObject(), is("object"));486 assertThat(spec.getRange(), is(Range.exact(20)));487 }488 @Test489 public void shouldReadSpec_above_object_10_20px() throws IOException {490 SpecAbove spec = (SpecAbove)readSpec("above object 10 to 20px");491 assertThat(spec.getObject(), is("object"));492 assertThat(spec.getRange(), is(Range.between(10, 20)));493 }494 @Test495 public void shouldReadSpec_above() throws IOException {496 SpecAbove spec = (SpecAbove)readSpec("above object");497 assertThat(spec.getObject(), is("object"));498 assertThat(spec.getRange(), is(Range.greaterThanOrEquals(0)));499 }500 @Test501 public void shouldReadSpec_below() throws IOException {502 SpecBelow spec = (SpecBelow)readSpec("below object");503 assertThat(spec.getObject(), is("object"));504 assertThat(spec.getRange(), is(Range.greaterThanOrEquals(0)));505 }506 @Test507 public void shouldReadSpec_below_object_20px() throws IOException {508 SpecBelow spec = (SpecBelow)readSpec("below object 20px");509 assertThat(spec.getObject(), is("object"));510 assertThat(spec.getRange(), is(Range.exact(20)));511 }512 @Test513 public void shouldReadSpec_below_object_10_to_20px() throws IOException {514 SpecBelow spec = (SpecBelow)readSpec("below object 10 to 20px");515 assertThat(spec.getObject(), is("object"));516 assertThat(spec.getRange(), is(Range.between(10, 20)));517 }518 @Test519 public void shouldReadSpec_left_of_object_10px() throws IOException {520 SpecLeftOf specLeftOf = (SpecLeftOf)readSpec("left-of object 10px");521 assertThat(specLeftOf.getObject(), is("object"));522 assertThat(specLeftOf.getRange(), is(Range.exact(10)));523 }524 @Test525 public void shouldReadSpec_left_of_object_10_to_20px() throws IOException {526 SpecLeftOf specLeftOf = (SpecLeftOf)readSpec("left-of object 10 to 20px");527 assertThat(specLeftOf.getObject(), is("object"));528 assertThat(specLeftOf.getRange(), is(Range.between(10, 20)));529 }530 @Test531 public void shouldReadSpec_left_of_object() throws IOException {532 SpecLeftOf specLeftOf = (SpecLeftOf)readSpec("left-of object");533 assertThat(specLeftOf.getObject(), is("object"));534 assertThat(specLeftOf.getRange(), is(Range.greaterThanOrEquals(0)));535 }536 @Test537 public void shouldReadSpec_right_of_object_10px() throws IOException {538 SpecRightOf specRightOf = (SpecRightOf)readSpec("right-of object 10px");539 assertThat(specRightOf.getObject(), is("object"));540 assertThat(specRightOf.getRange(), is(Range.exact(10)));541 }542 @Test543 public void shouldReadSpec_right_of_object_10_to_20px() throws IOException {544 SpecRightOf specRightOf = (SpecRightOf)readSpec("right-of object 10 to 20px");545 assertThat(specRightOf.getObject(), is("object"));546 assertThat(specRightOf.getRange(), is(Range.between(10, 20)));547 }548 @Test549 public void shouldReadSpec_right_of_object() throws IOException {550 SpecRightOf specRightOf = (SpecRightOf)readSpec("right-of object");551 assertThat(specRightOf.getObject(), is("object"));552 assertThat(specRightOf.getRange(), is(Range.greaterThanOrEquals(0)));553 }554 @Test(expectedExceptions = {SyntaxException.class},555 expectedExceptionsMessageRegExp = "Missing validation type \\(is, contains, starts, ends, matches\\)"556 )557 public void shouldGiveException_empty_css_spec() throws IOException {558 readSpec("css \"18px\"");559 }560 @Test(expectedExceptions = {SyntaxException.class},561 expectedExceptionsMessageRegExp = "Unknown validation type: \"18px\""562 )563 public void shouldGiveException_css_without_type() throws IOException {564 readSpec("css font-size \"18px\"");565 }566 @Test567 public void shouldReadSpec_centered_inside_object() throws IOException {568 SpecCentered spec = (SpecCentered)readSpec("centered inside object");569 assertThat(spec.getObject(), is("object"));570 assertThat(spec.getLocation(), is(SpecCentered.Location.INSIDE));571 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.ALL));572 }573 @Test574 public void shouldReadSpec_centered_horizontally_inside_object() throws IOException {575 SpecCentered spec = (SpecCentered)readSpec("centered horizontally inside object");576 assertThat(spec.getObject(), is("object"));577 assertThat(spec.getLocation(), is(SpecCentered.Location.INSIDE));578 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.HORIZONTALLY));579 }580 @Test581 public void shouldReadSpec_centered_vertically_inside_object() throws IOException {582 SpecCentered spec = (SpecCentered)readSpec("centered vertically inside object");583 assertThat(spec.getObject(), is("object"));584 assertThat(spec.getLocation(), is(SpecCentered.Location.INSIDE));585 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.VERTICALLY));586 }587 @Test588 public void shouldReadSpec_centered_all_inside_object() throws IOException {589 SpecCentered spec = (SpecCentered)readSpec("centered all inside object");590 assertThat(spec.getObject(), is("object"));591 assertThat(spec.getLocation(), is(SpecCentered.Location.INSIDE));592 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.ALL));593 }594 @Test595 public void shouldReadSpec_centered_all_on_object() throws IOException {596 SpecCentered spec = (SpecCentered)readSpec("centered all on object");597 assertThat(spec.getObject(), is("object"));598 assertThat(spec.getLocation(), is(SpecCentered.Location.ON));599 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.ALL));600 }601 @Test602 public void shouldReadSpec_centered_on_object() throws IOException {603 SpecCentered spec = (SpecCentered)readSpec("centered on object");604 assertThat(spec.getObject(), is("object"));605 assertThat(spec.getLocation(), is(SpecCentered.Location.ON));606 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.ALL));607 }608 @Test609 public void shouldReadSpec_centered_horizontally_on_object() throws IOException {610 SpecCentered spec = (SpecCentered)readSpec("centered horizontally on object");611 assertThat(spec.getObject(), is("object"));612 assertThat(spec.getLocation(), is(SpecCentered.Location.ON));613 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.HORIZONTALLY));614 }615 @Test616 public void shouldReadSpec_centered_horizontally_on_object_25px() throws IOException {617 SpecCentered spec = (SpecCentered)readSpec("centered horizontally on object 25px");618 assertThat(spec.getObject(), is("object"));619 assertThat(spec.getLocation(), is(SpecCentered.Location.ON));620 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.HORIZONTALLY));621 assertThat(spec.getErrorRate(), is(25));622 }623 @Test624 public void shouldReadSpec_centered_horizontally_on_object_25_px() throws IOException {625 SpecCentered spec = (SpecCentered)readSpec("centered horizontally on object 25 px");626 assertThat(spec.getObject(), is("object"));627 assertThat(spec.getLocation(), is(SpecCentered.Location.ON));628 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.HORIZONTALLY));629 assertThat(spec.getErrorRate(), is(25));630 }631 @Test632 public void shouldReadSpec_centered_vertically_on_object() throws IOException {633 SpecCentered spec = (SpecCentered)readSpec("centered vertically on object");634 assertThat(spec.getObject(), is("object"));635 assertThat(spec.getLocation(), is(SpecCentered.Location.ON));636 assertThat(spec.getAlignment(), is(SpecCentered.Alignment.VERTICALLY));637 }638 @Test639 public void shoulReadSpec_on_object_10px_left() throws IOException {640 SpecOn spec = (SpecOn)readSpec("on edge object 10px left");641 assertThat(spec.getSideHorizontal(), is(TOP));642 assertThat(spec.getSideVertical(), is(LEFT));643 assertThat(spec.getObject(), is("object"));644 List<Location> locations = spec.getLocations();645 assertThat(locations.size(), is(1));646 assertThat(spec.getLocations(), contains(new Location(Range.exact(10), sides(LEFT))));647 assertThat(spec.getOriginalText(), is("on edge object 10px left"));648 }649 @Test650 public void shoulReadSpec_on_object_10px_left_20px_top() throws IOException {651 SpecOn spec = (SpecOn)readSpec("on edge object 10px left, 20px top");652 assertThat(spec.getSideHorizontal(), is(TOP));653 assertThat(spec.getSideVertical(), is(LEFT));654 assertThat(spec.getObject(), is("object"));655 List<Location> locations = spec.getLocations();656 assertThat(locations.size(), is(2));657 assertThat(spec.getLocations(), contains(new Location(Range.exact(10), sides(LEFT)), new Location(Range.exact(20), sides(TOP))));658 assertThat(spec.getOriginalText(), is("on edge object 10px left, 20px top"));659 }660 @Test661 public void shouldReadSpec_on_top_object_10px_top_right() throws Exception {662 SpecOn spec = (SpecOn)readSpec("on top edge object 10px top right");663 assertThat(spec.getSideHorizontal(), is(TOP));664 assertThat(spec.getSideVertical(), is(LEFT));665 assertThat(spec.getObject(), is("object"));666 List<Location> locations = spec.getLocations();667 assertThat(locations.size(), is(1));668 assertThat(spec.getLocations(), contains(new Location(Range.exact(10), sides(TOP, RIGHT))));669 assertThat(spec.getOriginalText(), is("on top edge object 10px top right"));670 }671 @Test672 public void shouldReadSpec_on_left_object_10px_top_right() throws Exception {673 SpecOn spec = (SpecOn)readSpec("on left edge object 10px top right");674 assertThat(spec.getSideHorizontal(), is(TOP));675 assertThat(spec.getSideVertical(), is(LEFT));676 assertThat(spec.getObject(), is("object"));677 List<Location> locations = spec.getLocations();678 assertThat(locations.size(), is(1));679 assertThat(spec.getLocations(), contains(new Location(Range.exact(10), sides(TOP, RIGHT))));680 assertThat(spec.getOriginalText(), is("on left edge object 10px top right"));681 }682 @Test683 public void shouldReadSpec_on_bottom_right_object_10px_top_right() throws Exception {684 SpecOn spec = (SpecOn)readSpec("on right bottom edge object 10px top right");685 assertThat(spec.getSideHorizontal(), is(BOTTOM));686 assertThat(spec.getSideVertical(), is(RIGHT));687 assertThat(spec.getObject(), is("object"));688 List<Location> locations = spec.getLocations();689 assertThat(locations.size(), is(1));690 assertThat(spec.getLocations(), contains(new Location(Range.exact(10), sides(TOP, RIGHT))));691 assertThat(spec.getOriginalText(), is("on right bottom edge object 10px top right"));692 }693 @Test(expectedExceptions = SyntaxException.class,694 expectedExceptionsMessageRegExp = "Missing \"edge\"")695 public void shouldGiveError_missingEdges_forSpec_on() throws Exception {696 readSpec("on top left object 10px");697 }698 @Test699 public void shouldReadSpec_color_scheme_40percent_black_approx_30percent_white() throws Exception {700 SpecColorScheme spec = (SpecColorScheme)readSpec("color-scheme 40% black , ~30% white");701 List<ColorRange> colors = spec.getColorRanges();702 assertThat(colors.size(), is(2));703 assertThat(colors.get(0).getRange(), is(Range.exact(40)));704 assertThat(colors.get(0).getColorClassifier(), is(new SimpleColorClassifier("black", new Color(0, 0, 0))));705 assertThat(colors.get(1).getRange(), is(Range.between(28, 32)));706 assertThat(colors.get(1).getColorClassifier(), is(new SimpleColorClassifier("white", new Color(255, 255, 255))));707 }708 @Test709 public void shouldReadSpec_color_scheme_greater_than_40percent_ffaa03() throws Exception {710 SpecColorScheme spec = (SpecColorScheme)readSpec("color-scheme > 40% #ffaa03");711 List<ColorRange> colors = spec.getColorRanges();712 assertThat(colors.size(), is(1));713 assertThat(colors.get(0).getRange(), is(Range.greaterThan(40)));714 assertThat(colors.get(0).getColorClassifier(), is(new SimpleColorClassifier("#ffaa03", new Color(255, 170, 3))));715 }716 @Test717 public void shouldReadSpec_color_scheme_40_to_50percent_ffaa03() throws Exception {718 SpecColorScheme spec = (SpecColorScheme)readSpec("color-scheme 40 to 50% red");719 List<ColorRange> colors = spec.getColorRanges();720 assertThat(colors.size(), is(1));721 assertThat(colors.get(0).getRange(), is(Range.between(40, 50)));722 assertThat(colors.get(0).getColorClassifier(), is(new SimpleColorClassifier("red", new Color(255, 0, 0))));723 }724 @Test725 public void shouldReadSpec_color_withShorthand_hexColorNotation() throws Exception {726 SpecColorScheme spec = (SpecColorScheme)readSpec("color-scheme 40% #f3e");727 List<ColorRange> colors = spec.getColorRanges();728 assertThat(colors.size(), is(1));729 assertThat(colors.get(0).getRange(), is(Range.exact(40)));730 assertThat(colors.get(0).getColorClassifier(), is(new SimpleColorClassifier("#f3e", new Color(255, 51, 238))));731 }732 @Test733 public void shouldReadSpec_color_withGradients() throws Exception {734 SpecColorScheme spec = (SpecColorScheme)readSpec("color-scheme 40% white-green-blue");735 List<ColorRange> colors = spec.getColorRanges();736 assertThat(colors.size(), is(1));737 assertThat(colors.get(0).getRange(), is(Range.exact(40)));738 assertThat(colors.get(0).getColorClassifier(), is(new GradientColorClassifier("white-green-blue", asList(739 new Color(255, 255, 255),740 new Color(0, 255, 0),741 new Color(0, 0, 255)742 ))));743 }744 @Test745 public void shouldReadSpec_color_withGradients_2() throws Exception {746 SpecColorScheme spec = (SpecColorScheme)readSpec("color-scheme 40% white - green - blue, 10 to 23% #a3f - #00e");747 List<ColorRange> colors = spec.getColorRanges();748 assertThat(colors.size(), is(2));749 assertThat(colors.get(0).getRange(), is(Range.exact(40)));750 assertThat(colors.get(0).getColorClassifier(), is(new GradientColorClassifier("white - green - blue", asList(751 new Color(255, 255, 255),752 new Color(0, 255, 0),753 new Color(0, 0, 255)754 ))));755 assertThat(colors.get(1).getRange(), is(Range.between(10, 23)));756 assertThat(colors.get(1).getColorClassifier(), is(new GradientColorClassifier("#a3f - #00e", asList(757 new Color(170, 51, 255),758 new Color(0, 0, 238)759 ))));760 }761 @Test762 public void shouldReadSpec_image_withMaxPercentageError() throws IOException {763 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 2.4%");764 assertThat(spec.getImagePaths(), contains("imgs/image.png"));765 assertThat(spec.getErrorRate().getValue(), is(2.4));766 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PERCENT));767 assertThat(spec.getTolerance(), is(25));768 }769 @Test770 public void shouldReadSpec_image_withMaxPixelsError() throws IOException {771 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 112 px");772 assertThat(spec.getImagePaths(), contains("imgs/image.png"));773 assertThat(spec.getErrorRate().getValue(), is(112.0));774 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));775 assertThat(spec.getTolerance(), is(25));776 }777 @Test778 public void shouldReadSpec_image_withMaxPixelsError_tolerance5() throws IOException {779 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 112 px, tolerance 5");780 assertThat(spec.getImagePaths(), contains("imgs/image.png"));781 assertThat(spec.getErrorRate().getValue(), is(112.0));782 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));783 assertThat(spec.getTolerance(), is(5));784 assertThat(spec.isStretch(), is(false));785 assertThat(spec.isCropIfOutside(), is(false));786 }787 @Test788 public void shouldReadSpec_image_withMaxPixelsError_tolerance5_stretch() throws IOException {789 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 112 px, tolerance 5, stretch");790 assertThat(spec.getImagePaths(), contains("imgs/image.png"));791 assertThat(spec.getErrorRate().getValue(), is(112.0));792 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));793 assertThat(spec.getTolerance(), is(5));794 assertThat(spec.isStretch(), is(true));795 }796 @Test797 public void shouldReadSpec_image_withCropIfOutside() throws IOException {798 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, crop-if-outside");799 assertThat(spec.getImagePaths(), contains("imgs/image.png"));800 assertThat(spec.isCropIfOutside(), is(true));801 }802 @Test803 public void shouldReadSpec_image_withMaxPixelsError_tolerance5_filterBlur2() throws IOException {804 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 112 px, tolerance 5, filter blur 2");805 assertThat(spec.getImagePaths(), contains("imgs/image.png"));806 assertThat(spec.getErrorRate().getValue(), is(112.0));807 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));808 assertThat(spec.getTolerance(), is(5));809 assertThat(spec.getOriginalFilters().size(), is(1));810 assertThat(spec.getSampleFilters().size(), is(1));811 assertThat(((BlurFilter)spec.getOriginalFilters().get(0)).getRadius(), is(2));812 assertThat(((BlurFilter)spec.getSampleFilters().get(0)).getRadius(), is(2));813 }814 @Test815 public void shouldReadSpec_image_withMaxPixelsError_tolerance5_filterABlur2() throws IOException {816 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 112 px, tolerance 5, filter-a blur 2");817 assertThat(spec.getImagePaths(), contains("imgs/image.png"));818 assertThat(spec.getErrorRate().getValue(), is(112.0));819 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));820 assertThat(spec.getTolerance(), is(5));821 assertThat(spec.getOriginalFilters().size(), is(1));822 assertThat(spec.getSampleFilters().size(), is(0));823 assertThat(((BlurFilter)spec.getOriginalFilters().get(0)).getRadius(), is(2));824 }825 @Test826 public void shouldReadSpec_image_withMaxPixelsError_tolerance5_filterBBlur2() throws IOException {827 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 112 px, tolerance 5, filter-b blur 2");828 assertThat(spec.getImagePaths(), contains("imgs/image.png"));829 assertThat(spec.getErrorRate().getValue(), is(112.0));830 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));831 assertThat(spec.getTolerance(), is(5));832 assertThat(spec.getOriginalFilters().size(), is(0));833 assertThat(spec.getSampleFilters().size(), is(1));834 assertThat(((BlurFilter)spec.getSampleFilters().get(0)).getRadius(), is(2));835 }836 @Test837 public void shouldReadSpec_image_withMaxPixelsError_tolerance5_filterBlur2_filterDenoise1() throws IOException {838 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 112 px, filter blur 2, filter denoise 4, tolerance 5");839 assertThat(spec.getImagePaths(), contains("imgs/image.png"));840 assertThat(spec.getErrorRate().getValue(), is(112.0));841 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));842 assertThat(spec.getTolerance(), is(5));843 assertThat(spec.getOriginalFilters().size(), is(2));844 BlurFilter filter1 = (BlurFilter) spec.getOriginalFilters().get(0);845 assertThat(filter1.getRadius(), is(2));846 DenoiseFilter filter2 = (DenoiseFilter) spec.getOriginalFilters().get(1);847 assertThat(filter2.getRadius(), is(4));848 }849 @Test850 public void shouldReadSpec_image_withMaxPixelsError_tolerance5_filterBlur2_filterSaturation10_mapFilterDenoise1() throws IOException {851 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 112 px, filter blur 2, filter saturation 10, map-filter denoise 4, tolerance 5");852 assertThat(spec.getErrorRate().getValue(), is(112.0));853 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));854 assertThat(spec.getImagePaths(), contains("imgs/image.png"));855 assertThat(spec.getTolerance(), is(5));856 assertThat(spec.getOriginalFilters().size(), is(2));857 assertThat(spec.getSampleFilters().size(), is(2));858 assertThat(spec.getMapFilters().size(), is(1));859 assertThat(((BlurFilter)spec.getOriginalFilters().get(0)).getRadius(), is(2));860 assertThat(((BlurFilter)spec.getSampleFilters().get(0)).getRadius(), is(2));861 assertThat(((SaturationFilter)spec.getOriginalFilters().get(1)).getLevel(), is(10));862 assertThat(((SaturationFilter)spec.getSampleFilters().get(1)).getLevel(), is(10));863 DenoiseFilter filter2 = (DenoiseFilter) spec.getMapFilters().get(0);864 assertThat(filter2.getRadius(), is(4));865 }866 @Test867 public void shouldReadSpec_image_withMask() throws IOException {868 SpecImage spec = (SpecImage)readSpec("image file image.png, filter mask color-scheme-image-1.png");869 assertThat(spec.getImagePaths(), contains("image.png"));870 assertThat(spec.getOriginalFilters().size(), is(1));871 assertThat(spec.getOriginalFilters().get(0), is(instanceOf(MaskFilter.class)));872 assertThat(spec.getSampleFilters().size(), is(1));873 assertThat(spec.getSampleFilters().get(0), is(instanceOf(MaskFilter.class)));874 }875 @Test876 public void shouldReadSpec_image_withMaxPixelsError_andArea() throws IOException {877 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, error 112 px, area 10 10 100 20");878 assertThat(spec.getImagePaths(), contains("imgs/image.png"));879 assertThat(spec.getErrorRate().getValue(), is(112.0));880 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));881 assertThat(spec.getTolerance(), is(25));882 assertThat(spec.getSelectedArea(), is(new Rect(10,10,100,20)));883 }884 @Test885 public void shouldReadSpec_image_withAnalyzeOffset() throws IOException {886 SpecImage spec = (SpecImage)readSpec("image file imgs/image.png, analyze-offset 5");887 assertThat(spec.getImagePaths(), contains("imgs/image.png"));888 assertThat(spec.getAnalyzeOffset(), is(5));889 }890 @Test891 public void shouldReadSpec_image_andBuildImagePath_withContextPath() throws IOException {892 SpecImage spec = (SpecImage) readSpec("image file image.png", "some-component/specs");893 assertThat(spec.getImagePaths(), contains("some-component/specs/image.png"));894 }895 /**896 * Comes from https//github.com/galenframework/galen/issues/171897 * @throws IOException898 */899 @Test900 public void shouldReadSpec_image_toleranceAndErrorRate_fromConfig() throws IOException {901 System.setProperty("galen.spec.image.tolerance", "21");902 System.setProperty("galen.spec.image.error", "121%");903 SpecImage spec = (SpecImage)readSpec("image file image.png");904 assertThat(spec.getTolerance(), is(21));905 assertThat(spec.getErrorRate().getValue(), is(121.0));906 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PERCENT));907 System.getProperties().remove("galen.spec.image.tolerance");908 System.getProperties().remove("galen.spec.image.error");909 }910 @Test911 public void shouldReadSpec_image_replaceColors() throws IOException {912 SpecImage specImage = (SpecImage) readSpec("image file image.png, filter replace-colors #000-#333 #f0f0f0 #a0a0a0-#a0b0a0-#a0b0c0 with #111 tolerance 30 radius 2");913 assertThat(specImage.getOriginalFilters().size(), is(1));914 assertThat(specImage.getOriginalFilters().get(0), is(instanceOf(ReplaceColorsFilter.class)));915 ReplaceColorsFilter filter = (ReplaceColorsFilter) specImage.getOriginalFilters().get(0);916 assertThat(filter.getReplaceColorsDefinitions().size(), is(1));917 ReplaceColorsDefinition replaceColorsDefinitions = filter.getReplaceColorsDefinitions().get(0);918 assertThat(replaceColorsDefinitions.getReplaceColor(), is(new Color(17, 17, 17)));919 assertThat(replaceColorsDefinitions.getTolerance(), is(30));920 assertThat(replaceColorsDefinitions.getRadius(), is(2));921 assertThat(replaceColorsDefinitions.getColorClassifiers().size(), is(3));922 assertThat(replaceColorsDefinitions.getColorClassifiers().get(0), instanceOf(GradientColorClassifier.class));923 GradientColorClassifier gradient = (GradientColorClassifier) replaceColorsDefinitions.getColorClassifiers().get(0);924 assertThat(gradient.getName(), is("#000-#333"));925 assertThat(replaceColorsDefinitions.getColorClassifiers().get(1), instanceOf(SimpleColorClassifier.class));926 SimpleColorClassifier simple = (SimpleColorClassifier) replaceColorsDefinitions.getColorClassifiers().get(1);927 assertThat(simple.getName(), is("#f0f0f0"));928 assertThat(replaceColorsDefinitions.getColorClassifiers().get(2), instanceOf(GradientColorClassifier.class));929 gradient = (GradientColorClassifier) replaceColorsDefinitions.getColorClassifiers().get(2);930 assertThat(gradient.getName(), is("#a0a0a0-#a0b0a0-#a0b0c0"));931 }932 @Test933 public void shouldReadSpec_image_ignoredObjects() throws IOException {934 SpecImage spec = (SpecImage) readSpec("image file img.png, ignore-objects [menu_item-*, &excluded_objects], error 10px, ignore-objects one_more_obj");935 assertThat(spec.getImagePaths(), contains("img.png"));936 assertThat(spec.getIgnoredObjectExpressions(), contains("menu_item-*, &excluded_objects", "one_more_obj"));937 assertThat(spec.getErrorRate().getValue(), is(10.0));938 assertThat(spec.getErrorRate().getType(), is(SpecImage.ErrorRateType.PIXELS));939 }940 @Test941 public void shouldReadSpec_component() throws IOException {942 SpecComponent spec = (SpecComponent)readSpec("component some.spec");943 assertThat(spec.isFrame(), is(false));944 assertThat(spec.getSpecPath(), is("some.spec"));945 assertThat(spec.getOriginalText(), is("component some.spec"));946 }947 @Test948 public void shouldReadSpec_component_frame() throws IOException {949 SpecComponent spec = (SpecComponent)readSpec("component frame some.spec");950 assertThat(spec.isFrame(), is(true));951 assertThat(spec.getSpecPath(), is("some.spec"));952 assertThat(spec.getOriginalText(), is("component frame some.spec"));953 }954 @Test955 public void shouldReadSpec_component_withArguments_andRecogniseBasicTypes() throws IOException {956 SpecComponent spec = (SpecComponent)readSpec("component some.gspec, arg1 1, arg2 2.4, arg3 true, arg4 false, arg5 something, arg6 \"surrounded in quotes\" ");957 assertThat(spec.isFrame(), is(false));958 assertThat(spec.getSpecPath(), is("some.gspec"));959 assertThat(spec.getArguments(), is((Map<String, Object>)new HashMap<String, Object>(){{960 put("arg1", 1L);961 put("arg2", 2.4d);962 put("arg3", true);963 put("arg4", false);964 put("arg5", "something");965 put("arg6", "surrounded in quotes");966 }}));967 }968 @Test969 public void shouldReadSpec_count_any_pattern_is_6() throws IOException {970 SpecCount spec = (SpecCount)readSpec("count any menu-item-* is 6");971 assertThat(spec.getPattern(), is("menu-item-*"));972 assertThat(spec.getAmount(), is(Range.exact(6)));973 assertThat(spec.getFetchType(), is(SpecCount.FetchType.ANY));974 assertThat(spec.getOriginalText(), is("count any menu-item-* is 6"));975 }976 @Test977 public void shouldReadSpec_count_visible_pattern_is_6() throws IOException {978 SpecCount spec = (SpecCount)readSpec("count visible menu-item-* is 6");979 assertThat(spec.getPattern(), is("menu-item-*"));980 assertThat(spec.getAmount(), is(Range.exact(6)));981 assertThat(spec.getFetchType(), is(SpecCount.FetchType.VISIBLE));982 assertThat(spec.getOriginalText(), is("count visible menu-item-* is 6"));983 }984 @Test985 public void shouldReadSpec_absent_visible_pattern_is_6() throws IOException {986 SpecCount spec = (SpecCount)readSpec("count absent menu-item-* is 6");987 assertThat(spec.getPattern(), is("menu-item-*"));988 assertThat(spec.getAmount(), is(Range.exact(6)));989 assertThat(spec.getFetchType(), is(SpecCount.FetchType.ABSENT));990 assertThat(spec.getOriginalText(), is("count absent menu-item-* is 6"));991 }992 @Test993 public void shouldReadSpec_count_pattern_in_double_qoutes_is_6() throws IOException {994 SpecCount spec = (SpecCount)readSpec("count any \"menu-item-*, box-*\" is 6");995 assertThat(spec.getPattern(), is("menu-item-*, box-*"));996 assertThat(spec.getAmount(), is(Range.exact(6)));997 assertThat(spec.getOriginalText(), is("count any \"menu-item-*, box-*\" is 6"));998 }999 @Test...

Full Screen

Full Screen

shouldReadSpec_absent

Using AI Code Generation

copy

Full Screen

1import com.galenframework.parser.SyntaxException;2import com.galenframework.parser.SyntaxException;3import com.galenframework.specs.Spec;4import com.galenframework.specs.SpecPresent;5import com.galenframework.specs.SpecText;6import com.galenframework.s

Full Screen

Full Screen

shouldReadSpec_absent

Using AI Code Generation

copy

Full Screen

1 public void shouldReadSpec_absent() throws Exception {2 SpecsReaderV2 reader = new SpecsReaderV2();3 Spec spec = reader.readSpec("absent.spec", new StringReader("absent: #header"), new SpecReaderContext());4 assertThat(spec.getObjects().size(), is(1));5 assertThat(spec.getObjects().get(0).getName(), is("header"));6 assertThat(spec.getObjects().get(0).getAbsent(), is(true));7 assertThat(spec.getObjects().get(0).getPresent(), is(false));8 }

Full Screen

Full Screen

shouldReadSpec_absent

Using AI Code Generation

copy

Full Screen

1import com.galenframework.tests.speclang2.SpecsReaderV2Test;2import org.junit.Test;3public class SpecsReaderV2Test_shouldReadSpec_absent {4 public void test_shouldReadSpec_absent() throws Exception {5 SpecsReaderV2Test test = new SpecsReaderV2Test();6 test.shouldReadSpec_absent();7 }8}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Galen automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in SpecsReaderV2Test

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful