-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: alex <alex.plutta@googlemail.com> Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
- Loading branch information
1 parent
b61f9e0
commit 4ea9667
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/test/java/com/owncloud/android/ui/adapter/ActivityListAdapterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.owncloud.android.ui.adapter; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
import org.mockito.internal.util.reflection.FieldSetter; | ||
|
||
import java.util.ArrayList; | ||
|
||
public final class ActivityListAdapterTest { | ||
|
||
|
||
@Mock | ||
private ActivityListAdapter activityListAdapter; | ||
|
||
@Before | ||
public void setUp() throws NoSuchFieldException { | ||
MockitoAnnotations.initMocks(this); | ||
MockitoAnnotations.initMocks(activityListAdapter); | ||
FieldSetter.setField(activityListAdapter, activityListAdapter.getClass().getDeclaredField("values"), new ArrayList<>()); | ||
} | ||
|
||
@Test | ||
public void isHeader__ObjectIsHeader_ReturnTrue() { | ||
Object header = "Hello"; | ||
Object activity = Mockito.mock(com.owncloud.android.lib.resources.activities.model.Activity.class); | ||
|
||
Mockito.when(activityListAdapter.isHeader(0)).thenCallRealMethod(); | ||
Mockito.when(activityListAdapter.getItemViewType(0)).thenCallRealMethod(); | ||
|
||
activityListAdapter.values.add(header); | ||
activityListAdapter.values.add(activity); | ||
|
||
final boolean result = activityListAdapter.isHeader(0); | ||
Assert.assertTrue(result); | ||
} | ||
|
||
@Test | ||
public void isHeader__ObjectIsActivity_ReturnFalse() { | ||
Object header = "Hello"; | ||
Object activity = Mockito.mock(com.owncloud.android.lib.resources.activities.model.Activity.class); | ||
|
||
Mockito.when(activityListAdapter.isHeader(1)).thenCallRealMethod(); | ||
Mockito.when(activityListAdapter.getItemViewType(1)).thenCallRealMethod(); | ||
|
||
activityListAdapter.values.add(header); | ||
activityListAdapter.values.add(activity); | ||
Assert.assertFalse(activityListAdapter.isHeader(1)); | ||
} | ||
} |