Revize 051dcb51
Přidáno uživatelem Tomáš Šimandl před více než 6 roky(ů)
sources/src/main/webapp/uploadFiles.jsp | ||
---|---|---|
47 | 47 |
<label for="raw"><input type="radio" name="jsonFileFormat" value="raw" id="raw"> Raw JSON</label><br> |
48 | 48 |
</div> |
49 | 49 |
|
50 |
<button type="submit">Start visualization</button> |
|
50 |
<button id="btnLoad" type="submit">Start visualization</button>
|
|
51 | 51 |
</form> |
52 | 52 |
</div> |
53 | 53 |
|
sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/ArchetypeIconConfigTest.java | ||
---|---|---|
21 | 21 |
} |
22 | 22 |
|
23 | 23 |
@Test |
24 |
public void SpecifiedIcon1(){ |
|
25 |
locateTestingArchetypeIcon("vertex1"); |
|
24 |
public void SpecifiedValueDefinition(){ |
|
25 |
WebElement iconDef = browser.findElement(By.id("vertexArchetypeIcon-SpecifiedIcon")); |
|
26 |
|
|
27 |
System.out.println("Trying to locate an element with class 'testingArchetypeIcon'"); |
|
28 |
iconDef.findElement(By.className("testingArchetypeIcon")); |
|
29 |
System.out.println("Element found."); |
|
26 | 30 |
} |
27 | 31 |
|
28 | 32 |
@Test |
29 |
public void SpecifiedIcon2(){ |
|
30 |
Assertions.assertThrows(NoSuchElementException.class, |
|
31 |
() -> checkUnspecifiedArchetypeSymbol("vertex1", "S")); |
|
32 |
|
|
33 |
System.out.println("Default value not found on the vertex with specified archetype icon."); |
|
33 |
public void UnspecifiedValueDefinition(){ |
|
34 |
emptyIconDefinition("UnspecifiedIcon"); |
|
34 | 35 |
} |
35 | 36 |
|
36 | 37 |
@Test |
37 |
public void UnspecifiedIcon1(){ |
|
38 |
Assertions.assertThrows(NoSuchElementException.class, |
|
39 |
() -> locateTestingArchetypeIcon("vertex2")); |
|
40 |
|
|
41 |
System.out.println("Element not found."); |
|
38 |
public void SmileyValueDefinition(){ |
|
39 |
emptyIconDefinition("☺Smiley"); |
|
42 | 40 |
} |
43 | 41 |
|
44 | 42 |
@Test |
45 |
public void UnspecifiedIcon2(){ |
|
46 |
Assertions.assertThrows(NoSuchElementException.class, |
|
47 |
() -> locateTestingArchetypeIcon("vertex3")); |
|
48 |
|
|
49 |
System.out.println("Element not found."); |
|
43 |
public void SpecifiedIcon(){ |
|
44 |
locateTestingArchetypeIcon("1","#vertexArchetypeIcon-SpecifiedIcon"); |
|
50 | 45 |
} |
51 | 46 |
|
52 | 47 |
@Test |
53 |
public void UnspecifiedIcon3(){
|
|
54 |
checkUnspecifiedArchetypeSymbol("vertex2", "U");
|
|
48 |
public void UnspecifiedIcon(){ |
|
49 |
locateTestingArchetypeIcon("2","#vertexArchetypeIcon-UnspecifiedIcon");
|
|
55 | 50 |
} |
56 | 51 |
|
57 | 52 |
@Test |
58 |
public void UnspecifiedIcon4(){
|
|
59 |
checkUnspecifiedArchetypeSymbol("vertex3", "☺");
|
|
53 |
public void SmileyIcon(){
|
|
54 |
locateTestingArchetypeIcon("3","#vertexArchetypeIcon-☺Smiley");
|
|
60 | 55 |
} |
61 | 56 |
|
62 | 57 |
/** |
63 | 58 |
* Utility method for checking of the presence of the specified icon element |
64 | 59 |
* @param elementId Id of the element in which the search is done |
60 |
* @param expectedHref expected href to icon in founded element |
|
65 | 61 |
*/ |
66 |
private void locateTestingArchetypeIcon(String elementId) { |
|
67 |
WebElement icon = browser.findElement(By.id(elementId)) |
|
68 |
.findElement(By.className("archetype")); |
|
62 |
private void locateTestingArchetypeIcon(String elementId, String expectedHref) { |
|
63 |
WebElement icon = browser.findElement(By.cssSelector("[data-id='vertices']")) |
|
64 |
.findElement(By.cssSelector("[data-id='" + elementId + "']")) |
|
65 |
.findElement(By.className("archetype-icon")); |
|
69 | 66 |
|
70 |
System.out.println("Trying to locate an element with class 'testingArchetypeIcon'"); |
|
71 |
icon.findElement(By.className("testingArchetypeIcon")); |
|
72 |
System.out.println("Element found."); |
|
67 |
Assertions.assertEquals(expectedHref, icon.getAttribute("href")); |
|
73 | 68 |
} |
74 | 69 |
|
75 |
/** |
|
76 |
* Utility method for checking whether specified element contains the default archetype icon |
|
77 |
* @param elementId Id of the element in which the test is done |
|
78 |
* @param expectedText Expected text present in the icon |
|
79 |
*/ |
|
80 |
private void checkUnspecifiedArchetypeSymbol(String elementId, String expectedText) { |
|
81 |
WebElement icon = browser.findElement(By.id(elementId)) |
|
82 |
.findElement(By.className("archetype")); |
|
70 |
private void emptyIconDefinition(String iconName){ |
|
71 |
WebElement iconDef = browser.findElement(By.id("vertexArchetypeIcon-" + iconName)) |
|
72 |
.findElement(By.tagName("text")); |
|
83 | 73 |
|
84 |
System.out.println("Checking text of unspecified archetype icon"); |
|
85 |
Assertions.assertEquals(expectedText, icon.findElement(By.tagName("text")).getText(), |
|
86 |
"Text of unspecified icon is different from the expected."); |
|
87 |
System.out.println("Default text found."); |
|
74 |
System.out.println("Testing if icon contains specific text"); |
|
75 |
Assertions.assertEquals(iconName.substring(0,1), iconDef.getText()); |
|
88 | 76 |
} |
89 | 77 |
|
90 |
|
|
91 | 78 |
@AfterAll |
92 | 79 |
public static void finishTest() { |
93 | 80 |
SeleniumUtil.clear(); |
sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/AssociatedArchetypeTest.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
@Test |
26 | 26 |
public void visibilityOfAllIcons() { |
27 |
checkVisibilityOfIcons("vertex1", Arrays.asList("2", "4"));
|
|
27 |
checkVisibilityOfIcons("1", Arrays.asList("2", "4"), Arrays.asList("2", "4"));
|
|
28 | 28 |
|
29 |
checkVisibilityOfIcons("vertex2",Arrays.asList("1"));
|
|
29 |
checkVisibilityOfIcons("2", Arrays.asList("1"), Arrays.asList("1"));
|
|
30 | 30 |
|
31 |
checkVisibilityOfIcons("vertex3",Arrays.asList("1"));
|
|
31 |
checkVisibilityOfIcons("3", Arrays.asList("1"),Arrays.asList("1"));
|
|
32 | 32 |
|
33 |
checkVisibilityOfIcons("vertex4",Arrays.asList("1", "3"));
|
|
33 |
checkVisibilityOfIcons("4", Arrays.asList("1", "3"), Arrays.asList("1", "3"));
|
|
34 | 34 |
|
35 |
checkVisibilityOfIcons("vertex5",Arrays.asList("4"));
|
|
35 |
checkVisibilityOfIcons("5", Arrays.asList("4"), Arrays.asList("4"));
|
|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
@Test |
39 | 39 |
public void vertexHighlighting() { |
40 | 40 |
//associated vertices to V1 |
41 |
checkHighlightedVertices("archetype1_1", Arrays.asList("vertex2", "vertex3"));
|
|
42 |
checkHighlightedVertices("archetype1_3", Arrays.asList("vertex4"));
|
|
41 |
checkHighlightedVertices("1", "2", Arrays.asList("2", "3"));
|
|
42 |
checkHighlightedVertices("1", "4", Arrays.asList("4"));
|
|
43 | 43 |
|
44 | 44 |
//associated vertices to V2 |
45 |
checkHighlightedVertices("archetype2_0", Arrays.asList("vertex1"));
|
|
45 |
checkHighlightedVertices("2", "1", Arrays.asList("1"));
|
|
46 | 46 |
|
47 | 47 |
//associated vertices to V3 |
48 |
checkHighlightedVertices("archetype3_0", Arrays.asList("vertex1"));
|
|
48 |
checkHighlightedVertices("3", "1", Arrays.asList("1"));
|
|
49 | 49 |
|
50 | 50 |
//associated vertices to V4 |
51 |
checkHighlightedVertices("archetype4_0", Arrays.asList("vertex1"));
|
|
52 |
checkHighlightedVertices("archetype4_2", Arrays.asList("vertex5"));
|
|
51 |
checkHighlightedVertices("4", "1", Arrays.asList("1"));
|
|
52 |
checkHighlightedVertices("4", "3", Arrays.asList("5"));
|
|
53 | 53 |
|
54 | 54 |
//associated vertices to V5 |
55 |
checkHighlightedVertices("archetype5_3", Arrays.asList("vertex4"));
|
|
55 |
checkHighlightedVertices("5", "4", Arrays.asList("4"));
|
|
56 | 56 |
} |
57 | 57 |
|
58 | 58 |
/** |
59 | 59 |
* Check if all the expected associated archetype icons are present |
60 | 60 |
* @param elementId Id of the vertex in the DOM |
61 |
* @param expectedArchetypes names of expected archetypes |
|
61 | 62 |
* @param expectedArchetypeIconTexts Texts of all the associated archetype icons that are expected to occur |
62 | 63 |
*/ |
63 |
private void checkVisibilityOfIcons(String elementId, List<String> expectedArchetypeIconTexts) { |
|
64 |
private void checkVisibilityOfIcons(String elementId, List<String> expectedArchetypes, List<String> expectedArchetypeIconTexts) {
|
|
64 | 65 |
System.out.println("Checking element " + elementId); |
65 |
WebElement vertex = browser.findElement(By.id(elementId)); |
|
66 |
WebElement vertex = browser.findElement(By.cssSelector("[data-id='vertices']")) |
|
67 |
.findElement(By.cssSelector("[data-id='" + elementId + "']")); |
|
66 | 68 |
|
67 |
List<WebElement> associatedArchetypeIcons = vertex.findElements(By.className("associatedArchetype")); |
|
69 |
List<WebElement> associatedArchetypeIcons = vertex.findElement(By.tagName("g")). |
|
70 |
findElements(By.className("archetype-icon")); |
|
68 | 71 |
|
69 | 72 |
System.out.println("Associated archetypes: \n"); |
70 | 73 |
Assertions.assertEquals(associatedArchetypeIcons.size(), expectedArchetypeIconTexts.size()); |
71 | 74 |
|
72 | 75 |
for (int i = 0; i < expectedArchetypeIconTexts.size(); i++) { |
73 | 76 |
WebElement icon = associatedArchetypeIcons.get(i); |
74 |
System.out.println("Icon id: " + icon.getAttribute("id")); |
|
75 | 77 |
|
76 |
String archetypeIconText = icon.findElement(By.tagName("text")).getText(); |
|
77 |
System.out.println("Icon text: " + archetypeIconText +"\n"); |
|
78 |
String iconHref = icon.getAttribute("href"); |
|
79 |
System.out.println("Icon href: " + iconHref+"\n"); |
|
80 |
Assertions.assertEquals("#vertexArchetypeIcon-" + expectedArchetypes.get(i), iconHref); |
|
78 | 81 |
|
79 |
Assertions.assertEquals(expectedArchetypeIconTexts.get(i), archetypeIconText); |
|
82 |
|
|
83 |
WebElement iconDef = browser.findElement(By.id("vertexArchetypeIcon-" + expectedArchetypes.get(i))); |
|
84 |
|
|
85 |
System.out.println("Testing if icon contains specific text"); |
|
86 |
Assertions.assertEquals(expectedArchetypeIconTexts.get(i), iconDef.getText()); |
|
80 | 87 |
} |
81 | 88 |
} |
82 | 89 |
|
83 | 90 |
/** |
84 | 91 |
* Check if all the expected vertices are highlighted when clicking on the associated archetype icon |
85 |
* @param associatedArchetypeIconId Id of the associated archetype icon in the DOM |
|
92 |
* @param vertexId Id of the vertex in viewport |
|
93 |
* @param archetypeName name of associated archetype |
|
86 | 94 |
* @param expectedHighlightedVertexIds Ids of all the vertices that are expected to be highlighted |
87 | 95 |
*/ |
88 |
private void checkHighlightedVertices(String associatedArchetypeIconId, List<String> expectedHighlightedVertexIds) { |
|
89 |
System.out.println("\nChecking associated vertices for archetype icon with id: " + associatedArchetypeIconId); |
|
90 |
WebElement associatedArchetypeIcon = browser.findElement(By.id(associatedArchetypeIconId)); |
|
96 |
private void checkHighlightedVertices(String vertexId, String archetypeName, List<String> expectedHighlightedVertexIds) { |
|
97 |
System.out.println("\nChecking associated vertices of vertex: " + vertexId + " for archetype icon with : " + archetypeName); |
|
98 |
|
|
99 |
WebElement vertex = browser.findElement(By.cssSelector("[data-id='vertices']")) |
|
100 |
.findElement(By.cssSelector("[data-id='" + vertexId + "']")); |
|
101 |
|
|
102 |
List<WebElement> associatedArchetypeIcons = vertex.findElement(By.tagName("g")). |
|
103 |
findElements(By.className("archetype-icon")); |
|
104 |
|
|
105 |
WebElement associatedArchetypeIcon = null; |
|
106 |
for (WebElement icon : associatedArchetypeIcons) { |
|
107 |
if(icon.getAttribute("href").endsWith(archetypeName)) { |
|
108 |
associatedArchetypeIcon = icon; |
|
109 |
break; |
|
110 |
} |
|
111 |
} |
|
112 |
Assertions.assertNotNull(associatedArchetypeIcon); |
|
91 | 113 |
SeleniumUtil.svgClick(associatedArchetypeIcon); |
92 | 114 |
|
93 |
List<WebElement> highlightedVertices = browser.findElements(By.className("colorHighlightArchetype"));
|
|
115 |
List<WebElement> highlightedVertices = browser.findElements(By.className("node--highlighted-archetype"));
|
|
94 | 116 |
|
95 | 117 |
System.out.println("Number of highlighted vertices: " + highlightedVertices.size()); |
96 | 118 |
Assertions.assertEquals(expectedHighlightedVertexIds.size(), highlightedVertices.size()); |
97 | 119 |
|
98 | 120 |
for(int i = 0; i < highlightedVertices.size(); i++) { |
99 |
WebElement vertex = highlightedVertices.get(i); |
|
100 |
String id = vertex.getAttribute("id"); |
|
101 |
|
|
121 |
String id = highlightedVertices.get(i).getAttribute("data-id"); |
|
102 | 122 |
System.out.println(id); |
103 | 123 |
|
104 | 124 |
Assertions.assertEquals(expectedHighlightedVertexIds.get(i), id); |
sources/src/test/java/cz/zcu/kiv/imiger/tests/frontend/SeleniumUtil.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
private static final String GECKO_PATH = TEST_DIRECTORY + "\\geckodriver.exe"; |
27 | 27 |
|
28 |
private static final String URL = "http://localhost:8080"; |
|
28 |
private static final String URL = "http://localhost:8080/imiger/";
|
|
29 | 29 |
|
30 | 30 |
private static final int DATA_LOAD_TIMEOUT = 20; |
31 | 31 |
|
... | ... | |
39 | 39 |
} |
40 | 40 |
|
41 | 41 |
public static void loadGraphData(String filename) { |
42 |
WebElement fileInput = browser.findElement(By.id("hidden_input"));
|
|
42 |
WebElement fileInput = browser.findElement(By.id("file"));
|
|
43 | 43 |
fileInput.sendKeys(TEST_DIRECTORY + "\\data\\" + filename ); |
44 |
browser.findElement(By.className("load")).click();
|
|
44 |
browser.findElement(By.id("btnLoad")).click();
|
|
45 | 45 |
|
46 | 46 |
WebDriverWait wait = new WebDriverWait(browser, DATA_LOAD_TIMEOUT); |
47 |
wait.until(ExpectedConditions.presenceOfElementLocated(By.className("vertices")));
|
|
47 |
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("viewport")));
|
|
48 | 48 |
|
49 | 49 |
try { |
50 | 50 |
Thread.sleep(1000); |
Také k dispozici: Unified diff
Repaired two selenium tests