mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-23 05:25:31 +03:00
Mock the companion object correctly
Signed-off-by: Tim Krüger <t@timkrueger.me>
This commit is contained in:
parent
c854d8c3ae
commit
707841ec29
1 changed files with 6 additions and 3 deletions
|
@ -36,6 +36,7 @@ import org.mockito.MockitoAnnotations;
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
import org.powermock.reflect.Whitebox;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
|
@ -66,9 +67,11 @@ public class DoNotDisturbUtilsTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.openMocks(this);
|
||||||
mockStatic(NextcloudTalkApplication.class);
|
mockStatic(NextcloudTalkApplication.Companion.class);
|
||||||
PowerMockito.when(NextcloudTalkApplication.getSharedApplication()).thenReturn(application);
|
NextcloudTalkApplication.Companion companionMock = PowerMockito.mock(NextcloudTalkApplication.Companion.class);
|
||||||
|
Whitebox.setInternalState(NextcloudTalkApplication.class,"Companion",companionMock);
|
||||||
|
PowerMockito.when(NextcloudTalkApplication.Companion.getSharedApplication()).thenReturn(application);
|
||||||
when(application.getApplicationContext()).thenReturn(context);
|
when(application.getApplicationContext()).thenReturn(context);
|
||||||
when(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager);
|
when(context.getSystemService(Context.NOTIFICATION_SERVICE)).thenReturn(notificationManager);
|
||||||
when(context.getSystemService(Context.AUDIO_SERVICE)).thenReturn(audioManager);
|
when(context.getSystemService(Context.AUDIO_SERVICE)).thenReturn(audioManager);
|
||||||
|
|
Loading…
Reference in a new issue