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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations