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

File PanelWizardTest.java

 

Code metrics

0
72
5
1
159
99
5
0.07
14.4
5
1

Classes

Class Line # Actions
PanelWizardTest 26 72 0% 5 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    public class PanelWizardTest extends AbstractXWikiTestCase
27    {
 
28  4 toggle @Override
29    public void setUp()
30    {
31  4 super.setUp();
32  4 open("Panels", "PanelWizard");
33    }
34   
35    /**
36    * This method makes the following tests:
37    * <ul>
38    * <li>Opens the Wizard Panels page for XWiki instance.</li>
39    * <li>Checks for existence of 2 sections.</li>
40    * </ul>
41    */
 
42  1 toggle @Test
43    public void testSections()
44    {
45  1 assertElementPresent("//a[text()='Page Layout']");
46  1 assertElementPresent("//a[text()='Panel List']");
47    }
48   
49    /**
50    * This method makes the following tests :
51    * <ul>
52    * <li>Opens the Wizard Panels page for XWiki instance.</li>
53    * <li>Opens and test for all 4 layouts for page.</li>
54    * </ul>
55    */
 
56  1 toggle @Test
57    public void testPageLayout()
58    {
59  1 clickLinkWithXPath("//a[@href='#PageLayoutSection']", false);
60    // tests the page layouts
61  1 clickLinkWithXPath("//div[@id='nosidecolumn']", false);
62  1 waitForCondition("selenium.isElementPresent(\"//div[@id='rightPanels' and @style='display: none;']\")!=false;");
63  1 waitForCondition("selenium.isElementPresent(\"//div[@id='leftPanels' and @style='display: none;']\")!=false;");
64  1 assertElementPresent("//div[@id='rightPanels' and @style='display: none;']");
65  1 assertElementPresent("//div[@id='leftPanels' and @style='display: none;']");
66  1 clickLinkWithXPath("//div[@id='leftcolumn']", false);
67  1 waitForCondition("selenium.isElementPresent(\"//div[@id='rightPanels' and @style='display: none;']\")!=false;");
68  1 waitForCondition("selenium.isElementPresent(\"//div[@id='leftPanels' and @style='display: block;']\")!=false;");
69  1 assertElementPresent("//div[@id='rightPanels' and @style='display: none;']");
70  1 assertElementPresent("//div[@id='leftPanels' and @style='display: block;']");
71  1 clickLinkWithXPath("//div[@id='rightcolumn']", false);
72  1 waitForCondition("selenium.isElementPresent(\"//div[@id='rightPanels' and @style='display: block;']\")!=false;");
73  1 waitForCondition("selenium.isElementPresent(\"//div[@id='leftPanels' and @style='display: none;']\")!=false;");
74  1 assertElementPresent("//div[@id='rightPanels' and @style='display: block;']");
75  1 assertElementPresent("//div[@id='leftPanels' and @style='display: none;']");
76  1 clickLinkWithXPath("//div[@id='bothcolumns']", false);
77  1 waitForCondition("selenium.isElementPresent(\"//div[@id='rightPanels' and @style='display: block;']\")!=false;");
78  1 waitForCondition("selenium.isElementPresent(\"//div[@id='leftPanels' and @style='display: block;']\")!=false;");
79  1 assertElementPresent("//div[@id='rightPanels' and @style='display: block;']");
80  1 assertElementPresent("//div[@id='leftPanels' and @style='display: block;']");
81    }
82   
83    /**
84    * This method makes the following tests :
85    * <ul>
86    * <li>Opens the Wizard Panels page for XWiki instance.</li>
87    * <li>Selects 'bothcolums' layout.</li>
88    * <li>Then puts QuickLinks panel on the left side.</li>
89    * </ul>
90    */
 
91  1 toggle @Test
92    public void testInsertQuickLinksPanelInLeftColumn()
93    {
94  1 clickLinkWithXPath("//a[@href='#PageLayoutSection']", false);
95  1 waitForCondition("selenium.isElementPresent(\"//div[@id='rightcolumn']\")!=false;");
96  1 waitForCondition("selenium.isElementPresent(\"//div[@id='bothcolumns']\")!=false;");
97  1 waitForCondition("selenium.isElementPresent(\"//div[@id='leftcolumn']\")!=false;");
98  1 waitForCondition("selenium.isElementPresent(\"//div[@id='nosidecolumn']\")!=false;");
99  1 clickLinkWithXPath("//div[@id='rightcolumn']", false);
100  1 clickLinkWithXPath("//div[@id='bothcolumns']", false);
101  1 waitForBodyContains("Page Layout");
102  1 waitForBodyContains("Panel List");
103  1 clickLinkWithXPath("//a[@href='#PanelListSection']", false);
104  1 dragAndDrop(By.xpath("//div[@class='panel expanded QuickLinks']"), By.id("leftPanels"));
105  1 dragAndDrop(By.xpath("//div[@class='panel expanded CategoriesPanel']"), By.id("rightPanels"));
106  1 clickLinkWithXPath("//button[text()='Save the new layout']", false);
107  1 waitForNotificationSuccessMessage("The layout has been saved properly.");
108  1 open("Panels", "PanelWizard");
109  1 waitForCondition("selenium.isElementPresent(\"//div[@class='panel expanded QuickLinks']\")!=false;");
110  1 waitForCondition("selenium.isElementPresent(\"//div[@class='panel expanded Backlinks']\")!=false;");
111  1 waitForCondition("selenium.isElementPresent(\"leftPanels\")!=false;");
112  1 waitForCondition("selenium.isElementPresent(\"rightPanels\")!=false;");
113  1 assertElementPresent("//div[@class='panel expanded QuickLinks']");
114  1 assertElementPresent("//div[@class='panel expanded CategoriesPanel']");
115  1 assertElementPresent("leftPanels");
116  1 assertElementPresent("rightPanels");
117    }
118   
119    /**
120    * This method makes the following tests :
121    * <ul>
122    * <li>Opens the Wizard Panels page for XWiki instance.</li>
123    * <li>Test all 3 buttons.</li>
124    * </ul>
125    */
 
126  1 toggle @Test
127    public void testButtons()
128    {
129    // test button 'Go to Panels home page'
130  1 waitForBodyContains("Go to Panels home page");
131  1 assertElementPresent("//a[text()='Page Layout']");
132  1 assertElementPresent("//a[text()='Panel List']");
133  1 clickLinkWithText("Go to Panels home page");
134   
135    // test button 'Revert'
136  1 open("Panels", "PanelWizard");
137  1 clickLinkWithXPath("//a[@href='#PageLayoutSection']", false);
138  1 waitForCondition("selenium.isElementPresent(\"//div[@id='rightcolumn']\")!=false;");
139  1 waitForCondition("selenium.isElementPresent(\"//div[@id='bothcolumns']\")!=false;");
140  1 waitForCondition("selenium.isElementPresent(\"//div[@id='leftcolumn']\")!=false;");
141  1 waitForCondition("selenium.isElementPresent(\"//div[@id='nosidecolumn']\")!=false;");
142  1 clickLinkWithXPath("//div[@id='leftcolumn']", false);
143  1 clickLinkWithXPath("//a[@href='#PanelListSection']", false);
144  1 waitForCondition("selenium.isElementPresent(\"//button[text()='Revert']\")!=false;");
145  1 dragAndDrop(By.xpath("//div[@class = 'panel expanded QuickLinks']"), By.id("leftPanels"));
146  1 getSelenium().click("revertLayout");
147   
148    // test button 'Save the new layout'
149  1 waitForCondition("selenium.isElementPresent(\"//a[text()='Panel Wizard']\")!=false;");
150  1 clickLinkWithXPath("//a[text()='Panel Wizard']", true);
151  1 waitForBodyContains("Page Layout");
152  1 waitForBodyContains("Panel List");
153  1 assertElementPresent("//a[text()='Page Layout']");
154  1 assertElementPresent("//a[text()='Panel List']");
155  1 waitForCondition("selenium.isElementPresent(\"//button[text()='Save the new layout']\")!=false;");
156  1 clickLinkWithXPath("//button[text()='Save the new layout']", false);
157  1 waitForNotificationSuccessMessage("The layout has been saved properly.");
158    }
159    }