/*
 * Copyright (c) 2014, Apptentive, Inc. All Rights Reserved.
 * Please refer to the LICENSE file for the terms and conditions
 * under which redistribution and use of this file is permitted.
 */

package com.apptentive.android.sdk.tests;

import android.content.Context;
import android.os.Build;
import android.test.InstrumentationTestCase;
import com.apptentive.android.sdk.ApptentiveInternal;
import com.apptentive.android.sdk.Log;
import com.apptentive.android.sdk.model.CodePointStore;
import com.apptentive.android.sdk.module.engagement.interaction.InteractionManager;

/**
 * @author Sky Kelsey
 */
public class ApptentiveInstrumentationTestCase extends InstrumentationTestCase {

	protected Context testContext;
	protected Context targetContext;

	static {
		ApptentiveInternal.setMinimumLogLevel(Log.Level.VERBOSE);
	}

	protected Context getTestContext() {
		if (testContext == null) {
			testContext = getInstrumentation().getContext();
		}
		return testContext;
	}

	protected Context getTargetContext() {
		if (targetContext == null) {
			targetContext = getInstrumentation().getTargetContext();
		}
		return targetContext;
	}

	protected void resetDevice() {
		getTargetContext().getSharedPreferences("APPTENTIVE", Context.MODE_PRIVATE).edit().clear().commit();
		CodePointStore.clear(getTargetContext());
		InteractionManager.clear(getTargetContext());
	}

	protected static void sleep(long millis) {
		try {
			Thread.sleep(millis);
		} catch (InterruptedException e) {
		}
	}

	protected static boolean isRunningOnEmulator() {
		return Build.FINGERPRINT.contains("generic");
	}
}

@@ -337,16 +337,17 @@
 stCase;%0A
+%0A
 import c
@@ -570,16 +570,71 @@
 Manager;
+%0Aimport com.apptentive.android.sdk.tests.util.FileUtil;
 %0A%0A/**%0A *
@@ -1645,11 +1645,173 @@
 ic%22);%0A%09%7D
+%0A%0A%09protected String loadFileAssetAsString(String pathFromAssetsDirectory) %7B%0A%09%09return FileUtil.loadTextAssetAsString(getTestContext(), pathFromAssetsDirectory);%0A%09%7D
 %0A%7D%0A

Add method for loading asset as string to base testcase class.