@Test public void testDisableNew() { // given Set<Node> newButtons = conceptMapView.lookupAll(".newBtnTop"); Node firstNewButton = newButtons.iterator().next(); // when moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY); assertTrue(firstNewButton.isDisabled()); // Delete Concept again Node concept = conceptMapView.lookup(".concept"); moveTo(concept).doubleClickOn(MouseButton.PRIMARY); assertFalse(firstNewButton.isDisabled()); moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY); concept = conceptMapView.lookup(".concept"); assertTrue(firstNewButton.isDisabled()); moveTo(concept).clickOn(MouseButton.PRIMARY); // right Keyboard Node rightToggle = concept.lookup("#fourUserEditable-topToggle"); moveTo(rightToggle).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY); // press a key moveTo(1200, 140).clickOn(MouseButton.PRIMARY); assertFalse(firstNewButton.isDisabled()); }
@Test public void testNewAndSelectKeyboard() { // given Set<Node> newButtons = conceptMapView.lookupAll(".newBtnTop"); Node firstNewButton = newButtons.iterator().next(); Node rightKeyboard = conceptMapView.lookup("#" + Position.RIGHT).lookup("#keyboard"); Node leftKeyboard = conceptMapView.lookup("#" + Position.LEFT).lookup("#keyboard"); ; Node topKeyboard = conceptMapView.lookup("#" + Position.TOP).lookup("#keyboard"); ; Node bottomKeyboard = conceptMapView.lookup("#" + Position.BOTTOM).lookup("#keyboard"); ; assertTrue(rightKeyboard.isDisabled()); assertTrue(leftKeyboard.isDisabled()); assertTrue(topKeyboard.isDisabled()); assertTrue(bottomKeyboard.isDisabled()); // when moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY); Node concept = conceptMapView.lookup(".concept"); moveTo(concept).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY); Node rightToggle = concept.lookup("#fourUserEditable-rightToggle"); sleep(500); moveTo(rightToggle).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY); // then assertFalse(rightKeyboard.isDisabled()); assertTrue(leftKeyboard.isDisabled()); assertTrue(topKeyboard.isDisabled()); assertTrue(bottomKeyboard.isDisabled()); }
@Test public void testNewActionAndNotTwice() { // given Set<Node> newButtons = conceptMapView.lookupAll(".newBtnTop"); Node firstNewButton = newButtons.iterator().next(); // when moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY); // then Set<Node> concepts = conceptMapView.lookupAll(".concept"); assertEquals(1, concepts.size()); Node conceptParent = concepts.iterator().next(); assertTrue(conceptParent.lookup("#caption").getStyleClass().contains("empty")); // when moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY); // then concepts = conceptMapView.lookupAll(".concept"); assertEquals(1, concepts.size()); }
@Test public void testLayoutWithConceptAdded() { int conceptCount = map.getConceptCount(); Concept c = new Concept( new CollaborativeString(map.getExperiment().getParticipants().get(0), FIRST_CONCEPT)); double x = 0.4; double y = 0.4; c.setPosition(x, y, 0); map.addConcept(c); // when super.interact( () -> { controller.setConceptMap(map); controller.layout(); }); // then Set<Node> concepts = conceptMapView.lookupAll(".concept"); assertEquals(conceptCount + 1, concepts.size()); assertEquals(conceptCount + 1, map.getConceptCount()); Node addedConcept = concepts.iterator().next(); double xScaled = addedConcept.getLayoutX() + addedConcept.getTranslateX(); double yScaled = addedConcept.getLayoutY() + addedConcept.getTranslateY(); assertEquals(x * scene.getWidth(), xScaled, 0.5); assertEquals(y * scene.getHeight(), yScaled, 0.5); Label caption = (Label) addedConcept.lookup("#caption"); assertEquals(FIRST_CONCEPT, caption.getText()); }