1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.test.ui; |
21 |
|
|
22 |
|
import org.apache.commons.lang.math.RandomUtils; |
23 |
|
import org.junit.Assert; |
24 |
|
import org.junit.Before; |
25 |
|
import org.junit.Ignore; |
26 |
|
import org.junit.Rule; |
27 |
|
import org.junit.Test; |
28 |
|
import org.openqa.selenium.By; |
29 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
30 |
|
import org.xwiki.test.ui.browser.IgnoreBrowsers; |
31 |
|
import org.xwiki.test.ui.po.AttachmentsPane; |
32 |
|
import org.xwiki.test.ui.po.ViewPage; |
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
|
|
| 61.9% |
Uncovered Elements: 16 (42) |
Complexity: 4 |
Complexity Density: 0.11 |
|
43 |
|
public class AttachmentTest extends AbstractTest |
44 |
|
{ |
45 |
|
@Rule |
46 |
|
public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil()); |
47 |
|
|
48 |
|
private final String testAttachment = "SmallAttachment.txt"; |
49 |
|
|
50 |
|
private final String testAttachment2 = "SmallAttachment2.txt"; |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
2 |
@Before... |
53 |
|
public void setUp() throws Exception |
54 |
|
{ |
55 |
2 |
getUtil().rest().deletePage(getTestClassName(), getTestMethodName()); |
56 |
|
} |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
4-
|
|
58 |
0 |
@Test... |
59 |
|
@Ignore("WebDriver doesn't support uploading multiple files in one input, see http://code.google.com/p/selenium/issues/detail?id=2239") |
60 |
|
@IgnoreBrowsers({ |
61 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
62 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
63 |
|
}) |
64 |
|
public void testUploadDownloadTwoAttachmentsInParallel() |
65 |
|
{ |
66 |
0 |
ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), null, |
67 |
|
getTestClassName() + "#" + getTestMethodName()); |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
0 |
vp.waitForDocExtraPaneActive("comments"); |
72 |
|
|
73 |
0 |
AttachmentsPane ap = vp.openAttachmentsDocExtraPane(); |
74 |
0 |
ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment).getPath()); |
75 |
0 |
ap.addAnotherFile(); |
76 |
0 |
ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment2).getPath()); |
77 |
0 |
ap.clickAttachFiles(); |
78 |
|
|
79 |
0 |
Assert.assertEquals("1.1", ap.getLatestVersionOfAttachment(this.testAttachment)); |
80 |
0 |
Assert.assertEquals("1.1", ap.getLatestVersionOfAttachment(this.testAttachment2)); |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
0 |
ap.getAttachmentLink(this.testAttachment).click(); |
85 |
|
|
86 |
0 |
Assert.assertEquals("This is a small attachment.", getDriver().findElement(By.tagName("html")).getText()); |
87 |
0 |
getDriver().navigate().back(); |
88 |
0 |
vp.waitForDocExtraPaneActive("attachments"); |
89 |
0 |
ap.getAttachmentLink(this.testAttachment2).click(); |
90 |
0 |
Assert.assertEquals("This is another small attachment.", getDriver().findElement(By.tagName("html")).getText()); |
91 |
|
} |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
93 |
1 |
@Test... |
94 |
|
@IgnoreBrowsers( { |
95 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146"), |
96 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See http://jira.xwiki.org/browse/XE-1177")}) |
97 |
|
public void testUploadDownloadTwoAttachmentsInSequence() |
98 |
|
{ |
99 |
1 |
ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), null, |
100 |
|
getTestClassName() + "#" + getTestMethodName()); |
101 |
|
|
102 |
|
|
103 |
|
|
104 |
1 |
vp.waitForDocExtraPaneActive("comments"); |
105 |
|
|
106 |
1 |
AttachmentsPane ap = vp.openAttachmentsDocExtraPane(); |
107 |
1 |
ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment).getPath()); |
108 |
1 |
ap.waitForUploadToFinish(this.testAttachment); |
109 |
1 |
ap.clickHideProgress(); |
110 |
1 |
ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment2).getPath()); |
111 |
1 |
ap.waitForUploadToFinish(this.testAttachment2); |
112 |
|
|
113 |
1 |
Assert.assertEquals("1.1", ap.getLatestVersionOfAttachment(this.testAttachment)); |
114 |
1 |
Assert.assertEquals("1.1", ap.getLatestVersionOfAttachment(this.testAttachment2)); |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
1 |
ap.getAttachmentLink(this.testAttachment).click(); |
119 |
|
|
120 |
1 |
Assert.assertEquals("This is a small attachment.", getDriver().findElement(By.tagName("html")).getText()); |
121 |
1 |
getDriver().navigate().back(); |
122 |
1 |
vp.waitForDocExtraPaneActive("attachments"); |
123 |
1 |
ap.getAttachmentLink(this.testAttachment2).click(); |
124 |
1 |
Assert.assertEquals("This is another small attachment.", getDriver().findElement(By.tagName("html")).getText()); |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
130 |
1 |
@Test... |
131 |
|
@IgnoreBrowsers({ |
132 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
133 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
134 |
|
}) |
135 |
|
public void testAttachAndViewGifImage() |
136 |
|
{ |
137 |
|
|
138 |
|
|
139 |
|
|
140 |
1 |
ViewPage viewPage = getUtil().createPage(getClass().getSimpleName(), getTestMethodName(), |
141 |
|
String.format("[[image:image.gif||width=%s]]", (20 + RandomUtils.nextInt(200))), getTestClassName()); |
142 |
|
|
143 |
|
|
144 |
|
|
145 |
1 |
viewPage.waitForDocExtraPaneActive("comments"); |
146 |
|
|
147 |
|
|
148 |
1 |
AttachmentsPane attachmentsPane = viewPage.openAttachmentsDocExtraPane(); |
149 |
1 |
attachmentsPane.setFileToUpload(getClass().getResource("/image.gif").getPath()); |
150 |
1 |
attachmentsPane.waitForUploadToFinish("image.gif"); |
151 |
1 |
Assert.assertTrue(attachmentsPane.attachmentExistsByFileName("image.gif")); |
152 |
|
} |
153 |
|
} |