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

File TemplateProviderInlinePage.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart3.png
80% of files have more coverage

Code metrics

6
28
15
1
194
106
18
0.64
1.87
15
1.2

Classes

Class Line # Actions
TemplateProviderInlinePage 36 28 0% 18 37
0.2448979624.5%
 

Contributing tests

This file is covered by 3 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.administration.test.po;
21   
22    import java.util.List;
23   
24    import org.openqa.selenium.By;
25    import org.openqa.selenium.WebElement;
26    import org.openqa.selenium.support.FindBy;
27    import org.xwiki.test.ui.po.InlinePage;
28    import org.xwiki.test.ui.po.Select;
29   
30    /**
31    * Represents a template provider page in inline mode
32    *
33    * @version $Id: 56b322890141326c0b29d109b5b82d957ec91759 $
34    * @since 4.2M1
35    */
 
36    public class TemplateProviderInlinePage extends InlinePage
37    {
38    public static final String ACTION_SAVEANDEDIT = "saveandedit";
39   
40    public static final String ACTION_EDITONLY = "edit";
41   
42    @FindBy(name = "XWiki.TemplateProviderClass_0_template")
43    private WebElement templateInput;
44   
45    @FindBy(name = "XWiki.TemplateProviderClass_0_name")
46    private WebElement templateNameInput;
47   
48    @FindBy(name = "XWiki.TemplateProviderClass_0_type")
49    private WebElement templateTypeSelect;
50   
51    @FindBy(name = "XWiki.TemplateProviderClass_0_terminal")
52    private WebElement terminalSelect;
53   
54    @FindBy(name = "XWiki.TemplateProviderClass_0_action")
55    private WebElement templateActionSelect;
56   
57    private LocationPicker creationRestrictionsPicker =
58    new LocationPicker("XWiki.TemplateProviderClass_0_creationRestrictions");
59   
60    @FindBy(name = "XWiki.TemplateProviderClass_0_creationRestrictionsAreSuggestions")
61    private WebElement creationRestrictionsAreSuggestionsCheckbox;
62   
63    private LocationPicker visibilityRestrictionsPicker =
64    new LocationPicker("XWiki.TemplateProviderClass_0_visibilityRestrictions");
65   
 
66  0 toggle public String getTemplateName()
67    {
68  0 return this.templateNameInput.getAttribute("value");
69    }
70   
 
71  3 toggle public void setTemplateName(String value)
72    {
73  3 this.templateNameInput.clear();
74  3 this.templateNameInput.sendKeys(value);
75    }
76   
 
77  0 toggle public String getTemplate()
78    {
79  0 return this.templateInput.getAttribute("value");
80    }
81   
 
82  3 toggle public void setTemplate(String value)
83    {
84  3 this.templateInput.clear();
85  3 this.templateInput.sendKeys(value);
86    }
87   
 
88  0 toggle public boolean isPageTemplate()
89    {
90  0 return this.templateTypeSelect.findElement(By.xpath("//option[@value='page']")).isSelected();
91    }
92   
 
93  0 toggle public void setPageTemplate(boolean isPageTemplate)
94    {
95  0 Select select = new Select(this.templateTypeSelect);
96   
97  0 String value;
98  0 if (isPageTemplate) {
99  0 value = "page";
100    } else {
101  0 value = "space";
102    }
103   
104  0 select.selectByValue(value);
105    }
106   
 
107  0 toggle public boolean isTerminal()
108    {
109  0 return this.terminalSelect.findElement(By.xpath("//option[@value='1']")).isSelected();
110    }
111   
 
112  0 toggle public void setTerminal(boolean isTerminal)
113    {
114  0 Select select = new Select(this.terminalSelect);
115   
116  0 String value;
117  0 if (isTerminal) {
118  0 value = "1";
119    } else {
120  0 value = "0";
121    }
122   
123  0 select.selectByValue(value);
124    }
125   
126    /**
127    * @return the list of spaces
128    * @since 8.2M3 (renamed from getSpaces)
129    */
 
130  0 toggle public List<String> getVisibilityRestrictions()
131    {
132  0 return this.visibilityRestrictionsPicker.getValue();
133    }
134   
135    /**
136    * @param spaces the list of spaces
137    * @since 8.2M3 (renamed from setSpaces)
138    */
 
139  1 toggle public void setVisibilityRestrictions(List<String> spaces)
140    {
141  1 this.visibilityRestrictionsPicker.setValue(spaces);
142    }
143   
144    /**
145    * @param spaces the list of spaces to set
146    * @since 8.3M2
147    */
 
148  1 toggle public void setCreationRestrictions(List<String> spaces)
149    {
150  1 this.creationRestrictionsPicker.setValue(spaces);
151    }
152   
153    /**
154    * @return the list of spaces
155    * @since 8.2M2
156    */
 
157  0 toggle public List<String> getCreationRestrictions()
158    {
159  0 return this.creationRestrictionsPicker.getValue();
160    }
161   
162    /**
163    * The action to execute when the create button is pushed, you can configure here whether the new document is saved
164    * before it is opened for edition or not.
165    *
166    * @param actionName the behavior to have on create; valid values are "saveandedit" and "edit". See
167    * {@link #ACTION_EDITONLY} and {@link #ACTION_SAVEANDEDIT}
168    * @since 7.2M2
169    */
 
170  1 toggle public void setActionOnCreate(String actionName)
171    {
172  1 this.templateActionSelect.findElement(By.xpath("//option[@value='" + actionName + "']")).click();
173    }
174   
175    /**
176    * @return true if the creationRestrictions are suggestions, false otherwise
177    * @since 8.3M2
178    */
 
179  0 toggle public boolean isCreationRestrictionsSuggestions()
180    {
181  0 return this.creationRestrictionsAreSuggestionsCheckbox.isSelected();
182    }
183   
184    /**
185    * @param selected true if the creationRestrictions should be suggestions, false otherwise
186    * @since 8.3M2
187    */
 
188  0 toggle public void setCreationRestrictionsSuggestions(boolean selected)
189    {
190  0 if (this.creationRestrictionsAreSuggestionsCheckbox.isSelected() != selected) {
191  0 this.creationRestrictionsAreSuggestionsCheckbox.click();
192    }
193    }
194    }