| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.index.tree.test.po; |
| 21 |
|
|
| 22 |
|
import org.openqa.selenium.By; |
| 23 |
|
import org.openqa.selenium.StaleElementReferenceException; |
| 24 |
|
import org.openqa.selenium.WebDriver; |
| 25 |
|
import org.openqa.selenium.WebElement; |
| 26 |
|
import org.openqa.selenium.support.ui.ExpectedCondition; |
| 27 |
|
import org.xwiki.test.ui.po.BaseElement; |
| 28 |
|
import org.xwiki.test.ui.po.DocumentPicker; |
| 29 |
|
|
| 30 |
|
|
| 31 |
|
@link |
| 32 |
|
|
| 33 |
|
@version |
| 34 |
|
@since |
| 35 |
|
|
| |
|
| 88.9% |
Uncovered Elements: 4 (36) |
Complexity: 13 |
Complexity Density: 0.57 |
|
| 36 |
|
public class DocumentPickerModal extends BaseElement |
| 37 |
|
{ |
| 38 |
|
private WebElement container; |
| 39 |
|
|
| 40 |
|
private DocumentTreeElement tree; |
| 41 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 42 |
2 |
public DocumentPickerModal()... |
| 43 |
|
{ |
| 44 |
2 |
this(By.cssSelector(".location-picker .modal")); |
| 45 |
|
} |
| 46 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 47 |
4 |
public DocumentPickerModal(By selector)... |
| 48 |
|
{ |
| 49 |
4 |
this.container = getDriver().findElementWithoutWaiting(selector); |
| 50 |
|
|
| 51 |
4 |
this.waitForIt(); |
| 52 |
|
} |
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 54 |
11 |
public DocumentTreeElement getTree()... |
| 55 |
|
{ |
| 56 |
11 |
if (this.tree == null) { |
| 57 |
4 |
this.tree = new DocumentTreeElement(this.container.findElement(By.className("location-tree"))); |
| 58 |
|
} |
| 59 |
11 |
return this.tree; |
| 60 |
|
} |
| 61 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 62 |
0 |
public void cancel()... |
| 63 |
|
{ |
| 64 |
0 |
this.container.findElement(By.className("btn-default")).click(); |
| 65 |
0 |
waitToClose(); |
| 66 |
|
} |
| 67 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 68 |
4 |
public void select()... |
| 69 |
|
{ |
| 70 |
4 |
this.container.findElement(By.className("btn-primary")).click(); |
| 71 |
4 |
waitToClose(); |
| 72 |
|
} |
| 73 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 74 |
4 |
public void selectDocument(String... path)... |
| 75 |
|
{ |
| 76 |
4 |
getTree().clearSelection().openToDocument(path); |
| 77 |
4 |
select(); |
| 78 |
|
} |
| 79 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 80 |
6 |
public DocumentPickerModal waitForIt()... |
| 81 |
|
{ |
| 82 |
|
|
| 83 |
6 |
getDriver().waitUntilCondition(new ExpectedCondition<Boolean>() |
| 84 |
|
{ |
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 85 |
8 |
@Override... |
| 86 |
|
public Boolean apply(WebDriver driver) |
| 87 |
|
{ |
| 88 |
8 |
try { |
| 89 |
8 |
return container.getAttribute("class").endsWith(" in"); |
| 90 |
|
} catch (StaleElementReferenceException e) { |
| 91 |
|
|
| 92 |
0 |
return false; |
| 93 |
|
} |
| 94 |
|
} |
| 95 |
|
}); |
| 96 |
|
|
| 97 |
|
|
| 98 |
6 |
getTree().waitForIt(); |
| 99 |
|
|
| 100 |
6 |
return this; |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
@return |
| 108 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 109 |
4 |
public DocumentPickerModal waitToClose()... |
| 110 |
|
{ |
| 111 |
4 |
getDriver().waitUntilCondition(new ExpectedCondition<Boolean>() |
| 112 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 113 |
4 |
@Override... |
| 114 |
|
public Boolean apply(WebDriver driver) |
| 115 |
|
{ |
| 116 |
4 |
return !container.isDisplayed(); |
| 117 |
|
} |
| 118 |
|
}); |
| 119 |
4 |
return this; |
| 120 |
|
} |
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
@param |
| 127 |
|
@return |
| 128 |
|
@since |
| 129 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 130 |
1 |
public DocumentPickerModal waitForDocumentSelected(String... path)... |
| 131 |
|
{ |
| 132 |
1 |
getTree().waitForDocumentSelected(path); |
| 133 |
1 |
return this; |
| 134 |
|
} |
| 135 |
|
} |