mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
add getHeaderPositionForItem unit test
Signed-off-by: alex <alex.plutta@googlemail.com> Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
0ac5a8bcec
commit
cdd5d38d3d
1 changed files with 62 additions and 0 deletions
|
@ -52,4 +52,66 @@ public final class ActivityListAdapterTest {
|
|||
activityListAdapter.values.add(activity);
|
||||
Assert.assertFalse(activityListAdapter.isHeader(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeaderPositionForItem__AdapterIsEmpty_ReturnZero(){
|
||||
Mockito.when(activityListAdapter.isHeader(0)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getItemViewType(0)).thenCallRealMethod();
|
||||
|
||||
Assert.assertEquals(0,activityListAdapter.getHeaderPositionForItem(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeaderPositionForItem__ItemIsHeader_ReturnCurrentItem() {
|
||||
Object header = "Hello";
|
||||
Object activity = Mockito.mock(Activity.class);
|
||||
|
||||
Mockito.when(activityListAdapter.isHeader(0)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getItemViewType(0)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.isHeader(1)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getItemViewType(1)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.isHeader(2)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getItemViewType(2)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getHeaderPositionForItem(2)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.isHeader(3)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getItemViewType(3)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getHeaderPositionForItem(3)).thenCallRealMethod();
|
||||
|
||||
|
||||
activityListAdapter.values.add(header);
|
||||
activityListAdapter.values.add(activity);
|
||||
activityListAdapter.values.add(header);
|
||||
activityListAdapter.values.add(activity);
|
||||
|
||||
|
||||
Assert.assertEquals(2, activityListAdapter.getHeaderPositionForItem(2));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHeaderPositionForItem__ItemIsActivity_ReturnNextHeader() {
|
||||
Object header = "Hello";
|
||||
Object activity = Mockito.mock(Activity.class);
|
||||
|
||||
Mockito.when(activityListAdapter.isHeader(0)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getItemViewType(0)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getHeaderPositionForItem(0)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.isHeader(1)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getItemViewType(1)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getHeaderPositionForItem(1)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.isHeader(2)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getItemViewType(2)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getHeaderPositionForItem(2)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.isHeader(3)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getItemViewType(3)).thenCallRealMethod();
|
||||
Mockito.when(activityListAdapter.getHeaderPositionForItem(3)).thenCallRealMethod();
|
||||
|
||||
activityListAdapter.values.add(header);
|
||||
activityListAdapter.values.add(activity);
|
||||
activityListAdapter.values.add(header);
|
||||
activityListAdapter.values.add(activity);
|
||||
|
||||
Assert.assertEquals(2, activityListAdapter.getHeaderPositionForItem(2));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue