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_decorative.
@Test
protected void testNoInheritedFeaturedImage_altValueFromDAM_decorative() {
Image image = getImageUnderTest(IMAGE57_PATH);
assertNull(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, IMAGE57_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 testImageWithMap.
@Test
@SuppressWarnings("deprecation")
@Override
protected void testImageWithMap() {
context.contentPolicyMapping(resourceType, "uuidDisabled", true);
com.adobe.cq.wcm.core.components.models.Image image = getImageUnderTest(AbstractImageTest.IMAGE24_PATH);
Object[][] expectedAreas = { { "circle", "256,256,256", "0.2000,0.3001,0.2000", "http://adobe.com", "", "" }, { "rect", "256,171,1023,682", "0.1992,0.2005,0.7992,0.7995", "http://adobe.com", "", "altText" }, { "poly", "917,344,1280,852,532,852", "0.7164,0.4033,1.0000,0.9988,0.4156,0.9988", "http://adobe.com", "_blank", "" } };
List<ImageArea> areas = image.getAreas();
int index = 0;
while (areas.size() > index) {
ImageArea area = areas.get(index);
assertEquals(expectedAreas[index][0], area.getShape(), "The image area's shape is not as expected.");
assertEquals(expectedAreas[index][1], area.getCoordinates(), "The image area's coordinates are not as expected.");
assertEquals(expectedAreas[index][2], area.getRelativeCoordinates(), "The image area's relative coordinates are not as expected.");
assertEquals(expectedAreas[index][3], area.getHref(), "The image area's href is not as expected.");
assertEquals(expectedAreas[index][4], area.getTarget(), "The image area's target is not as expected.");
assertEquals(expectedAreas[index][5], area.getAlt(), "The image area's alt text is not as expected.");
assertValidLink(area.getLink(), (String) expectedAreas[index][3], StringUtils.trimToNull((String) expectedAreas[index][4]));
index++;
}
Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, AbstractImageTest.IMAGE24_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 testNoInheritedFeaturedImage_altValueFromImage_decorative.
@Test
protected void testNoInheritedFeaturedImage_altValueFromImage_decorative() {
Image image = getImageUnderTest(IMAGE58_PATH);
assertNull(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, IMAGE58_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 testInheritedFeaturedImage_altValueFromPageImage.
@Test
protected void testInheritedFeaturedImage_altValueFromPageImage() {
Image image = getImageUnderTest(IMAGE51_PATH);
assertEquals("Adobe Systems Logo and Wordmark in PNG format", 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, IMAGE51_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 testImageWithTwoOrMoreSmartSizes.
@Test
@SuppressWarnings("deprecation")
@Override
protected void testImageWithTwoOrMoreSmartSizes() {
context.contentPolicyMapping(resourceType, "allowedRenditionWidths", new int[] { 600, 700, 800, 2000, 2500 });
String escapedResourcePath = AbstractImageTest.IMAGE0_PATH.replace("jcr:content", "_jcr_content");
Image image = getImageUnderTest(AbstractImageTest.IMAGE0_PATH);
assertEquals("Adobe Systems Logo and Wordmark in PNG format", image.getAlt());
assertEquals("Adobe Systems Logo and Wordmark", image.getTitle());
assertEquals(IMAGE_FILE_REFERENCE, image.getFileReference());
String expectedSrcset = "/core/content/test/_jcr_content/root/image0." + selector + "." + JPEG_QUALITY + ".600.png/1490005239000/" + ASSET_NAME + ".png 600w," + "/core/content/test/_jcr_content/root/image0." + selector + "." + JPEG_QUALITY + ".700.png/1490005239000/" + ASSET_NAME + ".png 700w," + "/core/content/test/_jcr_content/root/image0." + selector + "." + JPEG_QUALITY + ".800.png/1490005239000/" + ASSET_NAME + ".png 800w," + "/core/content/test/_jcr_content/root/image0." + selector + "." + JPEG_QUALITY + ".2000.png/1490005239000/" + ASSET_NAME + ".png 2000w," + "/core/content/test/_jcr_content/root/image0." + selector + "." + JPEG_QUALITY + ".2500.png/1490005239000/" + ASSET_NAME + ".png 2500w";
assertEquals(expectedSrcset, image.getSrcset());
assertEquals("Adobe Systems Logo and Wordmark", image.getTitle());
assertEquals(IMAGE_FILE_REFERENCE, image.getFileReference());
String expectedJson = "{\"smartImages\":[\"/core/content/test/_jcr_content/root/image0." + selector + "." + JPEG_QUALITY + ".600.png/1490005239000/" + ASSET_NAME + ".png\",\"/core/content/test/_jcr_content/root/image0." + selector + "." + JPEG_QUALITY + ".700.png/1490005239000/" + ASSET_NAME + ".png\",\"/core/content/test/_jcr_content/root/image0" + "." + selector + "." + JPEG_QUALITY + ".800.png/1490005239000/" + ASSET_NAME + ".png\",\"/core/content/test/_jcr_content/root/image0." + selector + "." + JPEG_QUALITY + ".2000.png/1490005239000/" + ASSET_NAME + ".png\", \"/core/content/test/_jcr_content/root/image0." + selector + "." + JPEG_QUALITY + ".2500.png/1490005239000/" + ASSET_NAME + ".png\"],\"smartSizes\":[600,700,800,2000,2500],\"lazyEnabled\":false}";
compareJSON(expectedJson, image.getJson());
assertTrue(image.displayPopupTitle());
assertEquals(CONTEXT_PATH + "/content/test-image.html", image.getLink());
assertValidLink(image.getImageLink(), "/content/test-image.html", context.request());
assertEquals(CONTEXT_PATH + escapedResourcePath + "." + selector + ".png/1490005239000/" + ASSET_NAME + ".png", image.getSrc());
Utils.testJSONExport(image, Utils.getTestExporterJSONPath(testBase, AbstractImageTest.IMAGE0_PATH));
}
Aggregations