-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into issue-1734-save-button-not-supporting-mls
- Loading branch information
Showing
4 changed files
with
74 additions
and
11 deletions.
There are no files selected for viewing
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
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
54 changes: 54 additions & 0 deletions
54
...chw-core/src/test/java/org/smartregister/chw/core/activity/ReportSummaryActivityTest.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,54 @@ | ||
package org.smartregister.chw.core.activity; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
import org.mockito.junit.MockitoJUnit; | ||
import org.mockito.junit.MockitoRule; | ||
import org.robolectric.Robolectric; | ||
import org.robolectric.android.controller.ActivityController; | ||
import org.smartregister.Context; | ||
import org.smartregister.CoreLibrary; | ||
import org.smartregister.chw.core.BaseUnitTest; | ||
|
||
public class ReportSummaryActivityTest extends BaseUnitTest { | ||
@Rule | ||
public MockitoRule rule = MockitoJUnit.rule(); | ||
|
||
private ReportSummaryActivity activity; | ||
private ActivityController<ReportSummaryActivity> controller; | ||
|
||
@Before | ||
public void setUp() { | ||
MockitoAnnotations.initMocks(this); | ||
|
||
Context context = Context.getInstance(); | ||
CoreLibrary.init(context); | ||
|
||
//Auto login by default | ||
context.session().start(context.session().lengthInMilliseconds()); | ||
controller = Robolectric.buildActivity(ReportSummaryActivity.class).create().start().resume(); | ||
activity = controller.get(); | ||
} | ||
|
||
@Test | ||
public void testOnBackPressed() { | ||
ReportSummaryActivity spyActivity = Mockito.spy(activity); | ||
spyActivity.onBackPressed(); | ||
Mockito.verify(spyActivity).onBackPressed(); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
try { | ||
activity.finish(); | ||
controller.pause().stop().destroy(); //destroy controller if we can | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
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