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

File AbstractWYSIWYGEditorTest.java

 

Coverage histogram

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

Code metrics

4
17
4
1
101
53
6
0.35
4.25
4
1.5

Classes

Class Line # Actions
AbstractWYSIWYGEditorTest 39 17 0% 6 2
0.9292%
 

Contributing tests

No tests hitting this source file were found.

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.wysiwyg.test.ui;
21   
22    import java.util.HashMap;
23    import java.util.Map;
24   
25    import org.junit.*;
26    import org.openqa.selenium.By;
27    import org.xwiki.test.ui.AbstractTest;
28    import org.xwiki.test.ui.SuperAdminAuthenticationRule;
29    import org.xwiki.test.ui.po.FormElement;
30    import org.xwiki.test.ui.po.editor.ObjectEditPage;
31    import org.xwiki.wysiwyg.test.po.WYSIWYGEditPage;
32   
33    /**
34    * Base class for WYSIWYG Editor tests.
35    *
36    * @version $Id: ffe061a25328568a77356df396e4db511773781d $
37    * @since 5.1RC1
38    */
 
39    public abstract class AbstractWYSIWYGEditorTest extends AbstractTest
40    {
41    // Note: We do not use the @Rule annotation since we need this rule to be executed before the configure() method
42    // below which runs **before** any @Rule (since it's tagged with @BeforeClass). Thus we trigger the authentication
43    // manually.
44    public static SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil());
45   
46    /**
47    * The edited page.
48    */
49    protected WYSIWYGEditPage editPage;
50   
 
51  1 toggle @BeforeClass
52    public static void configure()
53    {
54  1 authenticationRule.authenticate();
55  1 enableAllEditingFeatures();
56    }
57   
 
58  9 toggle @Before
59    public void setUp() throws Exception
60    {
61  9 editPage = WYSIWYGEditPage.gotoPage(getTestClassName(), getTestMethodName()).waitUntilPageIsLoaded();
62    }
63   
64    /**
65    * Enables all editing features so they are accessible for testing.
66    */
 
67  1 toggle private static void enableAllEditingFeatures()
68    {
69  1 Map<String, String> config = new HashMap<String, String>();
70  1 config.put("plugins", "submit readonly line separator embed text valign list "
71    + "indent history format symbol link image " + "table macro import color justify font");
72  1 config.put("toolBar", "bold italic underline strikethrough teletype | subscript superscript | "
73    + "justifyleft justifycenter justifyright justifyfull | unorderedlist orderedlist | outdent indent | "
74    + "undo redo | format | fontname fontsize forecolor backcolor | hr removeformat symbol | "
75    + " paste | macro:velocity");
76  1 updateConfiguration(config);
77    }
78   
79    /**
80    * Updates the WYSIWYG editor configuration based on the given configuration object. The key in the configuration is
81    * the name of a {@code XWiki.WysiwygEditorConfigClass} property and the value is the new value for that property.
82    *
83    * @param config the configuration object
84    */
 
85  1 toggle private static void updateConfiguration(Map<String, String> config)
86    {
87  1 ObjectEditPage oep = ObjectEditPage.gotoPage("XWiki", "WysiwygEditorConfig");
88  1 FormElement form = oep.getObjectsOfClass("XWiki.WysiwygEditorConfigClass").get(0);
89  1 boolean save = false;
90  1 for (Map.Entry<String, String> entry : config.entrySet()) {
91  2 String propertyId = "XWiki.WysiwygEditorConfigClass_0_" + entry.getKey();
92  2 if (!entry.getValue().equals(form.getFieldValue(By.id(propertyId)))) {
93  2 form.setFieldValue(By.id(propertyId), entry.getValue());
94  2 save = true;
95    }
96    }
97  1 if (save) {
98  1 oep.clickSaveAndContinue();
99    }
100    }
101    }