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

File SearchResultsPane.java

 

Coverage histogram

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

Code metrics

6
13
6
1
105
44
9
0.69
2.17
6
1.5

Classes

Class Line # Actions
SearchResultsPane 35 13 0% 9 0
1.0100%
 

Contributing tests

This file is covered by 15 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 java.util.List;
23   
24    import org.openqa.selenium.By;
25    import org.openqa.selenium.WebElement;
26    import org.xwiki.extension.ExtensionId;
27    import org.xwiki.test.ui.po.BaseElement;
28   
29    /**
30    * Represents the extension search results.
31    *
32    * @version $Id: 80015ed2873632e2021c747487de7a7cca36baed $
33    * @since 4.2M1
34    */
 
35    public class SearchResultsPane extends BaseElement
36    {
37    /**
38    * @return the search results pagination
39    */
 
40  6 toggle public PaginationFilterPane getPagination()
41    {
42  6 return getDriver().hasElementWithoutWaiting(By.className("paginationFilter")) ? new PaginationFilterPane()
43    : null;
44    }
45   
46    /**
47    * @return the number of extensions displayed
48    */
 
49  13 toggle public int getDisplayedResultsCount()
50    {
51  13 return getDriver().findElementsWithoutWaiting(By.className("extension-item")).size();
52    }
53   
54    /**
55    * @return the message displayed if there are no search results
56    */
 
57  7 toggle public String getNoResultsMessage()
58    {
59  7 String xpath =
60    "//div[contains(@class, 'infomessage') and preceding-sibling::div[1][@class = 'extension-search-bar']]";
61  7 List<WebElement> found = getDriver().findElementsWithoutWaiting(By.xpath(xpath));
62  7 return found.size() > 0 ? found.get(0).getText() : null;
63    }
64   
65    /**
66    * Looks for the specified extension on the current results page.
67    *
68    * @param name the extension pretty name
69    * @param version the extension version
70    * @return the pane displaying the specified extension, {@code null} if not found
71    */
 
72  15 toggle public ExtensionPane getExtension(String name, String version)
73    {
74  15 String nameAndVersion = name + " " + version;
75  15 By xpath =
76    By.xpath("//form[contains(@class, 'extension-item') and descendant::*[contains(@class, "
77    + "'extension-title') and normalize-space(.) = '" + nameAndVersion + "']]");
78  15 List<WebElement> found = getDriver().findElements(xpath);
79  15 return found.size() == 1 ? new ExtensionPane(found.get(0)) : null;
80    }
81   
82    /**
83    * Looks for the specified extension on the current results page.
84    *
85    * @param extensionId the extension identifier
86    * @return the pane displaying the specified extension, {@code null} if not found
87    */
 
88  15 toggle public ExtensionPane getExtension(ExtensionId extensionId)
89    {
90  15 return getExtension(extensionId.getId(), extensionId.getVersion().getValue());
91    }
92   
93    /**
94    * Looks for the extension with the specified index in the search results.
95    *
96    * @param index the 0-based index of the extension in the results
97    * @return the pane displaying the specified extension
98    */
 
99  25 toggle public ExtensionPane getExtension(int index)
100    {
101  25 int position = index + 1;
102  25 By xpath = By.xpath("//form[contains(@class, 'extension-item')][" + position + "]");
103  25 return new ExtensionPane(getDriver().findElement(xpath));
104    }
105    }