1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.test.selenium

File DocExtraTest.java

 

Code metrics

0
61
7
1
163
93
7
0.11
8.71
7
1

Classes

Class Line # Actions
DocExtraTest 31 61 0% 7 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.test.selenium;
21   
22    import org.junit.Test;
23    import org.openqa.selenium.By;
24    import org.xwiki.test.selenium.framework.AbstractXWikiTestCase;
25   
26    /**
27    * Verify the document extra feature of XWiki.
28    *
29    * @version $Id: 00cd265b4f7886482196352ce0bc82658a1e0764 $
30    */
 
31    public class DocExtraTest extends AbstractXWikiTestCase
32    {
33    /**
34    * Test document extras presence after a click on the corresponding tabs.
35    */
 
36  1 toggle @Test
37    public void testDocExtraLoadingFromTabClicks()
38    {
39  1 open("Main", "WebHome");
40   
41  1 clickLinkWithXPath("//a[@id='Attachmentslink']", false);
42  1 waitForDocExtraPaneActive("attachments");
43   
44  1 clickLinkWithXPath("//a[@id='Historylink']", false);
45  1 waitForDocExtraPaneActive("history");
46   
47  1 clickLinkWithXPath("//a[@id='Informationlink']", false);
48  1 waitForDocExtraPaneActive("information");
49   
50  1 clickLinkWithXPath("//a[@id='Commentslink']", false);
51  1 waitForDocExtraPaneActive("comments");
52    }
53   
54    /**
55    * Test document extras presence after pressing the corresponding keyboard shortcuts. This test also verify that the
56    * browser scrolls to the bottom of the page.
57    *
58    * @throws InterruptedException if selenium fails to simulate keyboard shortcut.
59    */
 
60  1 toggle @Test
61    public void testDocExtraLoadingFromKeyboardShortcuts() throws InterruptedException
62    {
63  1 open("Main", "WebHome");
64   
65  1 getSkinExecutor().pressKeyboardShortcut("a", false, false, false);
66  1 waitForDocExtraPaneActive("attachments");
67  1 assertDocExtraPaneInView("attachments");
68  1 scrollToPageTop();
69   
70  1 getSkinExecutor().pressKeyboardShortcut("h", false, false, false);
71  1 waitForDocExtraPaneActive("history");
72  1 assertDocExtraPaneInView("history");
73  1 scrollToPageTop();
74   
75  1 getSkinExecutor().pressKeyboardShortcut("i", false, false, false);
76  1 waitForDocExtraPaneActive("information");
77  1 assertDocExtraPaneInView("information");
78  1 scrollToPageTop();
79   
80  1 getSkinExecutor().pressKeyboardShortcut("c", false, false, false);
81  1 waitForDocExtraPaneActive("comments");
82  1 assertDocExtraPaneInView("comments");
83    }
84   
85    /**
86    * Test document extra presence when the user arrives from an URL with anchor. This test also verify that the
87    * browser scrolls to the bottom of the page.
88    */
 
89  1 toggle @Test
90    public void testDocExtraLoadingFromURLAnchor()
91    {
92    // We have to load a different page first since opening the same page with a new anchor doesn't call
93    // our functions (on purpose)
94  1 open("Main", "ThisPageDoesNotExist");
95  1 open("Main", "WebHome#Attachments");
96  1 waitForDocExtraPaneActive("attachments");
97  1 assertDocExtraPaneInView("attachments");
98   
99  1 open("Main", "ThisPageDoesNotExist");
100  1 open("Main", "WebHome#History");
101  1 waitForDocExtraPaneActive("history");
102  1 assertDocExtraPaneInView("history");
103   
104  1 open("Main", "ThisPageDoesNotExist");
105  1 open("Main", "WebHome#Information");
106  1 waitForDocExtraPaneActive("information");
107  1 assertDocExtraPaneInView("information");
108   
109  1 open("Main", "ThisPageDoesNotExist");
110  1 open("Main", "WebHome#Comments");
111  1 waitForDocExtraPaneActive("comments");
112  1 assertDocExtraPaneInView("comments");
113    }
114   
115    /**
116    * Test document extra presence after clicks on links directing to the extra tabs (top menu for Toucan skin for
117    * example and shortcuts for Colibri skin for example). This test also verify that the browser scrolls to the bottom
118    * of the page.
119    */
 
120  1 toggle @Test
121    public void testDocExtraLoadingFromLinks()
122    {
123  1 open("Main", "WebHome");
124   
125  1 clickShowAttachments();
126  1 waitForDocExtraPaneActive("attachments");
127  1 assertDocExtraPaneInView("attachments");
128  1 scrollToPageTop();
129   
130  1 clickShowHistory();
131  1 waitForDocExtraPaneActive("history");
132  1 assertDocExtraPaneInView("history");
133  1 scrollToPageTop();
134   
135  1 clickShowInformation();
136  1 waitForDocExtraPaneActive("information");
137  1 assertDocExtraPaneInView("information");
138  1 scrollToPageTop();
139   
140  1 clickShowComments();
141  1 waitForDocExtraPaneActive("comments");
142  1 assertDocExtraPaneInView("comments");
143    }
144   
145    /**
146    * @param paneId valid values: "history", "comments", etc
147    */
 
148  16 toggle private void waitForDocExtraPaneActive(String paneId)
149    {
150  16 waitForElement(paneId + "content");
151    }
152   
 
153  6 toggle private void scrollToPageTop()
154    {
155  6 getSelenium().getEval("window.scroll(0,0);");
156    }
157   
 
158  12 toggle private void assertDocExtraPaneInView(String paneId)
159    {
160  12 String paneContentId = String.format("%scontent", paneId);
161  12 assertElementInView(By.id(paneContentId));
162    }
163    }