Search in sources :

Example 1 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 testImageWithOneSmartSize.

@Test
public void testImageWithOneSmartSize() throws Exception {
    String escapedResourcePath = Text.escapePath(IMAGE3_PATH);
    Image image = getImageUnderTest(IMAGE3_PATH);
    assertEquals(IMAGE_TITLE_ALT, image.getAlt());
    assertEquals(IMAGE_TITLE_ALT, image.getTitle());
    assertNull("Did not expect a file reference.", image.getFileReference());
    assertFalse("Image should not display a caption popup.", image.displayPopupTitle());
    assertEquals(IMAGE_LINK, image.getLink());
    assertEquals(CONTEXT_PATH + escapedResourcePath + ".img.600.png", image.getSrc());
    String expectedJson = "{\"smartImages\":[\"/core/content/test/jcr%3acontent/root/image3.img.600.png\"],\"smartSizes\":[600]," + "\"lazyEnabled\":false}";
    compareJSON(expectedJson, image.getJson());
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) Image(com.adobe.cq.wcm.core.components.models.Image) Test(org.junit.Test)

Example 2 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 testImageCacheKiller.

@Test
public void testImageCacheKiller() throws Exception {
    String escapedResourcePath = Text.escapePath(IMAGE4_PATH);
    Image image = getImageUnderTest(IMAGE4_PATH, WCMMode.EDIT);
    assertEquals(CONTEXT_PATH + escapedResourcePath + ".img.png/1494867377756.png", image.getSrc());
    escapedResourcePath = Text.escapePath(IMAGE15_PATH);
    image = getImageUnderTest(IMAGE15_PATH, WCMMode.EDIT);
    assertEquals(CONTEXT_PATH + escapedResourcePath + ".img.png/1494867377756.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 3 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
@SuppressWarnings("deprecation")
@Override
protected void testSimpleDecorativeImage() {
    context.contentPolicyMapping(resourceType, "uuidDisabled", true);
    String escapedResourcePath = AbstractImageTest.IMAGE4_PATH.replace("jcr:content", "_jcr_content");
    com.adobe.cq.wcm.core.components.models.Image image = getImageUnderTest(AbstractImageTest.IMAGE4_PATH);
    assertEquals(null, image.getAlt(), "Did not expect a value for the alt attribute, since the image is marked as decorative.");
    assertEquals("Adobe Systems Logo and Wordmark", image.getTitle());
    assertTrue(image.displayPopupTitle());
    assertEquals(null, image.getLink(), "Did not expect a link for this image, since it's marked as decorative.");
    assertNull(image.getImageLink(), "Expected null link");
    assertEquals(CONTEXT_PATH + escapedResourcePath + "." + selector + ".png/1494867377756/" + ASSET_NAME + ".png", image.getSrc());
    assertNull(image.getSrcset());
    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 4 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 testInheritedFeaturedImage_altValueFromImage_decorative.

@Test
protected void testInheritedFeaturedImage_altValueFromImage_decorative() {
    Image image = getImageUnderTest(IMAGE54_PATH);
    assertNull(image.getAlt(), "getAlt()");
    assertEquals("/content/dam/core/images/Adobe_Systems_logo_and_wordmark.png", image.getFileReference(), "getFileReference()");
    assertEquals("60a1a56e-f3f4-4021-a7bf-ac7a51f0ffe5", image.getUuid(), "getUuid()");
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE54_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 5 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 testInheritedFeaturedImage_altValueFromPageImage_decorative.

@Test
protected void testInheritedFeaturedImage_altValueFromPageImage_decorative() {
    Image image = getImageUnderTest(IMAGE53_PATH);
    assertNull(image.getAlt(), "getAlt()");
    assertEquals("/content/dam/core/images/Adobe_Systems_logo_and_wordmark.png", image.getFileReference(), "getFileReference()");
    assertEquals("60a1a56e-f3f4-4021-a7bf-ac7a51f0ffe5", image.getUuid(), "getUuid()");
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE53_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