RangeSelectionComponent extends AnimatedComponent { public void setDragBarHeight(int dragBarHeight) { myDragBarHeight = dragBarHeight; } RangeSelectionComponent(@NotNull RangeSelectionModel model, @NotNull Range viewRange);  RangeSelectionComponent(@NotNull RangeSelectionModel model, @NotNull Range viewRange, boolean isPointSelectionReplaced); void addSelectionUpdatedListener(final Consumer<Range> listener); @NotNull Mode getMode(); boolean shouldShowSeekComponent(); void setDragBarHeight(int dragBarHeight); static final double CLICK_RANGE_RATIO; }
@Test public void canDragSelectionToPan() { RangeSelectionModel model = new RangeSelectionModel(new Range(40, 50)); RangeSelectionComponent component = new RangeSelectionComponent(model, new Range(0, 100)); component.setDragBarHeight(10); component.setSize(100, 100); FakeUi ui = new FakeUi(component); ui.mouse.press(45, 9); assertThat(model.getSelectionRange().getMin()).isWithin(DELTA).of(40); assertThat(model.getSelectionRange().getMax()).isWithin(DELTA).of(50); assertThat(component.getCursor()).isEqualTo(AdtUiCursors.GRABBING); ui.mouse.dragDelta(40, 0); assertThat(model.getSelectionRange().getMin()).isWithin(DELTA).of(80); assertThat(model.getSelectionRange().getMax()).isWithin(DELTA).of(90); ui.mouse.release(); assertThat(component.getCursor()).isEqualTo(AdtUiCursors.GRAB); }
@Test public void canMakeNewSelectionInSelection() { RangeSelectionModel model = new RangeSelectionModel(new Range(40, 50)); RangeSelectionComponent component = new RangeSelectionComponent(model, new Range(0, 100)); component.setDragBarHeight(20); component.setSize(100, 100); FakeUi ui = new FakeUi(component); ui.mouse.press(45, 21); assertThat(model.getSelectionRange().getMin()).isWithin(DELTA).of(45); assertThat(model.getSelectionRange().getMax()).isWithin(DELTA).of(45); assertThat(component.getCursor()).isEqualTo(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); ui.mouse.dragDelta(40, 0); assertThat(model.getSelectionRange().getMin()).isWithin(DELTA).of(45); assertThat(model.getSelectionRange().getMax()).isWithin(DELTA).of(85); ui.mouse.release(); assertThat(component.getCursor()).isEqualTo(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); }