HasData<String> listView = new MockHasData<String>();
MockView<String> view = new MockView<String>();
HasDataPresenter<String> presenter = new HasDataPresenter<String>(listView, view, 10, null);
// Initialize some data.
presenter.setVisibleRange(new Range(10, 30));
assertEquals(new Range(10, 30), presenter.getVisibleRange());
presenter.setRowData(10, createData(0, 10));
assertEquals(10, presenter.getVisibleItemCount());
assertEquals("test 0", presenter.getVisibleItem(0));
presenter.flush();
view.assertReplaceAllChildrenCalled(10);
view.assertLoadingState(LoadingState.PARTIALLY_LOADED);
// Decrease the start index.
presenter.setVisibleRange(new Range(8, 30));
assertEquals(new Range(8, 30), presenter.getVisibleRange());
assertEquals(12, presenter.getVisibleItemCount());
assertEquals(null, presenter.getVisibleItem(0));
assertEquals(null, presenter.getVisibleItem(1));
assertEquals("test 0", presenter.getVisibleItem(2));
presenter.flush();