mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-08-23 02:17:20 +00:00
Mock ContextCompat.getSystemService() using PowerMockito.
This commit is contained in:
parent
52aafe6b8c
commit
fe3cbeb65b
@ -58,7 +58,7 @@ import static org.mockito.ArgumentMatchers.anyString;
|
|||||||
import static org.mockito.Matchers.eq;
|
import static org.mockito.Matchers.eq;
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({Base64.class, Log.class, PreferenceManager.class})
|
@PrepareForTest({Base64.class, Log.class, PreferenceManager.class, ContextCompat.class})
|
||||||
public class DeviceTest {
|
public class DeviceTest {
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
@ -113,7 +113,8 @@ public class DeviceTest {
|
|||||||
PowerMockito.when(PreferenceManager.getDefaultSharedPreferences(any())).thenReturn(defaultSettings);
|
PowerMockito.when(PreferenceManager.getDefaultSharedPreferences(any())).thenReturn(defaultSettings);
|
||||||
RsaHelper.initialiseRsaKeys(context);
|
RsaHelper.initialiseRsaKeys(context);
|
||||||
|
|
||||||
Mockito.when(ContextCompat.getSystemService(context, NotificationManager.class)).thenReturn(Mockito.mock(NotificationManager.class));
|
PowerMockito.mockStatic(ContextCompat.class);
|
||||||
|
PowerMockito.when(ContextCompat.getSystemService(context, NotificationManager.class)).thenReturn(Mockito.mock(NotificationManager.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user