|
|
@@ -14,6 +14,7 @@ import kr.co.zumo.app.lifeplus.model.SuperModel;
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
+import static org.mockito.AdditionalMatchers.not;
|
|
|
import static org.mockito.ArgumentMatchers.argThat;
|
|
|
import static org.mockito.ArgumentMatchers.eq;
|
|
|
import static org.powermock.api.mockito.PowerMockito.doReturn;
|
|
|
@@ -49,6 +50,19 @@ public class ActivityStarterTest {
|
|
|
starter = spy(new ActivityStarter(context));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void ready() throws Exception {
|
|
|
+ // 네트워크 에러
|
|
|
+ doReturn(true).when(lifeplusPreferences).isPermissionInfoDone();
|
|
|
+ doReturn(true).when(lifeplusPreferences).isTutorialDone();
|
|
|
+ SuperModel.getInstance().setUserId("dummy");
|
|
|
+
|
|
|
+ starter.launch(false);
|
|
|
+
|
|
|
+ // 네트워크 에러 액티비티로 이동해야 함 not 으로 powerMock 이 정상 작동하는지 확인
|
|
|
+ verifyPrivate(starter).invoke("gotoScreen", not(argThat(new ClassMatcher<>(MainActivity.class))));
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void launch() throws Exception {
|
|
|
// 네트워크 에러
|
|
|
@@ -59,7 +73,7 @@ public class ActivityStarterTest {
|
|
|
starter.launch(false);
|
|
|
|
|
|
// 네트워크 에러 액티비티로 이동;
|
|
|
- verifyPrivate(starter).invoke("gotoScreen", argThat(new ClassOrSubclassMatcher<>(NetworkErrorActivity.class)));
|
|
|
+ verifyPrivate(starter).invoke("gotoScreen", argThat(new ClassMatcher<>(NetworkErrorActivity.class)));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -88,7 +102,7 @@ public class ActivityStarterTest {
|
|
|
|
|
|
starter.launch(true);
|
|
|
|
|
|
- verifyPrivate(starter).invoke("gotoScreen", argThat(new ClassOrSubclassMatcher<>(PermissionInfoActivity.class)));
|
|
|
+ verifyPrivate(starter).invoke("gotoScreen", argThat(new ClassMatcher<>(PermissionInfoActivity.class)));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -100,7 +114,7 @@ public class ActivityStarterTest {
|
|
|
|
|
|
starter.launch(true);
|
|
|
|
|
|
- verifyPrivate(starter).invoke("gotoScreen", argThat(new ClassOrSubclassMatcher<>(OnBoardingActivity.class)));
|
|
|
+ verifyPrivate(starter).invoke("gotoScreen", argThat(new ClassMatcher<>(OnBoardingActivity.class)));
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -115,14 +129,14 @@ public class ActivityStarterTest {
|
|
|
// 토큰, 아이디 가 없기 때문에 비활성 멤버
|
|
|
assertFalse(SuperModel.getInstance().isActiveMember());
|
|
|
|
|
|
- verifyPrivate(starter).invoke("gotoScreen", argThat(new ClassOrSubclassMatcher<>(MainActivity.class)));
|
|
|
+ verifyPrivate(starter).invoke("gotoScreen", argThat(new ClassMatcher<>(MainActivity.class)));
|
|
|
}
|
|
|
|
|
|
- public class ClassOrSubclassMatcher<T> implements ArgumentMatcher<Class<T>> {
|
|
|
+ public class ClassMatcher<T> implements ArgumentMatcher<Class<T>> {
|
|
|
|
|
|
private final Class<T> targetClass;
|
|
|
|
|
|
- public ClassOrSubclassMatcher(Class<T> targetClass) {
|
|
|
+ ClassMatcher(Class<T> targetClass) {
|
|
|
this.targetClass = targetClass;
|
|
|
}
|
|
|
|