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

File TreeSuggestionsPane.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart7.png
64% of files have more coverage

Code metrics

0
10
10
1
128
49
10
1
1
10
1

Classes

Class Line # Actions
TreeSuggestionsPane 30 10 0% 10 6
0.770%
 

Contributing tests

This file is covered by 16 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.wysiwyg.framework;
21   
22    import org.openqa.selenium.By;
23    import org.xwiki.test.ui.XWikiWebDriver;
24   
25    /**
26    * The list of suggestions provided by the tree finder.
27    *
28    * @version $Id: d342dd800732463ead6a2bd11dcb42be46ff5497 $
29    */
 
30    public class TreeSuggestionsPane
31    {
32    private final XWikiWebDriver driver;
33   
34    /**
35    * Creates a new instance that uses the given web driver.
36    *
37    * @param driver the web driver
38    */
 
39  26 toggle public TreeSuggestionsPane(XWikiWebDriver driver)
40    {
41  26 this.driver = driver;
42    }
43   
44    /**
45    * Select the space with the given name from the list of suggestions.
46    *
47    * @param spaceName the space name
48    */
 
49  0 toggle public void selectSpace(String spaceName)
50    {
51  0 select(spaceName, "space");
52    }
53   
54    /**
55    * Select the page with the given title from the list of suggestions.
56    *
57    * @param pageTitle the page title
58    */
 
59  16 toggle public void selectPage(String pageTitle)
60    {
61  16 select(pageTitle, "document");
62    }
63   
64    /**
65    * Select the attachment with the given name from the list of suggestions.
66    *
67    * @param fileName the attachment file name
68    */
 
69  5 toggle public void selectAttachment(String fileName)
70    {
71  5 select(fileName, "attachment");
72    }
73   
74    /**
75    * Select the suggestion with the given value and type.
76    *
77    * @param value the suggestion value
78    * @param type the suggestion type
79    */
 
80  21 toggle private void select(String value, String type)
81    {
82  21 this.driver.findElementByXPath(getSuggestionSelector(value, type)).click();
83    }
84   
85    /**
86    * @param spaceName the space name
87    * @return {@code true} if there is a suggestion matching the given space name, {@code false} otherwise
88    */
 
89  0 toggle public boolean hasSpace(String spaceName)
90    {
91  0 return hasSuggestion(spaceName, "space");
92    }
93   
94    /**
95    * @param pageTitle the page title
96    * @return {@code true} if there is a suggestion matching the given page title, {@code false} otherwise
97    */
 
98  4 toggle public boolean hasPage(String pageTitle)
99    {
100  4 return hasSuggestion(pageTitle, "document");
101    }
102   
103    /**
104    * @param fileName the file name
105    * @return {@code true} if there is a suggestion matching the given file name, {@code false} otherwise
106    */
 
107  0 toggle public boolean hasAttachment(String fileName)
108    {
109  0 return hasSuggestion(fileName, "attachment");
110    }
111   
112    /**
113    * @param value the suggestion value
114    * @param type the suggestion type
115    * @return {@code true} if there is a suggestion with the given value and type
116    */
 
117  4 toggle private boolean hasSuggestion(String value, String type)
118    {
119  4 return this.driver.hasElementWithoutWaiting(By.xpath(getSuggestionSelector(value, type)));
120    }
121   
 
122  25 toggle private String getSuggestionSelector(String value, String type)
123    {
124  25 return String.format("//div[contains(@class, 'xtree-finder-suggestions')]"
125    + "//div[contains(@class, 'suggestItem') and contains(@class, '%s')]"
126    + "//div[@class = 'value' and contains(., '%s')]", type, value);
127    }
128    }