use of org.xwiki.rendering.configuration.ExtendedRenderingConfiguration in project xwiki-platform by xwiki.
the class XWikiWikiModelTest method getImageURLWhenBothWidthAndHeightAreUnspecifiedAndImageSizeIsLimited.
/**
* Tests that the proper image URL is generated when both the width and the height are unspecified and image size is
* limited in the configuration.
*
* @throws Exception if an exception occurs while running the test
*/
@Test
public void getImageURLWhenBothWidthAndHeightAreUnspecifiedAndImageSizeIsLimited() throws Exception {
ExtendedRenderingConfiguration configuration = this.mocker.getInstance(ExtendedRenderingConfiguration.class);
when(configuration.getImageWidthLimit()).thenReturn(200);
when(configuration.getImageHeightLimit()).thenReturn(170);
Map<String, String> parameters = Collections.emptyMap();
testImageURL(new AttachmentResourceReference("attachmentReference"), parameters, true, "width=200&height=170&keepAspectRatio=true");
}
use of org.xwiki.rendering.configuration.ExtendedRenderingConfiguration in project xwiki-platform by xwiki.
the class XWikiWikiModelTest method getImageURLWhenBothWidthAndHeightAreUnspecifiedAndImageSizeIsNotLimited.
/**
* Tests that the proper image URL is generated when both the width and the height are unspecified and the image
* size is not limited in the configuration.
*
* @throws Exception if an exception occurs while running the test
*/
@Test
public void getImageURLWhenBothWidthAndHeightAreUnspecifiedAndImageSizeIsNotLimited() throws Exception {
final ExtendedRenderingConfiguration configuration = this.mocker.getInstance(ExtendedRenderingConfiguration.class);
when(configuration.getImageWidthLimit()).thenReturn(-1);
when(configuration.getImageHeightLimit()).thenReturn(-1);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("style", "bad CSS declaration");
testImageURL(new AttachmentResourceReference("attachmentReference"), parameters, true, null);
}
use of org.xwiki.rendering.configuration.ExtendedRenderingConfiguration in project xwiki-platform by xwiki.
the class XWikiWikiModelTest method testImageURL.
private void testImageURL(final ResourceReference imageReference, Map<String, String> parameters, final boolean expectedIsImageDimensionsIncludedInImageURL, final String expectedQueryString) throws Exception {
AttachmentReference attachmentReference = new AttachmentReference("image", new DocumentReference("wiki", "space", "page"));
ExtendedRenderingConfiguration configuration = this.mocker.getInstance(ExtendedRenderingConfiguration.class);
when(configuration.isImageDimensionsIncludedInImageURL()).thenReturn(expectedIsImageDimensionsIncludedInImageURL);
when(this.referenceResolver.resolve(imageReference, EntityType.ATTACHMENT)).thenReturn(attachmentReference);
when(this.documentAccessBridge.getAttachmentURL(attachmentReference, expectedQueryString, false)).thenReturn("?" + expectedQueryString);
assertEquals("?" + expectedQueryString, this.mocker.getComponentUnderTest().getImageURL(imageReference, parameters));
}
use of org.xwiki.rendering.configuration.ExtendedRenderingConfiguration in project xwiki-platform by xwiki.
the class XWikiWikiModelTest method getImageURLWhenBothWidthAndHeightAreUnspecifiedAndOnlyImageWidthIsLimited.
/**
* Tests that the proper image URL is generated when both the width and the height are unspecified and only the
* image width is limited in the configuration.
*
* @throws Exception if an exception occurs while running the test
*/
@Test
public void getImageURLWhenBothWidthAndHeightAreUnspecifiedAndOnlyImageWidthIsLimited() throws Exception {
final ExtendedRenderingConfiguration configuration = this.mocker.getInstance(ExtendedRenderingConfiguration.class);
when(configuration.getImageWidthLimit()).thenReturn(25);
when(configuration.getImageHeightLimit()).thenReturn(-1);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("width", "45%");
parameters.put("style", "height:10em");
testImageURL(new AttachmentResourceReference("attachmentReference"), parameters, true, "width=25");
}
Aggregations