package org.commcare.android;

import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.internal.bytecode.InstrumentationConfiguration;
import org.robolectric.manifest.AndroidManifest;
import org.robolectric.res.Fs;

/**
 * Register sqlcipher SQLiteDatabase to be shadowed globally.
 *
 * @author Phillip Mates (pmates@dimagi.com).
 */
public class CommCareTestRunner extends RobolectricTestRunner {
    public CommCareTestRunner(Class<?> klass) throws InitializationError {
        super(klass);
    }

    @Override
    public InstrumentationConfiguration createClassLoaderConfig(Config config) {
        InstrumentationConfiguration.Builder builder = InstrumentationConfiguration.newBuilder().withConfig(config);
        builder.addInstrumentedPackage("net.sqlcipher.database.SQLiteDatabase");
        builder.addInstrumentedPackage("org.commcare.models.encryption");
        return builder.build();
    }

    @Override
    protected AndroidManifest getAppManifest(Config config) {

        String manifestPath = "app/AndroidManifest.xml";
        String resPath = "app/res";
        String assetsPath = "app/assets";

        return new AndroidManifest(Fs.fileFromPath(manifestPath), Fs.fileFromPath(resPath), Fs.fileFromPath(assetsPath)) {
            @Override
            public int getTargetSdkVersion() {
                return 25;
            }

            @Override
            public int getMinSdkVersion() {
                return 9;
            }
        };
    }
}
@@ -238,88 +238,8 @@
 ion;
-%0Aimport org.robolectric.manifest.AndroidManifest;%0Aimport org.robolectric.res.Fs;
 %0A%0A/*
@@ -931,577 +931,6 @@
    %7D
-%0A%0A    @Override%0A    protected AndroidManifest getAppManifest(Config config) %7B%0A%0A        String manifestPath = %22app/AndroidManifest.xml%22;%0A        String resPath = %22app/res%22;%0A        String assetsPath = %22app/assets%22;%0A%0A        return new AndroidManifest(Fs.fileFromPath(manifestPath), Fs.fileFromPath(resPath), Fs.fileFromPath(assetsPath)) %7B%0A            @Override%0A            public int getTargetSdkVersion() %7B%0A                return 25;%0A            %7D%0A%0A            @Override%0A            public int getMinSdkVersion() %7B%0A                return 9;%0A            %7D%0A        %7D;%0A    %7D
 %0A%7D

Revert "trying overriding getAppManifest in CommCareTestRunner to fix test failures on jenkins"