Search in sources :

Example 16 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
@SuppressWarnings("deprecation")
protected void testImageWithTwoOrMoreSmartSizes() {
    String escapedResourcePath = IMAGE0_PATH.replace("jcr:content", "_jcr_content");
    context.contentPolicyMapping(resourceType, "allowedRenditionWidths", new int[] { 600, 700, 800, 2000, 2500 });
    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_content/root/image0." + selector + "." + jpegQuality + ".600.png/1490005239000/" + ASSET_NAME + ".png\",\"/core/content/test/_jcr_content/root/image0." + selector + "." + jpegQuality + ".700.png/1490005239000/" + ASSET_NAME + ".png\",\"/core/content/test/_jcr_content/root/image0." + selector + "." + jpegQuality + ".800.png/1490005239000/" + ASSET_NAME + ".png\",\"/core/content/test/_jcr_content/root/image0." + selector + "." + jpegQuality + ".2000.png/1490005239000/" + ASSET_NAME + ".png\", \"/core/content/test/_jcr_content/root/image0." + selector + "." + jpegQuality + ".2500.png/1490005239000/" + ASSET_NAME + ".png\"],\"smartSizes\":[600,700,800,2000,2500],\"lazyEnabled\":true}";
    compareJSON(expectedJson, image.getJson());
    assertFalse(image.displayPopupTitle());
    assertEquals(CONTEXT_PATH + "/content/test-image.html", image.getLink());
    assertEquals(CONTEXT_PATH + escapedResourcePath + "." + selector + ".png/1490005239000/" + ASSET_NAME + ".png", image.getSrc());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE0_PATH));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image) Test(org.junit.jupiter.api.Test)

Example 17 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")
protected void testImageFromTemplateStructureNoDate() {
    context.contentPolicyMapping("core/wcm/components/image", "allowedRenditionWidths", new int[] { 600, 700, 800, 2000, 2500 });
    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(IMAGE_TITLE_ALT, image.getAlt());
    assertEquals(IMAGE_TITLE_ALT, image.getTitle());
    assertEquals(IMAGE_FILE_REFERENCE_NO_DATE, image.getFileReference());
    String expectedJson = "{" + "\"smartImages\":[\"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + jpegQuality + ".600.png/structure/jcr%3acontent/root/image_template_no_date.png\",\"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + jpegQuality + ".700.png/structure/jcr%3acontent/root/image_template_no_date.png\", \"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + jpegQuality + ".800.png/structure/jcr%3acontent/root/image_template_no_date.png\"," + "\"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + jpegQuality + ".2000.png/structure/jcr%3acontent/root/image_template_no_date.png\",\"/core/conf/coretest/settings/wcm/templates/testtemplate/structure." + selector + "." + jpegQuality + ".2500.png/structure/jcr%3acontent/root/image_template_no_date.png\"]," + "\"smartSizes\":[600,700,800,2000,2500]," + "\"lazyEnabled\":true" + "}";
    compareJSON(expectedJson, image.getJson());
    assertFalse(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) Test(org.junit.jupiter.api.Test)

Example 18 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")
protected void testSimpleDecorativeImage() {
    String escapedResourcePath = IMAGE4_PATH.replace("jcr:content", "_jcr_content");
    Image image = getImageUnderTest(IMAGE4_PATH);
    assertNull(image.getAlt(), "Did not expect a value for the alt attribute, since the image is marked as decorative.");
    assertNull(image.getTitle(), "Did not expect a title for this image.");
    assertFalse(image.displayPopupTitle(), "Image should not display a caption popup.");
    assertNull(image.getLink(), "Did not expect a link for this image, since it's marked as decorative.");
    assertEquals(CONTEXT_PATH + escapedResourcePath + "." + selector + ".png/1494867377756/adobe-systems-logo-and-wordmark.png", image.getSrc());
    compareJSON("{\"" + Image.JSON_SMART_IMAGES + "\":[], \"" + Image.JSON_SMART_SIZES + "\":[], \"" + Image.JSON_LAZY_ENABLED + "\":true}", image.getJson());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE4_PATH));
}
Also used : Image(com.adobe.cq.wcm.core.components.models.Image) Test(org.junit.jupiter.api.Test)

Example 19 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 testLocalFileWithoutFileNameParameter.

@Test
@SuppressWarnings("deprecation")
@Override
protected void testLocalFileWithoutFileNameParameter() {
    context.contentPolicyMapping(resourceType, "allowedRenditionWidths", new int[] { 600 });
    String escapedResourcePath = IMAGE27_PATH.replace("jcr:content", "_jcr_content");
    Image image = getImageUnderTest(IMAGE27_PATH);
    assertNull(image.getFileReference(), "Did not expect a file reference.");
    assertEquals(CONTEXT_PATH + escapedResourcePath + "." + selector + ".82.600.png/1490005239000.png", image.getSrc());
    String expectedJson = "{\"smartImages\":[\"/core/content/test/_jcr_content/root/image27." + selector + "." + jpegQuality + ".600.png/1490005239000.png\"],\"smartSizes\":[600],\"lazyEnabled\":false}";
    compareJSON(expectedJson, image.getJson());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE27_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 20 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 testDMImageWithAutoSmartCropAndImageModifiers.

protected void testDMImageWithAutoSmartCropAndImageModifiers(String resourceType) {
    context.contentPolicyMapping(resourceType, Image.PN_DESIGN_DYNAMIC_MEDIA_ENABLED, true);
    Image image = getImageUnderTest(IMAGE39_PATH);
    assertTrue(image.isDmImage());
    Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, IMAGE39_PATH));
}
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