1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.flamingo.test.ui; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
|
24 |
|
import org.junit.Rule; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.model.reference.DocumentReference; |
27 |
|
import org.xwiki.test.ui.AbstractTest; |
28 |
|
import org.xwiki.test.ui.SuperAdminAuthenticationRule; |
29 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
30 |
|
import org.xwiki.test.ui.browser.IgnoreBrowsers; |
31 |
|
import org.xwiki.test.ui.po.BreadcrumbElement; |
32 |
|
import org.xwiki.test.ui.po.ViewPage; |
33 |
|
|
34 |
|
import static org.junit.Assert.assertEquals; |
35 |
|
import static org.junit.Assert.assertFalse; |
36 |
|
import static org.junit.Assert.assertTrue; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@version |
42 |
|
@since |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 2 |
Complexity Density: 0.08 |
|
44 |
|
public class BreadcrumbsTest extends AbstractTest |
45 |
|
{ |
46 |
|
@Rule |
47 |
|
public SuperAdminAuthenticationRule adminAuthenticationRule = new SuperAdminAuthenticationRule(getUtil()); |
48 |
|
|
49 |
|
private static final String PARENT_TITLE = "Parent page"; |
50 |
|
|
51 |
|
private static final String CHILD_TITLE = "Child page"; |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
53 |
1 |
@Test... |
54 |
|
@IgnoreBrowsers({ |
55 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
56 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
57 |
|
}) |
58 |
|
public void verifyBreadcrumbInParentChildMode() |
59 |
|
{ |
60 |
|
|
61 |
1 |
getUtil().deletePage(getTestClassName(), getTestMethodName()); |
62 |
|
|
63 |
1 |
getUtil().setHierarchyMode("parentchild"); |
64 |
|
|
65 |
1 |
String parentPageName = getTestMethodName() + "ParentPage"; |
66 |
1 |
String parentPageFullName = getTestClassName() + "." + parentPageName; |
67 |
|
|
68 |
1 |
getUtil().createPage(getTestClassName(), parentPageName, null, PARENT_TITLE); |
69 |
1 |
ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), null, CHILD_TITLE, null, |
70 |
|
parentPageFullName); |
71 |
|
|
72 |
|
|
73 |
1 |
assertTrue(vp.hasBreadcrumbContent(PARENT_TITLE, false)); |
74 |
1 |
assertTrue(vp.hasBreadcrumbContent(CHILD_TITLE, true)); |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
1 |
getUtil().addObject(getTestClassName(), parentPageName, "XWiki.XWikiRights", |
80 |
|
"levels", "view", |
81 |
|
"users", "XWiki.superadmin", |
82 |
|
"allow", "1"); |
83 |
|
|
84 |
|
|
85 |
1 |
getUtil().forceGuestUser(); |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
1 |
vp = getUtil().gotoPage(getTestClassName(), getTestMethodName()); |
90 |
1 |
assertFalse(vp.isAuthenticated()); |
91 |
1 |
assertFalse(vp.hasBreadcrumbContent(PARENT_TITLE, false, true)); |
92 |
1 |
assertTrue(vp.hasBreadcrumbContent(CHILD_TITLE, true, true)); |
93 |
1 |
assertTrue(vp.hasBreadcrumbContent(parentPageName, false, false)); |
94 |
|
|
95 |
|
|
96 |
1 |
adminAuthenticationRule.authenticate(); |
97 |
1 |
getUtil().setHierarchyMode("reference"); |
98 |
|
} |
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
100 |
1 |
@Test... |
101 |
|
public void verifyBreadcrumbInLongHierarchy() throws Exception |
102 |
|
{ |
103 |
1 |
DocumentReference documentReference = |
104 |
|
new DocumentReference("xwiki", Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H"), "WebHome"); |
105 |
1 |
ViewPage page = getUtil().createPage(documentReference, "Content", getTestMethodName()); |
106 |
|
|
107 |
1 |
BreadcrumbElement breadcrumb = page.getBreadcrumb(); |
108 |
|
|
109 |
1 |
assertEquals("/A/…/F/G/" + getTestMethodName(), breadcrumb.getPathAsString()); |
110 |
|
|
111 |
1 |
breadcrumb.expand(); |
112 |
1 |
assertEquals("/A/B/C/D/E/F/G/" + getTestMethodName(), breadcrumb.getPathAsString()); |
113 |
|
|
114 |
1 |
getUtil().deletePage(documentReference); |
115 |
|
} |
116 |
|
} |