| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.wysiwyg.test.po; |
| 21 |
|
|
| 22 |
|
import org.openqa.selenium.By; |
| 23 |
|
import org.openqa.selenium.WebDriver; |
| 24 |
|
import org.openqa.selenium.WebElement; |
| 25 |
|
import org.openqa.selenium.support.ui.ExpectedCondition; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
@version |
| 31 |
|
@since |
| 32 |
|
|
| |
|
| 78% |
Uncovered Elements: 9 (41) |
Complexity: 16 |
Complexity Density: 0.8 |
|
| 33 |
|
public class EditorElement extends org.xwiki.test.ui.po.editor.wysiwyg.EditorElement |
| 34 |
|
{ |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
private static final String TAB_ITEM_XPATH = "//div[@role = 'tab' and . = '%s']"; |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
|
private MenuBarElement menuBar; |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
private ToolBarElement toolBar; |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
@param |
| 54 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 55 |
19 |
public EditorElement(String fieldId)... |
| 56 |
|
{ |
| 57 |
19 |
super(fieldId); |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
@return |
| 62 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 63 |
2 |
public MenuBarElement getMenuBar()... |
| 64 |
|
{ |
| 65 |
2 |
if (menuBar == null) { |
| 66 |
1 |
menuBar = new MenuBarElement(getContainer().findElement(By.className("gwt-MenuBar-horizontal"))); |
| 67 |
|
} |
| 68 |
2 |
return menuBar; |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
@return |
| 73 |
|
|
| |
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 74 |
0 |
public ToolBarElement getToolBar()... |
| 75 |
|
{ |
| 76 |
0 |
if (toolBar == null) { |
| 77 |
0 |
toolBar = new ToolBarElement(getContainer().findElement(By.className("xToolbar"))); |
| 78 |
|
} |
| 79 |
0 |
return toolBar; |
| 80 |
|
} |
| 81 |
|
|
| 82 |
|
|
| 83 |
|
@return |
| 84 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 85 |
8 |
public WebElement getSourceTextArea()... |
| 86 |
|
{ |
| 87 |
8 |
return getContainer().findElement(By.className("xPlainTextEditor")); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 94 |
4 |
public void switchToSource()... |
| 95 |
|
{ |
| 96 |
4 |
switchToSource(true); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
@param |
| 103 |
|
|
| |
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 104 |
4 |
public void switchToSource(boolean wait)... |
| 105 |
|
{ |
| 106 |
4 |
getContainer().findElement(By.xpath(String.format(TAB_ITEM_XPATH, "Source"))).click(); |
| 107 |
4 |
if (wait) { |
| 108 |
4 |
waitForSourceTextArea(true); |
| 109 |
|
} |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 116 |
2 |
public void switchToWysiwyg()... |
| 117 |
|
{ |
| 118 |
2 |
switchToWysiwyg(true); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
@param |
| 125 |
|
|
| |
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 126 |
2 |
public void switchToWysiwyg(boolean wait)... |
| 127 |
|
{ |
| 128 |
2 |
getContainer().findElement(By.xpath(String.format(TAB_ITEM_XPATH, "WYSIWYG"))).click(); |
| 129 |
2 |
if (wait) { |
| 130 |
2 |
waitForSourceTextArea(false); |
| 131 |
|
} |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
@param |
| 138 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 139 |
6 |
private void waitForSourceTextArea(final boolean enabled)... |
| 140 |
|
{ |
| 141 |
6 |
getDriver().waitUntilCondition(new ExpectedCondition<WebElement>() |
| 142 |
|
{ |
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 143 |
6 |
@Override... |
| 144 |
|
public WebElement apply(WebDriver driver) |
| 145 |
|
{ |
| 146 |
6 |
WebElement sourceTextArea = getContainer().findElement(By.className("xPlainTextEditor")); |
| 147 |
6 |
return sourceTextArea.isEnabled() == enabled ? sourceTextArea : null; |
| 148 |
|
} |
| 149 |
|
}); |
| 150 |
|
} |
| 151 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 152 |
8 |
@Override... |
| 153 |
|
public EditorElement waitToLoad() |
| 154 |
|
{ |
| 155 |
8 |
return (EditorElement) super.waitToLoad(); |
| 156 |
|
} |
| 157 |
|
} |