Search in sources :

Example 41 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 testImageWithNoSmartSize.

@Test
protected void testImageWithNoSmartSize() {
    context.contentPolicyMapping(resourceType, "uuidDisabled", true);
    Image image = getImageUnderTest(AbstractImageTest.IMAGE4_PATH);
    assertArrayEquals(new int[] {}, image.getWidths());
    assertFalse(image.isLazyEnabled());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, AbstractImageTest.IMAGE4_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 42 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 testImageWithTwoOrMoreSmartSizes.

@Test
public void testImageWithTwoOrMoreSmartSizes() throws Exception {
    String escapedResourcePath = Text.escapePath(IMAGE0_PATH);
    Image image = getImageUnderTest(IMAGE0_PATH);
    assertEquals(IMAGE_TITLE_ALT, image.getAlt());
    assertEquals(IMAGE_TITLE_ALT, image.getTitle());
    assertEquals(IMAGE_FILE_REFERENCE, image.getFileReference());
    String expectedJson = "{\"smartImages\":[\"/core/content/test/jcr%3acontent/root/image0.img.600.png\"," + "\"/core/content/test/jcr%3acontent/root/image0.img.700.png\",\"/core/content/test/jcr%3acontent/root/image0" + ".img.800.png\",\"/core/content/test/jcr%3acontent/root/image0.img.2000.png\", " + "\"/core/content/test/jcr%3acontent/root/image0.img.2500.png\"],\"smartSizes\":[600,700,800,2000,2500],\"lazyEnabled\":true}";
    compareJSON(expectedJson, image.getJson());
    assertFalse(image.displayPopupTitle());
    assertEquals("/content/test-image.html", image.getLink());
    assertEquals(CONTEXT_PATH + escapedResourcePath + ".img.png", image.getSrc());
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Image(com.adobe.cq.wcm.core.components.models.Image) Test(org.junit.Test)

Example 43 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 testTIFFImage.

@Test
public void testTIFFImage() throws Exception {
    String escapedResourcePath = Text.escapePath(IMAGE16_PATH);
    Image image = getImageUnderTest(IMAGE16_PATH);
    assertEquals(CONTEXT_PATH + escapedResourcePath + ".img.jpeg", image.getSrc());
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Image(com.adobe.cq.wcm.core.components.models.Image) Test(org.junit.Test)

Example 44 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 testSimpleDecorativeImage.

@Test
public void testSimpleDecorativeImage() throws Exception {
    String escapedResourcePath = Text.escapePath(IMAGE4_PATH);
    Image image = getImageUnderTest(IMAGE4_PATH);
    assertNull("Did not expect a value for the alt attribute, since the image is marked as decorative.", image.getAlt());
    assertNull("Did not expect a title for this image.", image.getTitle());
    assertFalse("Image should not display a caption popup.", image.displayPopupTitle());
    assertNull("Did not expect a link for this image, since it's marked as decorative.", image.getLink());
    assertEquals(CONTEXT_PATH + escapedResourcePath + ".img.png", image.getSrc());
    compareJSON("{\"" + Image.JSON_SMART_IMAGES + "\":[], \"" + Image.JSON_SMART_SIZES + "\":[], \"" + Image.JSON_LAZY_ENABLED + "\":true}", image.getJson());
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Image(com.adobe.cq.wcm.core.components.models.Image) Test(org.junit.Test)

Example 45 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 testNoInheritedFeaturedImage_altValueFromDAM.

@Test
protected void testNoInheritedFeaturedImage_altValueFromDAM() {
    Image image = getImageUnderTest(IMAGE55_PATH);
    assertEquals("transparent HD PNG", image.getAlt(), "getAlt()");
    assertEquals("/content/dam/core/images/transparent_hd.png", image.getFileReference(), "getFileReference()");
    assertEquals("f6460529-b7b1-4b3a-8980-b3b3f0ee109c", image.getUuid(), "getUuid()");
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE55_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