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

File PaginationFilterPane.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
12
9
1
162
61
9
0.75
1.33
9
1

Classes

Class Line # Actions
PaginationFilterPane 33 12 0% 9 0
1.0100%
 

Contributing tests

This file is covered by 2 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.extension.test.po;
21   
22    import org.openqa.selenium.By;
23    import org.openqa.selenium.WebElement;
24    import org.openqa.selenium.support.FindBy;
25    import org.xwiki.test.ui.po.BaseElement;
26   
27    /**
28    * Represents the pagination filter.
29    *
30    * @version $Id: d7ac42c21ca14efb9c7b420c930985691c4f9aaf $
31    * @since 4.2M1
32    */
 
33    public class PaginationFilterPane extends BaseElement
34    {
35    /**
36    * The class name of the next page button.
37    */
38    private static final String NEXT_PAGE_CLASS_NAME = "nextPagination";
39   
40    /**
41    * The class name of the previous page button.
42    */
43    private static final String PREVIOUS_PAGE_CLASS_NAME = "prevPagination";
44   
45    /**
46    * The elements that displays the total number of results.
47    */
48    @FindBy(className = "totalResultsNo")
49    private WebElement resultsCount;
50   
51    /**
52    * The element that displays the index of the first and last result from the current page.
53    */
54    @FindBy(className = "currentResultsNo")
55    private WebElement currentRange;
56   
57    /**
58    * The element that displays the index of the current page.
59    */
60    @FindBy(className = "currentPage")
61    private WebElement currentPageIndex;
62   
63    /**
64    * The index of the last page.
65    */
66    @FindBy(xpath = "//span[@class = 'pagination']/*[last()]")
67    private WebElement lastPageIndex;
68   
69    /**
70    * The button used to navigate to the previous page.
71    */
72    @FindBy(className = PREVIOUS_PAGE_CLASS_NAME)
73    private WebElement previousPageButton;
74   
75    /**
76    * The button used to navigate to the next page.
77    */
78    @FindBy(className = NEXT_PAGE_CLASS_NAME)
79    private WebElement nextPageButton;
80   
81    /**
82    * @return the total number of results
83    */
 
84  5 toggle public int getResultsCount()
85    {
86  5 return Integer.parseInt(resultsCount.getText());
87    }
88   
89    /**
90    * @return the index of the first and last result on the current page, using this format: {@code start - end}
91    */
 
92  4 toggle public String getCurrentRange()
93    {
94  4 return currentRange.getText();
95    }
96   
97    /**
98    * @return the index of the current page
99    */
 
100  5 toggle public int getCurrentPageIndex()
101    {
102  5 return Integer.parseInt(currentPageIndex.getText());
103    }
104   
105    /**
106    * @return the number of pages
107    */
 
108  4 toggle public int getPageCount()
109    {
110  4 return Integer.parseInt(lastPageIndex.getText());
111    }
112   
113    /**
114    * Navigates to the next page.
115    *
116    * @return the new pagination filter matching the next page
117    */
 
118  1 toggle public PaginationFilterPane nextPage()
119    {
120  1 nextPageButton.click();
121  1 return new PaginationFilterPane();
122    }
123   
124    /**
125    * @return {@code true} if the previous page button is active, {@code false} otherwise
126    */
 
127  3 toggle public boolean hasNextPage()
128    {
129  3 return getDriver().findElements(By.className(NEXT_PAGE_CLASS_NAME)).size() > 0;
130    }
131   
132    /**
133    * Navigates to the previous page.
134    *
135    * @return the new pagination filter matching the previous page
136    */
 
137  1 toggle public PaginationFilterPane previousPage()
138    {
139  1 previousPageButton.click();
140  1 return new PaginationFilterPane();
141    }
142   
143    /**
144    * @return {@code true} if the previous page button is active, {@code false} otherwise
145    */
 
146  2 toggle public boolean hasPreviousPage()
147    {
148  2 return getDriver().findElements(By.className(PREVIOUS_PAGE_CLASS_NAME)).size() > 0;
149    }
150   
151    /**
152    * Loads the specified page of results.
153    *
154    * @param index the page index
155    * @return the specified page
156    */
 
157  2 toggle public PaginationFilterPane gotoPage(int index)
158    {
159  2 getDriver().findElement(By.xpath("//span[@class = 'pagination']/a[. = '" + index + "']")).click();
160  2 return new PaginationFilterPane();
161    }
162    }