@Test public void noAddNotificationWhenCollapsed() throws Exception { ExpandableGroup expandableGroup = new ExpandableGroup(parent); expandableGroup.registerGroupDataObserver(groupAdapter); expandableGroup.add(new DummyItem()); Mockito.verify(groupAdapter, Mockito.never()).onItemRangeInserted(expandableGroup, 1, 1); }
@Test public void testUnexpandedGroupCount() throws Exception { ExpandableGroup expandableGroup = new ExpandableGroup(parent); Section section = new Section(); int sectionSize = 5; for (int i = 0; i < sectionSize; i++) { section.add(new DummyItem()); } expandableGroup.add(section); Item lastItem = new DummyItem(); expandableGroup.add(lastItem); assertEquals(1, expandableGroup.getGroupCount()); }
@Test public void testGetPosition() throws Exception { ExpandableGroup expandableGroup = new ExpandableGroup(parent); Section section = new Section(); expandableGroup.add(section); Section notAddedSection = new Section(); assertEquals(1, expandableGroup.getPosition(section)); assertEquals(-1, expandableGroup.getPosition(notAddedSection)); }
@Test public void testGetGroup() throws Exception { ExpandableGroup expandableGroup = new ExpandableGroup(parent); Section section = new Section(); int sectionSize = 5; for (int i = 0; i < sectionSize; i++) { section.add(new DummyItem()); } expandableGroup.add(section); Item lastItem = new DummyItem(); expandableGroup.add(lastItem); expandableGroup.onToggleExpanded(); assertEquals(lastItem, expandableGroup.getGroup(2)); }
@Test public void noChildAddNotificationWhenCollapsed() { ExpandableGroup expandableGroup = new ExpandableGroup(parent); expandableGroup.registerGroupDataObserver(groupAdapter); Section section = new Section(); DummyItem item = new DummyItem(); expandableGroup.add(section); section.add(item); Mockito.verify(groupAdapter, Mockito.never()).onItemRangeInserted(expandableGroup, 1, 1); }
@Test public void addNotificationWhenExpanded() throws Exception { ExpandableGroup expandableGroup = new ExpandableGroup(parent); expandableGroup.onToggleExpanded(); expandableGroup.registerGroupDataObserver(groupAdapter); expandableGroup.add(new DummyItem()); Mockito.verify(groupAdapter).onItemRangeInserted(expandableGroup, 1, 1); }
@Test public void expandNotifies() throws Exception { ExpandableGroup expandableGroup = new ExpandableGroup(parent); Section section = new Section(); int sectionSize = 5; for (int i = 0; i < sectionSize; i++) { section.add(new DummyItem()); } expandableGroup.add(section); Item lastItem = new DummyItem(); expandableGroup.add(lastItem); expandableGroup.registerGroupDataObserver(groupAdapter); expandableGroup.onToggleExpanded(); Mockito.verify(groupAdapter).onItemRangeInserted(expandableGroup, 1, 6); }
@Test public void testExpandedGroupCountForAdd() throws Exception { ExpandableGroup expandableGroup = new ExpandableGroup(parent); DummyItem item = new DummyItem(); expandableGroup.add(item); expandableGroup.registerGroupDataObserver(groupAdapter); expandableGroup.onToggleExpanded(); assertEquals(2, expandableGroup.getGroupCount()); }
@Test public void testExpandedGroupCount() throws Exception { ExpandableGroup expandableGroup = new ExpandableGroup(parent); Section section = new Section(); int sectionSize = 5; for (int i = 0; i < sectionSize; i++) { section.add(new DummyItem()); } expandableGroup.add(section); Item lastItem = new DummyItem(); expandableGroup.add(lastItem); expandableGroup.registerGroupDataObserver(groupAdapter); expandableGroup.onToggleExpanded(); assertEquals(3, expandableGroup.getGroupCount()); }
@Test public void collapseNotifies() throws Exception { ExpandableGroup expandableGroup = new ExpandableGroup(parent); Section section = new Section(); int sectionSize = 5; for (int i = 0; i < sectionSize; i++) { section.add(new DummyItem()); } expandableGroup.add(section); Item lastItem = new DummyItem(); expandableGroup.add(lastItem); expandableGroup.onToggleExpanded(); expandableGroup.registerGroupDataObserver(groupAdapter); expandableGroup.onToggleExpanded(); Mockito.verify(groupAdapter).onItemRangeRemoved(expandableGroup, 1, 6); }
@Test public void childAddNotificationWhenExpanded() { ExpandableGroup expandableGroup = new ExpandableGroup(parent); expandableGroup.onToggleExpanded(); expandableGroup.registerGroupDataObserver(groupAdapter); Section section = new Section(); DummyItem item = new DummyItem(); expandableGroup.add(section); section.add(item); Mockito.verify(groupAdapter).onItemRangeInserted(expandableGroup, 1, 1); }
ExpandableGroup expandableGroup = new ExpandableGroup(expandableHeaderItem); for (int i = 0; i < 2; i++) { expandableGroup.add(new CardItem(rainbow200[1]));