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

File ClassEditPage.java

 

Coverage histogram

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

Code metrics

2
22
10
1
133
73
11
0.5
2.2
10
1.1

Classes

Class Line # Actions
ClassEditPage 33 22 0% 11 0
1.0100%
 

Contributing tests

This file is covered by 10 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.ui.po.editor;
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.FormElement;
26   
27    /**
28    * Represents the common actions possible on all Pages when using the "edit" action with the "class" editor.
29    *
30    * @version $Id: ba1f1b6c6238e22122ab442ea00ace4f333a735c $
31    * @since 3.2M3
32    */
 
33    public class ClassEditPage extends EditPage
34    {
35    @FindBy(name = "action_propupdate")
36    private WebElement saveandview;
37   
38    @FindBy(id = "propupdate")
39    private WebElement propertyForm;
40   
41    @FindBy(id = "propname")
42    private WebElement propertyNameField;
43   
44    @FindBy(id = "proptype")
45    private WebElement propertyTypeField;
46   
47    @FindBy(name = "action_propadd")
48    private WebElement propertySubmit;
49   
50    private FormElement form;
51   
52    /**
53    * Go to the passed page in object edit mode.
54    */
 
55  9 toggle public static ClassEditPage gotoPage(String space, String page)
56    {
57  9 getUtil().gotoPage(space, page, "edit", "editor=class");
58  9 return new ClassEditPage();
59    }
60   
 
61  12 toggle public ClassPropertyEditPane addProperty(String propertyName, String propertyType)
62    {
63  12 addPropertyWithoutWaiting(propertyName, propertyType);
64   
65    // The following call waits for the element to appear since there's no page refresh.
66  12 return getPropertyEditPane(propertyName);
67    }
68   
69    /**
70    * @since 3.2M3
71    */
 
72  13 toggle public void addPropertyWithoutWaiting(String propertyName, String propertyType)
73    {
74  13 getForm().setFieldValue(this.propertyNameField, propertyName);
75  13 getForm().setFieldValue(this.propertyTypeField, propertyType);
76  13 this.propertySubmit.click();
77    }
78   
 
79  2 toggle public void deleteProperty(String propertyName)
80    {
81  2 final By propertyLocator = By.id("xproperty_" + propertyName);
82  2 final WebElement propertyContainer = getDriver().findElement(propertyLocator);
83  2 WebElement deleteLink = propertyContainer.findElement(By.className("delete"));
84  2 deleteLink.click();
85   
86    // Expect a confirmation box
87  2 getDriver().waitUntilElementIsVisible(By.className("xdialog-box-confirmation"));
88  2 getDriver().findElement(By.cssSelector(".xdialog-box-confirmation input[value='Yes']")).click();
89  2 getDriver().waitUntilElementDisappears(propertyLocator);
90    }
91   
 
92  49 toggle private FormElement getForm()
93    {
94  49 if (this.form == null) {
95  17 this.form = new FormElement(this.propertyForm);
96    }
97  49 return this.form;
98    }
99   
100    /**
101    * Use this method if you need to set generic meta-properties (common to all XClass property types). For specific
102    * meta-properties use the methods dedicated to each XClass property type.
103    *
104    * @param propertyName the name of a property of this class
105    * @return the pane used to edit the specified property
106    * @since 4.5
107    */
 
108  12 toggle public ClassPropertyEditPane getPropertyEditPane(String propertyName)
109    {
110  12 return new ClassPropertyEditPane(getForm(), propertyName).expand();
111    }
112   
 
113  2 toggle public DatabaseListClassEditElement getDatabaseListClassEditElement(String propertyName)
114    {
115  2 return (DatabaseListClassEditElement) new DatabaseListClassEditElement(getForm(), propertyName).expand();
116    }
117   
 
118  5 toggle public StaticListClassEditElement getStaticListClassEditElement(String propertyName)
119    {
120  5 return (StaticListClassEditElement) new StaticListClassEditElement(getForm(), propertyName).expand();
121    }
122   
 
123  4 toggle public NumberClassEditElement getNumberClassEditElement(String propertyName)
124    {
125  4 return (NumberClassEditElement) new NumberClassEditElement(getForm(), propertyName).expand();
126    }
127   
 
128  15 toggle @Override
129    public WebElement getSaveAndViewButton()
130    {
131  15 return saveandview;
132    }
133    }