HasData<String> listView = new MockHasData<String>();
MockView<String> view = new MockView<String>();
HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);
// Set the range the first time.
presenter.setVisibleRange(new Range(0, 100));
assertEquals(new Range(0, 100), presenter.getVisibleRange());
assertEquals(0, presenter.getVisibleItemCount());
presenter.flush();
view.assertReplaceChildrenNotCalled();
view.assertLoadingState(LoadingState.LOADING);
// Set the range to the same value.
presenter.setVisibleRange(new Range(0, 100));
assertEquals(new Range(0, 100), presenter.getVisibleRange());
assertEquals(0, presenter.getVisibleItemCount());
presenter.flush();
view.assertReplaceChildrenNotCalled();
view.assertLoadingState(LoadingState.LOADING);
// Set the start to a negative value.
try {
presenter.setVisibleRange(new Range(-1, 100));
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected.
}
// Set the length to a negative value.
try {
presenter.setVisibleRange(new Range(0, -100));
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
// Expected.
}
}