@Test
public void movingMouseChangesCursor() {

  RangeSelectionModel model = new RangeSelectionModel(new Range(10, 20));
  RangeSelectionComponent component = new RangeSelectionComponent(model, new Range(0, 100));
  component.setSize(100, 100);
  FakeUi ui = new FakeUi(component);
  // Moving to min handle should change cursor to east resize cursor.
  ui.mouse.moveTo(getMinHandleX(model), 0);
  assertThat(component.getCursor()).isEqualTo(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
  assertThat(component.getMode()).isEqualTo(RangeSelectionComponent.Mode.ADJUST_MIN);
  // Moving inside the range should change cursor to default cursor.
  ui.mouse.moveTo(15, 0);
  assertThat(component.getCursor()).isEqualTo(AdtUiCursors.GRABBING);
  assertThat(component.getMode()).isEqualTo(RangeSelectionComponent.Mode.MOVE);
  // Moving inside the range should change cursor to default cursor.
  ui.mouse.moveTo(15, 50);
  assertThat(component.getCursor()).isEqualTo(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
  assertThat(component.getMode()).isEqualTo(RangeSelectionComponent.Mode.CREATE);
  // Moving to max handle should change cursor to west resize cursor.
  ui.mouse.moveTo(getMaxHandleX(model), 50);
  assertThat(component.getCursor()).isEqualTo(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
  assertThat(component.getMode()).isEqualTo(RangeSelectionComponent.Mode.ADJUST_MAX);
  // Moving outside the range should change cursor to default.
  ui.mouse.moveTo(0, 0);
  assertThat(component.getCursor()).isEqualTo(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
  assertThat(component.getMode()).isEqualTo(RangeSelectionComponent.Mode.CREATE);
}