コード例 #1
0
  @Test
  public void testConceptNewJump() {
    // given
    Set<Node> newButtons = conceptMapView.lookupAll(".newBtnTop");
    Node firstNewButton = newButtons.iterator().next();

    moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY);
    Node concept = conceptMapView.lookup(".concept");

    double expectedX = concept.getLayoutX() + concept.getTranslateX();
    double expectedY = concept.getLayoutY() + concept.getTranslateY();

    // when

    super.interact(
        () -> {
          stage.setFullScreen(false);
          stage.setWidth(stage.getWidth() - 40);
          stage.setHeight(stage.getHeight() - 40);
        });

    // then

    double actualX = concept.getLayoutX() + concept.getTranslateX();
    double actualY = concept.getLayoutY() + concept.getTranslateY();

    assertEquals(expectedX, actualX, 50);
    assertEquals(expectedY, actualY, 50);
  }
コード例 #2
0
  @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());
  }