Skip to content

Commit

Permalink
Add test to verify the new method
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersantos committed Feb 25, 2018
1 parent ebbd5d2 commit 2ebe2fb
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,37 @@ public class UnauthorizedAppTest {
@Rule
public final ActivityTestRule<MainActivity> uiThreadTestRule = new ActivityTestRule<>(MainActivity.class);

@Test
public void verifyUnauthorizedCustomApp_DONTALLOW() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);
uiThreadTestRule.runOnUiThread(new Runnable() {
@Override
public void run() {
new PiracyChecker(InstrumentationRegistry.getTargetContext())
.addAppToCheck(new PirateApp("Demo", uiThreadTestRule.getActivity().getPackageName()))
.callback(new PiracyCheckerCallback() {
@Override
public void allow() {
assertTrue("PiracyChecker FAILED: There is a custom unauthorized app installed.", false);
signal.countDown();
}

@Override
public void dontAllow(@NonNull PiracyCheckerError error, @Nullable PirateApp app) {
if (error == PiracyCheckerError.PIRATE_APP_INSTALLED)
assertTrue("PiracyChecker OK", true);
else
assertTrue("PiracyChecker FAILED : PiracyCheckError is not " + error.toString(), false);
signal.countDown();
}
})
.start();
}
});

signal.await(30, TimeUnit.SECONDS);
}

@Test
public void verifyUnauthorizedApps_DONTALLOW() throws Throwable {
final CountDownLatch signal = new CountDownLatch(1);
Expand Down

0 comments on commit 2ebe2fb

Please sign in to comment.