Search in sources :

Example 1 with AttachmentResourceReference

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;
}
Also used : AttachmentResourceReference(org.xwiki.rendering.listener.reference.AttachmentResourceReference)

Example 2 with AttachmentResourceReference

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&param=value");
    testImageURL(reference, parameters, true, "width=41&param=value&height=17");
}
Also used : HashMap(java.util.HashMap) AttachmentResourceReference(org.xwiki.rendering.listener.reference.AttachmentResourceReference) Test(org.junit.Test)

Example 3 with AttachmentResourceReference

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");
}
Also used : HashMap(java.util.HashMap) AttachmentResourceReference(org.xwiki.rendering.listener.reference.AttachmentResourceReference) Test(org.junit.Test)

Example 4 with AttachmentResourceReference

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");
}
Also used : ExtendedRenderingConfiguration(org.xwiki.rendering.configuration.ExtendedRenderingConfiguration) AttachmentResourceReference(org.xwiki.rendering.listener.reference.AttachmentResourceReference) Test(org.junit.Test)

Example 5 with AttachmentResourceReference

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");
}
Also used : HashMap(java.util.HashMap) AttachmentResourceReference(org.xwiki.rendering.listener.reference.AttachmentResourceReference) Test(org.junit.Test)

Aggregations

AttachmentResourceReference (org.xwiki.rendering.listener.reference.AttachmentResourceReference)14 Test (org.junit.Test)11 HashMap (java.util.HashMap)9 ExtendedRenderingConfiguration (org.xwiki.rendering.configuration.ExtendedRenderingConfiguration)3 ResourceReference (org.xwiki.rendering.listener.reference.ResourceReference)3 AttachmentReference (org.xwiki.model.reference.AttachmentReference)2 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)1 BaseObject (com.xpn.xwiki.objects.BaseObject)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 Type (java.lang.reflect.Type)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 DefaultVersionConstraint (org.xwiki.extension.version.internal.DefaultVersionConstraint)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 PresentationBuilder (org.xwiki.officeimporter.builder.PresentationBuilder)1 XDOMOfficeDocument (org.xwiki.officeimporter.document.XDOMOfficeDocument)1 ExpandedMacroBlock (org.xwiki.rendering.block.ExpandedMacroBlock)1 ImageBlock (org.xwiki.rendering.block.ImageBlock)1 MetaDataBlock (org.xwiki.rendering.block.MetaDataBlock)1 XDOM (org.xwiki.rendering.block.XDOM)1