targetSdkVersion 28
versionCode 1
versionName "1.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
ndkBuild {
def gstRoot
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:rules:1.0.2'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
--- /dev/null
+package org.nnsuite.nnstreamer;
+
+import android.content.Context;
+import android.os.Environment;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+
+import static org.junit.Assert.*;
+
+/**
+ * Common definition to test NNStreamer API.
+ *
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class APITestCommon {
+ private static boolean mInitialized = false;
+
+ /**
+ * Initializes NNStreamer API library.
+ */
+ public static void initNNStreamer() {
+ if (!mInitialized) {
+ try {
+ Context context = InstrumentationRegistry.getTargetContext();
+ mInitialized = NNStreamer.initialize(context);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+ }
+
+ /**
+ * Gets the File object of tensorflow-lite image classification model.
+ * Note that, to invoke tensorflow-lite model in the storage, the permission READ_EXTERNAL_STORAGE is required.
+ */
+ public static File getTestModel() {
+ String root = Environment.getExternalStorageDirectory().getAbsolutePath();
+ File model = new File(root + "/nnstreamer/test/mobilenet_v1_1.0_224_quant.tflite");
+
+ if (!model.exists()) {
+ fail();
+ }
+
+ return model;
+ }
+
+ @Test
+ public void useAppContext() {
+ Context context = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("org.nnsuite.nnstreamer.test", context.getPackageName());
+ }
+}