package com.github.javiersantos.piracychecker;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.test.InstrumentationRegistry;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.github.javiersantos.piracychecker.demo.MainActivity;
import com.github.javiersantos.piracychecker.enums.PiracyCheckerCallback;
import com.github.javiersantos.piracychecker.enums.PiracyCheckerError;
import com.github.javiersantos.piracychecker.enums.PirateApp;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertTrue;

/**
 * 2. Specific test cases for unauthorized apps. Requires to install an unauthorized app before running this tests.
 */
@RunWith(AndroidJUnit4.class)
public class UnauthorizedAppTest {

    @Rule
    public final ActivityTestRule<MainActivity> uiThreadTestRule = new ActivityTestRule<>(MainActivity.class);

    @Test
    public void verifyUnauthorizedApps_DONTALLOW() throws Throwable {
        final CountDownLatch signal = new CountDownLatch(1);
        uiThreadTestRule.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                new PiracyChecker(InstrumentationRegistry.getTargetContext())
                        .enableUnauthorizedAppsCheck()
                        .blockIfUnauthorizedAppUninstalled("piracychecker_preferences", "app_unauthorized")
                        .callback(new PiracyCheckerCallback() {
                            @Override
                            public void allow() {
                                assertTrue("PiracyChecker FAILED: There is an 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);
    }

}

@@ -1070,24 +1070,1519 @@
 ty.class);%0A%0A
+    @Test%0A    public void verifyUnauthorizedCustomApp_DONTALLOW() throws Throwable %7B%0A        final CountDownLatch signal = new CountDownLatch(1);%0A        uiThreadTestRule.runOnUiThread(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                new PiracyChecker(InstrumentationRegistry.getTargetContext())%0A                        .addAppToCheck(new PirateApp(%22Demo%22, uiThreadTestRule.getActivity().getPackageName()))%0A                        .callback(new PiracyCheckerCallback() %7B%0A                            @Override%0A                            public void allow() %7B%0A                                assertTrue(%22PiracyChecker FAILED: There is a custom unauthorized app installed.%22, false);%0A                                signal.countDown();%0A                            %7D%0A%0A                            @Override%0A                            public void dontAllow(@NonNull PiracyCheckerError error, @Nullable PirateApp app) %7B%0A                                if (error == PiracyCheckerError.PIRATE_APP_INSTALLED)%0A                                    assertTrue(%22PiracyChecker OK%22, true);%0A                                else%0A                                    assertTrue(%22PiracyChecker FAILED : PiracyCheckError is not %22 + error.toString(), false);%0A                                signal.countDown();%0A                            %7D%0A                        %7D)%0A                        .start();%0A            %7D%0A        %7D);%0A%0A        signal.await(30, TimeUnit.SECONDS);%0A    %7D%0A%0A
     @Test%0A  

Add test to verify the new method