Skip to content

Commit

Permalink
Add tests for ObservableGridView.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksoichiro committed Dec 1, 2015
1 parent f680cdf commit 3d4944d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Expand Up @@ -98,6 +98,20 @@ public void run() {
activity.headerView.setClickable(true);

scrollable.addHeaderView(activity.headerView);

assertEquals(100/* items */ + 2/* header */ + 2/* footer */, hvgAdapter.getCount());
assertEquals(1, hvgAdapter.getHeadersCount());
assertEquals(2, hvgAdapter.getNumColumns());
// If the header is added by addHeader(View),
// HeaderViewGridAdapter doesn't contain any associated data.
// headerData does NOT mean the view.
// If we want to get the view, we should use getView().
assertNull(hvgAdapter.getItem(0));
assertNull(hvgAdapter.getItem(1));

assertEquals(1, hvgAdapter.getFootersCount());
assertNull(hvgAdapter.getItem(100/* items */ + 2/* header */ + 2/* footer */ - 1 - 1));
assertNull(hvgAdapter.getItem(100/* items */ + 2/* header */ + 2/* footer */ - 1));
}
});
// Scroll to bottom and try removing re-adding the footer view.
Expand Down
Expand Up @@ -652,6 +652,10 @@ public HeaderViewGridAdapter(ArrayList<FixedViewInfo> headerViewInfos, ArrayList
&& areAllListInfosSelectable(mFooterViewInfos);
}

public int getNumColumns() {
return mNumColumns;
}

public void setNumColumns(int numColumns) {
if (numColumns < 1) {
return;
Expand Down

0 comments on commit 3d4944d

Please sign in to comment.