Search in sources :

Example 31 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 testDMImageWithAutoSmartCrop.

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

Example 32 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 testImageWithOneSmartSizeAndPolicyDelegate.

@Test
protected void testImageWithOneSmartSizeAndPolicyDelegate() {
    context.contentPolicyMapping(resourceType, "allowedRenditionWidths", new int[] { 600 });
    context.request().setParameterMap(ImmutableMap.of("contentPolicyDelegatePath", IMAGE0_PATH));
    Image image = getImageUnderTest(AbstractImageTest.IMAGE3_PATH);
    assertArrayEquals(new int[] { 600 }, image.getWidths());
    assertFalse(image.isLazyEnabled());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, AbstractImageTest.IMAGE3_PATH + "-with-policy-delegate"));
}
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 33 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 testImageWithMap.

@Test
@SuppressWarnings("deprecation")
protected void testImageWithMap() {
    context.contentPolicyMapping(resourceType, "uuidDisabled", true);
    com.adobe.cq.wcm.core.components.models.Image image = getImageUnderTest(AbstractImageTest.IMAGE24_PATH);
    Object[][] expectedAreas = { { "circle", "256,256,256", "0.2000,0.3001,0.2000", "http://adobe.com", "", "" }, { "rect", "256,171,1023,682", "0.1992,0.2005,0.7992,0.7995", "http://adobe.com", "", "altText" }, { "poly", "917,344,1280,852,532,852", "0.7164,0.4033,1.0000,0.9988,0.4156,0.9988", "http://adobe.com", "_blank", "" } };
    List<ImageArea> areas = image.getAreas();
    int index = 0;
    while (areas.size() > index) {
        ImageArea area = areas.get(index);
        assertEquals(expectedAreas[index][0], area.getShape(), "The image area's shape is not as expected.");
        assertEquals(expectedAreas[index][1], area.getCoordinates(), "The image area's coordinates are not as expected.");
        assertEquals(expectedAreas[index][2], area.getRelativeCoordinates(), "The image area's relative coordinates are not as expected.");
        assertEquals(expectedAreas[index][3], area.getHref(), "The image area's href is not as expected.");
        assertEquals(expectedAreas[index][4], area.getTarget(), "The image area's target is not as expected.");
        assertEquals(expectedAreas[index][5], area.getAlt(), "The image area's alt text is not as expected.");
        index++;
    }
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, AbstractImageTest.IMAGE24_PATH));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image) ImageArea(com.adobe.cq.wcm.core.components.models.ImageArea) AbstractImageTest(com.adobe.cq.wcm.core.components.internal.models.v1.AbstractImageTest) Test(org.junit.jupiter.api.Test)

Example 34 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 testDMImageWithImagePresetOneSmartSize.

protected void testDMImageWithImagePresetOneSmartSize(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 });
        }
    });
    Image image = getImageUnderTest(IMAGE33_PATH);
    assertTrue(image.isDmImage());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE33_PATH + "-one-smart-size"));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image)

Example 35 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 testDMImageWithSmartCropRenditionOneSmartSize.

protected void testDMImageWithSmartCropRenditionOneSmartSize(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 });
        }
    });
    Image image = getImageUnderTest(IMAGE36_PATH);
    assertTrue(image.isDmImage());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE36_PATH + "-one-smart-size"));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image)

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