use of org.xwiki.rendering.listener.reference.AttachmentResourceReference in project xwiki-platform by xwiki.
the class DefaultResourceReferenceEntityReferenceResolverTest method attachmentResource.
private AttachmentResourceReference attachmentResource(String referenceString, boolean typed) {
AttachmentResourceReference reference = new AttachmentResourceReference(referenceString);
reference.setTyped(typed);
return reference;
}
use of org.xwiki.rendering.listener.reference.AttachmentResourceReference in project xwiki-platform by xwiki.
the class XWikiWikiModelTest method getImageURLWhenImageReferenceHasQueryString.
/**
* Tests that the proper image URL is generated when the attachment URL has a query string and a fragment
* identifier.
*
* @throws Exception if an exception occurs while running the test
*/
@Test
public void getImageURLWhenImageReferenceHasQueryString() throws Exception {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("height", "17");
parameters.put("width", "23");
AttachmentResourceReference reference = new AttachmentResourceReference("attachmentReference");
reference.setParameter(AttachmentResourceReference.QUERY_STRING, "width=41¶m=value");
testImageURL(reference, parameters, true, "width=41¶m=value&height=17");
}
use of org.xwiki.rendering.listener.reference.AttachmentResourceReference in project xwiki-platform by xwiki.
the class XWikiWikiModelTest method getImageURLWhenBothWidthAndHeightAttributesAreSpecified.
/**
* Tests that the proper image URL is generated when both the width and the height image parameters are specified.
*
* @throws Exception if an exception occurs while running the test
*/
@Test
public void getImageURLWhenBothWidthAndHeightAttributesAreSpecified() throws Exception {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("width", "100px");
parameters.put("height", "50");
testImageURL(new AttachmentResourceReference("attachmentReference"), parameters, true, "width=100&height=50");
}
use of org.xwiki.rendering.listener.reference.AttachmentResourceReference 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.listener.reference.AttachmentResourceReference in project xwiki-platform by xwiki.
the class XWikiWikiModelTest method getImageURLWhenOnlyHeightCSSPropertyIsSpecified.
/**
* Tests that the proper image URL is generated when only the height CSS property is specified.
*
* @throws Exception if an exception occurs while running the test
*/
@Test
public void getImageURLWhenOnlyHeightCSSPropertyIsSpecified() throws Exception {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("style", "width: 5cm; height: 80px");
testImageURL(new AttachmentResourceReference("attachmentReference"), parameters, true, "height=80");
}
Aggregations