Search in sources :

Example 36 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testSVGImage.

@Test
protected void testSVGImage() {
    Image image = getImageUnderTest(IMAGE22_PATH);
    assertEquals(0, image.getWidths().length);
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image) AbstractImageTest(com.adobe.cq.wcm.core.components.internal.models.v1.AbstractImageTest) Test(org.junit.jupiter.api.Test)

Example 37 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testDMAnimatedGif.

@Test
void testDMAnimatedGif() {
    context.contentPolicyMapping(ImageImpl.RESOURCE_TYPE, Image.PN_DESIGN_DYNAMIC_MEDIA_ENABLED, true);
    Image image = getImageUnderTest(IMAGE40_PATH);
    assertTrue(image.isDmImage());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(TEST_BASE, IMAGE40_PATH));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image) AbstractImageTest(com.adobe.cq.wcm.core.components.internal.models.v1.AbstractImageTest) Test(org.junit.jupiter.api.Test)

Example 38 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testDMImageWithSmartCropRendition.

protected void testDMImageWithSmartCropRendition(String resourceType) {
    context.contentPolicyMapping(resourceType, Image.PN_DESIGN_DYNAMIC_MEDIA_ENABLED, true);
    Image image = getImageUnderTest(IMAGE36_PATH);
    assertTrue(image.isDmImage());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE36_PATH));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image)

Example 39 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testDMImageWithAutoSmartCropTwoSmartSizes.

protected void testDMImageWithAutoSmartCropTwoSmartSizes(String resourceType) {
    context.contentPolicyMapping(resourceType, new HashMap<String, Object>() {

        {
            put(Image.PN_DESIGN_DYNAMIC_MEDIA_ENABLED, true);
            put(Image.PN_DESIGN_ALLOWED_RENDITION_WIDTHS, new int[] { 600, 800 });
        }
    });
    Image image = getImageUnderTest(IMAGE38_PATH);
    assertTrue(image.isDmImage());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE38_PATH + "-two-smart-sizes"));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image)

Example 40 with Image

use of com.adobe.cq.wcm.core.components.models.Image in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class ImageImplTest method testImageFromTemplateStructureNoDate.

@Test
@SuppressWarnings("deprecation")
@Override
protected void testImageFromTemplateStructureNoDate() {
    context.contentPolicyMapping(resourceType, "allowedRenditionWidths", new int[] { 600, 700, 800, 2000, 2500 });
    com.adobe.cq.wcm.core.components.models.Image image = getImageUnderTest(TEMPLATE_IMAGE_NO_DATE_PATH);
    assertEquals(CONTEXT_PATH + "/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + ".png/structure/jcr%3acontent/root/image_template_no_date.png", image.getSrc());
    assertEquals("Adobe Systems Logo and Wordmark in PNG format", image.getAlt());
    assertEquals("Adobe Systems Logo and Wordmark", image.getTitle());
    assertEquals(IMAGE_FILE_REFERENCE_NO_DATE, image.getFileReference());
    String expectedJson = "{" + "\"smartImages\":[" + "\"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + JPEG_QUALITY + ".600.png/structure/jcr%3acontent/root/image_template_no_date.png\",\"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + JPEG_QUALITY + ".700.png/structure/jcr%3acontent/root/image_template_no_date.png\", \"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + JPEG_QUALITY + ".800.png/structure/jcr%3acontent/root/image_template_no_date.png\"," + "\"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + JPEG_QUALITY + "." + "2000.png/structure/jcr%3acontent/root/image_template_no_date.png\"," + "\"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + JPEG_QUALITY + ".2500.png/structure/jcr%3acontent/root/image_template_no_date.png\"" + "]," + "\"smartSizes\":[600,700,800,2000,2500]," + "\"lazyEnabled\":false" + "}";
    compareJSON(expectedJson, image.getJson());
    assertTrue(image.displayPopupTitle());
    assertEquals(CONTEXT_PATH + "/content/test-image.html", image.getLink());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, TEMPLATE_IMAGE_NO_DATE_PATH));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image) AbstractImageTest(com.adobe.cq.wcm.core.components.internal.models.v1.AbstractImageTest) Test(org.junit.jupiter.api.Test)

Aggregations

Image (com.adobe.cq.wcm.core.components.models.Image)84 Test (org.junit.jupiter.api.Test)57 AbstractImageTest (com.adobe.cq.wcm.core.components.internal.models.v1.AbstractImageTest)46 Test (org.junit.Test)5 Matchers.anyString (org.mockito.Matchers.anyString)5 Page (com.day.cq.wcm.api.Page)3 PageManager (com.day.cq.wcm.api.PageManager)3 Resource (org.apache.sling.api.resource.Resource)3 Link (com.adobe.cq.wcm.core.components.commons.link.Link)2 LinkHandler (com.adobe.cq.wcm.core.components.internal.link.LinkHandler)2 CoreResourceWrapper (com.adobe.cq.wcm.core.components.internal.resource.CoreResourceWrapper)2 ImageArea (com.adobe.cq.wcm.core.components.models.ImageArea)2 Teaser (com.adobe.cq.wcm.core.components.models.Teaser)2 DownloadResource (com.day.cq.commons.DownloadResource)2 ImageResource (com.day.cq.commons.ImageResource)2 Template (com.day.cq.wcm.api.Template)2 Style (com.day.cq.wcm.api.designer.Style)2 StringReader (java.io.StringReader)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2