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

File EditThemePage.java

 

Coverage histogram

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

Code metrics

2
25
12
1
133
87
13
0.52
2.08
12
1.08

Classes

Class Line # Actions
EditThemePage 31 25 0% 13 1
0.97435997.4%
 

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.flamingo.test.po;
21   
22    import java.util.ArrayList;
23    import java.util.List;
24   
25    import org.openqa.selenium.By;
26    import org.openqa.selenium.Keys;
27    import org.openqa.selenium.WebElement;
28    import org.openqa.selenium.support.FindBy;
29    import org.xwiki.test.ui.po.editor.EditPage;
30   
 
31    public class EditThemePage extends EditPage
32    {
33    @FindBy(id = "autosync")
34    private WebElement autoSyncCheckBox;
35   
36    @FindBy(id = "refresh")
37    private WebElement refreshButton;
38   
39    @FindBy(id = "preview-curtain")
40    private WebElement previewCurtain;
41   
 
42  2 toggle public EditThemePage()
43    {
44  2 waitUntilPageJSIsLoaded();
45    }
46   
 
47  8 toggle public void selectVariableCategory(String category)
48    {
49  8 WebElement categoryElem = getDriver().findElement(
50    By.xpath("//div[@id='panel-theme-variables']//div[@class='panel-body']"
51    + "//li//a[@data-toggle='tab' and text()='" + category + "']"));
52  8 categoryElem.click();
53    // Wait until the panel is displayed
54  8 getDriver().waitUntilElementIsVisible(
55    By.xpath("//div[@id='bt-variables']//div[contains(@class, 'active')]/h2[text()='"+category+"']"));
56    }
57   
 
58  3 toggle public List<String> getVariableCategories()
59    {
60  3 List<String> results = new ArrayList<>();
61  3 List<WebElement> categoryElems = getDriver().findElements(
62    By.xpath("//div[@id='panel-theme-variables']//div[@class='panel-body']"
63    + "//li//a[@data-toggle='tab']"));
64  3 for (WebElement elem : categoryElems) {
65  33 results.add(elem.getText());
66    }
67   
68  3 return results;
69    }
70   
 
71  2 toggle public void setAutoRefresh(boolean enabled)
72    {
73  2 if (autoSyncCheckBox.isEnabled() != enabled) {
74  2 autoSyncCheckBox.click();
75    }
76    }
77   
 
78  4 toggle public void setVariableValue(String variableName, String value)
79    {
80  4 WebElement variableField = getDriver().findElement(By.xpath("//label[text() = '@"+variableName+"']/..//input"));
81    // Remove the previous value
82  4 variableField.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE);
83    // Write the new one
84  4 variableField.sendKeys(value);
85    }
86   
87    /**
88    * @since 6.3RC1
89    */
 
90  2 toggle public void setTextareaValue(String variableName, String value)
91    {
92  2 WebElement variableField = getDriver().findElement(
93    By.xpath("//label[text() = '@"+variableName+"']/..//textarea"));
94    // Remove the previous value
95  2 variableField.sendKeys(Keys.chord(Keys.CONTROL, "a"), Keys.BACK_SPACE);
96    // Write the new one
97  2 variableField.sendKeys(value);
98    }
99   
 
100  1 toggle public void clickOnRefreshPreview()
101    {
102  1 refreshButton.click();
103    }
104   
 
105  1 toggle public void refreshPreview()
106    {
107  1 clickOnRefreshPreview();
108  1 waitUntilPreviewIsLoaded();
109    }
110   
 
111  1 toggle public boolean isPreviewBoxLoading()
112    {
113  1 return previewCurtain.isDisplayed();
114    }
115   
 
116  3 toggle public void waitUntilPreviewIsLoaded()
117    {
118  3 getDriver().waitUntilElementDisappears(By.id("preview-curtain"));
119    }
120   
 
121  1 toggle public PreviewBox getPreviewBox()
122    {
123  1 return new PreviewBox();
124    }
125   
 
126  1 toggle @Override
127    public ViewThemePage clickSaveAndView()
128    {
129  1 this.save.click();
130  1 return new ViewThemePage();
131    }
132   
133    }