1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-11 04:25:53 +00:00

Test fixes, removed RestAPI tests that require activity.

These tests could not be executed reliably, not even using activity tests.
This commit is contained in:
Felix Ableitner 2014-09-29 00:43:59 +03:00
parent 98d63a177f
commit 377615a1aa
4 changed files with 6 additions and 46 deletions

View file

@ -10,13 +10,9 @@ import java.util.List;
public class MockRestApi extends RestApi {
public MockRestApi(Context context, String url, OnApiAvailableListener listener) {
super(context, url, listener);
}
@Override
public void setApiKey(String apiKey) {
throw new UnsupportedOperationException();
public MockRestApi(Context context, String url, String apiKey,
OnApiAvailableListener listener) {
super(context, url, apiKey, listener);
}
@Override

View file

@ -49,7 +49,7 @@ public class MockSyncthingService extends SyncthingService {
@Override
public RestApi getApi() {
return new MockRestApi(this, null, null);
return new MockRestApi(this, null, null, null);
}
@Override

View file

@ -1,8 +1,6 @@
package com.nutomic.syncthingandroid.test.syncthing;
import android.app.Activity;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
@ -14,7 +12,6 @@ import com.nutomic.syncthingandroid.syncthing.SyncthingService;
import com.nutomic.syncthingandroid.test.MockContext;
import com.nutomic.syncthingandroid.util.ConfigXml;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -139,39 +136,6 @@ public class RestApiTest extends AndroidTestCase {
latch.await(1, TimeUnit.SECONDS);
}
@LargeTest
public void testModifyNode() throws InterruptedException {
final RestApi.Node node = new RestApi.Node();
node.NodeID = "P56IOI7-MZJNU2Y-IQGDREY-DM2MGTI-MGL3BXN-PQ6W5BM-TBBZ4TJ-XZWICQ2";
node.Addresses = "dynamic";
node.Name = "my node";
final CountDownLatch latch = new CountDownLatch(1);
mApi.editNode(node, new Activity(), new RestApi.OnNodeIdNormalizedListener() {
@Override
public void onNodeIdNormalized(String normalizedId, String error) {
assertEquals(node.NodeID, normalizedId);
assertEquals(null, error);
latch.countDown();
}
});
latch.await(10, TimeUnit.SECONDS);
assertTrue(mApi.deleteNode(node, new Activity()));
}
@SmallTest
public void testModifyRepo() {
RestApi.Repo repo = new RestApi.Repo();
repo.Directory = "/my/dir";
repo.ID = "my-repo";
repo.NodeIds = new ArrayList<>();
repo.ReadOnly = false;
repo.Versioning = new RestApi.Versioning();
assertTrue(mApi.editRepo(repo, true, new Activity()));
assertTrue(mApi.deleteRepo(repo, new Activity()));
}
@MediumTest
public void testNormalizeNodeId() throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);

View file

@ -82,9 +82,9 @@ public class SyncthingRunnable implements Runnable {
.setOnlyAlertOnce(true);
Notification n = new NotificationCompat.BigTextStyle(b)
.bigText(mContext.getString(R.string.binary_crashed_message, ret)).build();
NotificationManager mNotificationManager = (NotificationManager)
NotificationManager nm = (NotificationManager)
mContext.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(NOTIFICATION_CRASHED, n);
nm.notify(NOTIFICATION_CRASHED, n);
}
}
}