java: Rename and update the Android instrumented test
The test was renamed to avoid the class colission with the
internal/InitTest. The test is also update to use the new init/login
API.
Change-Id: Ib3a98ce2bff02e05c2d009fe66a01af285af004e
diff --git a/syncbase/src/androidTest/java/io/v/syncbase/internal/InitTest.java b/syncbase/src/androidTest/java/io/v/syncbase/internal/InitTest.java
deleted file mode 100644
index a5ffab3..0000000
--- a/syncbase/src/androidTest/java/io/v/syncbase/internal/InitTest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2016 The Vanadium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package io.v.syncbase.internal;
-
-import android.support.test.runner.AndroidJUnit4;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-@RunWith(AndroidJUnit4.class)
-@SmallTest
-public class InitTest {
- @Test
- public void init() {
- Init.init();
- }
-}
diff --git a/syncbase/src/androidTest/java/io/v/syncbase/internal/InitTestInstrumented.java b/syncbase/src/androidTest/java/io/v/syncbase/internal/InitTestInstrumented.java
new file mode 100644
index 0000000..983be49
--- /dev/null
+++ b/syncbase/src/androidTest/java/io/v/syncbase/internal/InitTestInstrumented.java
@@ -0,0 +1,51 @@
+// Copyright 2016 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package io.v.syncbase.internal;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.google.common.util.concurrent.SettableFuture;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.concurrent.TimeUnit;
+
+import io.v.syncbase.Syncbase;
+
+@RunWith(AndroidJUnit4.class)
+@SmallTest
+public class InitTestInstrumented {
+ @Test
+ public void init() throws Exception {
+ System.loadLibrary("syncbase");
+ Syncbase.Options opts = new Syncbase.Options();
+ opts.rootDir = InstrumentationRegistry.getContext()
+ .getDir("syncbase", Context.MODE_PRIVATE).getAbsolutePath();
+ opts.disableUserdataSyncgroup = true;
+ opts.disableSyncgroupPublishing = true;
+ opts.testLogin = true;
+ Syncbase.init(opts);
+
+ final SettableFuture<Void> future = SettableFuture.create();
+
+ Syncbase.login("", "", new Syncbase.LoginCallback() {
+ @Override
+ public void onSuccess() {
+ future.set(null);
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ future.setException(e);
+ }
+ });
+
+ future.get(5, TimeUnit.SECONDS);
+ }
+}