Search in sources :

Example 46 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 testInheritedPageImage_pageImageAltValueFromResource_withFileResource.

@Test
protected void testInheritedPageImage_pageImageAltValueFromResource_withFileResource() {
    Image image = getImageUnderTest(PAGE3_IMAGE0_PATH);
    assertEquals("/core/content/test_page3/_jcr_content/root/page3_image0.coreimg.png", image.getSrc(), "getSrc()");
    assertEquals("featured image alt", image.getAlt(), "getAlt()");
    assertNull(image.getFileReference(), "getFileReference()");
    assertNull(image.getUuid(), "getUuid()");
    assertEquals("image-96253254e2", image.getId(), "getId()");
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, PAGE3_IMAGE0_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 47 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 testInheritedPageImage_fromTemplate_withLink.

@Test
protected void testInheritedPageImage_fromTemplate_withLink() {
    Image image = getImageUnderTest(TEMPLATE_IMAGE_INHERITED_PATH2);
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, TEMPLATE_IMAGE_INHERITED_PATH2));
}
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 48 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.

@Override
@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());
    assertTrue(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 49 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 testLazyLoadedDisabled.

@Test
protected void testLazyLoadedDisabled() {
    context.contentPolicyMapping(resourceType, "disableLazyLoading", true, "allowedRenditionWidths", new int[] { 600 });
    Image image = getImageUnderTest(AbstractImageTest.IMAGE3_PATH);
    assertFalse(image.isLazyEnabled());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, AbstractImageTest.IMAGE3_PATH + "-with-lazy-loading-disabled"));
}
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 50 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 testImageWithMoreThanOneSmartSize.

@Override
@Test
protected void testImageWithMoreThanOneSmartSize() {
    context.contentPolicyMapping(resourceType, "allowedRenditionWidths", new int[] { 600, 700, 800, 2000, 2500 });
    Image image = getImageUnderTest(AbstractImageTest.IMAGE0_PATH);
    assertArrayEquals(new int[] { 600, 700, 800, 2000, 2500 }, image.getWidths());
    assertTrue(image.isLazyEnabled());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, AbstractImageTest.IMAGE0_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