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

File GlobalRightsAdministrationSectionPage.java

 

Coverage histogram

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

Code metrics

8
18
8
1
108
61
12
0.67
2.25
8
1.5

Classes

Class Line # Actions
GlobalRightsAdministrationSectionPage 33 18 0% 12 13
0.6176470561.8%
 

Contributing tests

This file is covered by 1 test. .

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 org.openqa.selenium.By;
23    import org.openqa.selenium.WebElement;
24    import org.openqa.selenium.support.FindBy;
25    import org.xwiki.test.ui.po.EditRightsPane;
26   
27    /**
28    * Represents the actions possible on the Global Rights Administration Page.
29    *
30    * @version $Id: a3e7c4d3d33e62dbc1737ec51e631f704e00487d $
31    * @since 4.2M1
32    */
 
33    public class GlobalRightsAdministrationSectionPage extends AdministrationSectionPage
34    {
35    @FindBy(id = "guest_comment_requires_captcha")
36    private WebElement captchaCheckBox;
37   
38    @FindBy(id = "authenticate_view")
39    WebElement forceAuthenticatedViewLink;
40   
41    private EditRightsPane editRightsPane = new EditRightsPane();
42   
 
43  2 toggle public GlobalRightsAdministrationSectionPage()
44    {
45  2 super("Rights");
46    }
47   
48    /**
49    * @since 4.2M1
50    */
 
51  1 toggle public static GlobalRightsAdministrationSectionPage gotoPage()
52    {
53  1 getUtil().gotoPage("XWiki", "XWikiPreferences", "admin", "editor=globaladmin&section=Rights");
54  1 return new GlobalRightsAdministrationSectionPage();
55    }
56   
57    /** Checks the "always authenticate user for view" option. */
 
58  1 toggle public void forceAuthenticatedView()
59    {
60  1 setAuthenticatedView(true);
61    }
62   
63    /** Unchecks the "always authenticate user for view" option. */
 
64  1 toggle public void unforceAuthenticatedView()
65    {
66  1 setAuthenticatedView(false);
67    }
68   
 
69  2 toggle private void setAuthenticatedView(boolean enabled)
70    {
71  2 String desiredAltValue = enabled ? "yes" : "no";
72   
73  2 if (!this.forceAuthenticatedViewLink.getAttribute("alt").equals(desiredAltValue)) {
74  2 this.forceAuthenticatedViewLink.click();
75   
76    // Wait for the setting to apply. Wait longer than usual in this case in an attempt to avoid some false
77    // positives in the tests.
78  2 int defaultTimeout = getDriver().getTimeout();
79  2 try {
80  2 getDriver().setTimeout(defaultTimeout * 2);
81  2 getDriver().waitUntilElementHasAttributeValue(
82    By.id(this.forceAuthenticatedViewLink.getAttribute("id")), "alt", desiredAltValue);
83    } finally {
84    // Restore the utils timeout for other tests.
85  2 getDriver().setTimeout(defaultTimeout);
86    }
87    }
88    }
89   
 
90  0 toggle public void disableCAPTCHA()
91    {
92  0 if (this.captchaCheckBox.isSelected()) {
93  0 this.captchaCheckBox.click();
94    }
95    }
96   
 
97  0 toggle public void enableCAPTCHA()
98    {
99  0 if (!this.captchaCheckBox.isSelected()) {
100  0 this.captchaCheckBox.click();
101    }
102    }
103   
 
104  0 toggle public EditRightsPane getEditRightsPane()
105    {
106  0 return this.editRightsPane;
107    }
108    }