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

File ImportTest.java

 

Code metrics

0
20
4
1
92
42
4
0.2
5
4
1

Classes

Class Line # Actions
ImportTest 31 20 0% 4 0
1.0100%
 

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.test.wysiwyg;
21   
22    import org.junit.Test;
23    import org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase;
24   
25    /**
26    * Test case for wysiwyg content import plugin.
27    *
28    * @version $Id: 808457a45ed859d36cdd585931b9d5a5d6b9149d $
29    * @since 2.0.1
30    */
 
31    public class ImportTest extends AbstractWysiwygTestCase
32    {
33    public static final String IMPORT_BUTTON = "Import";
34   
35    public static final String FILTER_STYLES = "//div[@class = 'xDialogBody']//input[@type = 'checkbox']";
36   
37    /**
38    * Test that the paste wizard works.
39    */
 
40  1 toggle @Test
41    public void testPasteFromClipboard()
42    {
43  1 clickPasteButton();
44  1 populateOfficeContentEditor("<p>Hello <font color=\"#ff0000\">World</font></p>");
45  1 getSelenium().uncheck(FILTER_STYLES);
46  1 clickButtonWithText(IMPORT_BUTTON);
47  1 waitForDialogToClose();
48  1 switchToSource();
49  1 assertSourceText("Hello (% style=\"color:#ff0000;\" %)World");
50    }
51   
52    /**
53    * @see XWIKI-3040: A rich text area on a dialog box looses its content if we move the dialog box
54    */
 
55  1 toggle @Test
56    public void testPastedContentIsPreservedWhenDialogIsMoved()
57    {
58  1 clickPasteButton();
59    // Put some content inside the rich text area of the office import dialog.
60  1 populateOfficeContentEditor("office");
61    // Move the dialog.
62  1 getSelenium().dragdrop("//div[@class='gwt-Label xDialogCaption']", "100, 100");
63    // Import the pasted content.
64  1 clickButtonWithText(IMPORT_BUTTON);
65  1 waitForDialogToClose();
66    // Check the result.
67  1 switchToSource();
68  1 assertSourceText("office");
69    }
70   
71    /**
72    * Click the paste button on the tool bar.
73    */
 
74  2 toggle protected void clickPasteButton()
75    {
76  2 pushToolBarButton("Paste");
77    }
78   
79    /**
80    * Utility method for injecting html content into office import wizard's copy paste area.
81    *
82    * @param innerHTML html content.
83    */
 
84  2 toggle private void populateOfficeContentEditor(String innerHTML)
85    {
86  2 StringBuilder script = new StringBuilder();
87  2 script.append("var eframe = document.getElementsByClassName('xImportOfficeContentEditor')[0];\n");
88  2 script.append("var rte = eframe.contentWindow.document.body;\n");
89  2 script.append(String.format("rte.innerHTML = '%s';\n", innerHTML));
90  2 getSelenium().getEval(script.toString());
91    }
92    }