diff --git a/tests-sync/.classpath b/tests-sync/.classpath
index bf2584e47..235ca48e1 100644
--- a/tests-sync/.classpath
+++ b/tests-sync/.classpath
@@ -5,8 +5,5 @@
-
-
-
diff --git a/tests-sync/project.properties b/tests-sync/project.properties
index 816c46ffb..730e911f2 100644
--- a/tests-sync/project.properties
+++ b/tests-sync/project.properties
@@ -9,5 +9,3 @@
# Project target.
target=android-14
-android.library.reference.1=../api
-android.library.reference.2=../facebook/facebook
diff --git a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java
index 4b99f73c9..684176fdc 100644
--- a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java
+++ b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksNewSyncTest.java
@@ -24,16 +24,16 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.api.GtasksApiUtilities;
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
-import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
+import com.todoroo.astrid.gtasks.sync.GtasksSyncV2Provider;
import com.todoroo.astrid.service.MetadataService;
import com.todoroo.astrid.service.TaskService;
+import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
import com.todoroo.astrid.test.DatabaseTestCase;
@SuppressWarnings("nls")
public class GtasksNewSyncTest extends DatabaseTestCase {
private static GtasksInvoker gtasksService;
- private GtasksSyncProvider syncProvider;
private static boolean initialized = false;
private boolean bypassTests = false;
@@ -473,8 +473,21 @@ public class GtasksNewSyncTest extends DatabaseTestCase {
//Perform a synchronization
private void whenInvokeSync() {
- syncProvider.synchronize(getContext());
- gtasksService = syncProvider.getGtasksService(); //This is to prevent token mismatch; the sync provider invalidates the old one
+ new GtasksSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() {
+ @Override
+ public void finished() {
+ synchronized(GtasksNewSyncTest.this) {
+ GtasksNewSyncTest.this.notify();
+ }
+ }
+ });
+ try {
+ synchronized(this) {
+ wait();
+ }
+ } catch (InterruptedException e) {
+ fail("Interrupted while waiting for sync to finish");
+ }
}
@Override
@@ -486,8 +499,6 @@ public class GtasksNewSyncTest extends DatabaseTestCase {
}
setupTestList();
-
- syncProvider = new GtasksSyncProvider();
}
private void initializeTestService() throws Exception {
diff --git a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java
index 589b76338..5ef2e7f45 100644
--- a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java
+++ b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncOnSaveTest.java
@@ -33,7 +33,7 @@ public class GtasksSyncOnSaveTest extends DatabaseTestCase {
@Autowired GtasksMetadataService gtasksMetadataService;
@Autowired GtasksPreferenceService gtasksPreferenceService;
- private GtasksInvoker gtasksService;
+ private static GtasksInvoker gtasksService;
private boolean initialized = false;
private boolean bypassTests = false;
private static final String TEST_ACCOUNT = "sync_tester2@astrid.com";
diff --git a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncTest.java b/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncTest.java
deleted file mode 100644
index 2e3efc46d..000000000
--- a/tests-sync/src/com/todoroo/astrid/gtasks/GtasksSyncTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*package com.todoroo.astrid.gtasks;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.todoroo.andlib.service.Autowired;
-import com.todoroo.andlib.utility.DateUtilities;
-import com.todoroo.andlib.utility.Preferences;
-import com.todoroo.astrid.data.Task;
-import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
-import com.todoroo.astrid.service.TaskService;
-import com.todoroo.astrid.test.DatabaseTestCase;
-
-
-public class GtasksSyncTest extends DatabaseTestCase {
-
- private static final String TEST_USERNAME = "astridtasktest@gmail.com";
- private static final String TEST_PASSWORD = "tasktest0000";
-
- private static boolean initialized = false;
- private static GoogleTaskService testService;
- private static GoogleTaskListInfo taskList;
-
- @Autowired TaskService taskService;
- @Autowired GtasksPreferenceService gtasksPreferenceService;
-
- // --- tests
-
- // !!! This test is disabled until it works :(
-
- public void DISABLED_testBasicTaskCreation() throws Exception {
- Task task = givenTask("wasabi");
-
- whenSynchronizing();
-
- thenAssertTaskExistsRemotely(task);
- }
-
- public void DISABLED_testTaskWithDueDate() throws Exception {
- Task task = givenTask("wasabi");
- task.setValue(Task.DUE_DATE, task.createDueDate(Task.URGENCY_SPECIFIC_DAY,
- DateUtilities.now()));
-
- whenSynchronizing();
-
- GoogleTaskTask remote = thenAssertTaskExistsRemotely(task);
- assertTrue(remote.getTask_date() > DateUtilities.now() - DateUtilities.ONE_DAY);
- assertEquals(task.getValue(Task.DUE_DATE), refetchLocal(task).getValue(Task.DUE_DATE));
- }
-
- public void DISABLED_testTaskWithDueTime() throws Exception {
- Task task = givenTask("wasabi");
- task.setValue(Task.DUE_DATE, task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME,
- DateUtilities.now()));
-
- whenSynchronizing();
-
- GoogleTaskTask remote = thenAssertTaskExistsRemotely(task);
- assertTrue(remote.getTask_date() > DateUtilities.now() - DateUtilities.ONE_DAY);
- assertEquals(task.getValue(Task.DUE_DATE), refetchLocal(task).getValue(Task.DUE_DATE));
- }
-
- // --- helpers
-
- private Task refetchLocal(Task task) {
- return taskService.fetchById(task.getId(), Task.PROPERTIES);
- }
-
- private GoogleTaskTask thenAssertTaskExistsRemotely(Task task) throws Exception {
- List tasks = testService.getTasks(taskList.getId());
- for(GoogleTaskTask remote : tasks) {
- if(remote.getName().equals(task.getValue(Task.TITLE)))
- return remote;
- }
- fail("Task didn't exist remotely: " + task);
- return null;
- }
-
- private void whenSynchronizing() {
- new GtasksSyncProvider().synchronize(getContext());
- }
-
- private Task givenTask(String title) {
- Task task = new Task();
- task.setValue(Task.TITLE, title + System.currentTimeMillis());
- taskService.save(task);
- return task;
- }
-
- // --- setup stuff
-
- // set up task list and clean it out
- protected void DISABLED_setUp() throws Exception {
- super.setUp();
-
- if(!initialized)
- initializeTestService();
-
- ArrayList actions = new ArrayList();
- ListActions l = new ListActions();
- for(GoogleTaskTask task : testService.getTasks(taskList.getId())) {
- actions.add(l.modifyTask(task.getId()).deleted(true).done());
- }
-
- testService.executeListActions(taskList.getId(), actions.toArray(new ListAction[actions.size()]));
- }
-
- public void initializeTestService() throws Exception {
- GoogleConnectionManager gcm = new GoogleConnectionManager(TEST_USERNAME, TEST_PASSWORD);
- testService = new GoogleTaskService(gcm);
- GoogleTaskView taskView = testService.getTaskView();
- GoogleTaskListInfo[] lists = taskView.getAllLists();
- outer: {
- for(GoogleTaskListInfo list : lists) {
- if("AstridUnitTests".equals(list.getName())) {
- taskList = list;
- break outer;
- }
- }
- fail("could not find the main list");
- }
- initialized = true;
-
- Preferences.setString(GtasksPreferenceService.PREF_DEFAULT_LIST, taskList.getId());
- Preferences.setString(GtasksPreferenceService.PREF_USER_NAME, TEST_USERNAME);
- Preferences.setString(GtasksPreferenceService.PREF_PASSWORD, TEST_PASSWORD);
- gtasksPreferenceService.setToken(gcm.getToken());
- }
-
-
-
-}//*/
diff --git a/tests-sync/src/com/todoroo/astrid/sync/repeats/AbstractSyncRepeatTests.java b/tests-sync/src/com/todoroo/astrid/sync/repeats/AbstractSyncRepeatTests.java
index 70862198d..4280b6270 100644
--- a/tests-sync/src/com/todoroo/astrid/sync/repeats/AbstractSyncRepeatTests.java
+++ b/tests-sync/src/com/todoroo/astrid/sync/repeats/AbstractSyncRepeatTests.java
@@ -21,6 +21,7 @@ import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.dao.MetadataDao;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
+import com.todoroo.astrid.data.SyncFlags;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.repeats.RepeatTaskCompleteListener;
import com.todoroo.astrid.test.DatabaseTestCase;
@@ -38,11 +39,11 @@ abstract public class AbstractSyncRepeatTests extends DatabaseTest
protected void setUp() throws Exception {
super.setUp();
Preferences.setStringFromInteger(R.string.p_default_urgency_key, 0);
- RepeatTaskCompleteListener.setSkipActFmCheck(true);
}
private void saveAndTriggerRepeatListener(Task task) {
- Flags.set(Flags.ACTFM_SUPPRESS_SYNC);
+ task.putTransitory(SyncFlags.ACTFM_SUPPRESS_SYNC, true);
+ task.putTransitory(SyncFlags.GTASKS_SUPPRESS_SYNC, true);
if(task.isSaved())
taskDao.saveExisting(task);
else
diff --git a/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsActFmSync.java b/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsActFmSync.java
index aa2f1d9b3..9f0c4499d 100644
--- a/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsActFmSync.java
+++ b/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsActFmSync.java
@@ -18,13 +18,13 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.actfm.sync.ActFmDataService;
import com.todoroo.astrid.actfm.sync.ActFmInvoker;
import com.todoroo.astrid.actfm.sync.ActFmPreferenceService;
-import com.todoroo.astrid.actfm.sync.ActFmSyncProvider;
import com.todoroo.astrid.actfm.sync.ActFmSyncService;
+import com.todoroo.astrid.actfm.sync.ActFmSyncV2Provider;
import com.todoroo.astrid.dao.TaskDao.TaskCriteria;
import com.todoroo.astrid.data.Metadata;
import com.todoroo.astrid.data.Task;
-import com.todoroo.astrid.repeats.RepeatTaskCompleteListener;
import com.todoroo.astrid.service.MetadataService;
+import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
@@ -42,7 +42,6 @@ public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
protected void setUp() throws Exception {
super.setUp();
Preferences.setStringFromInteger(R.string.p_default_urgency_key, 0);
- RepeatTaskCompleteListener.setSkipActFmCheck(false);
if (!initialized) {
initializeTestService();
@@ -53,7 +52,7 @@ public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
private void initializeTestService() throws Exception {
invoker = new ActFmInvoker();
- authenticate(TEST_ACCOUNT, null, ActFmInvoker.PROVIDER_PASSWORD, TEST_PASSWORD);
+ authenticate(TEST_ACCOUNT, null, null, ActFmInvoker.PROVIDER_PASSWORD, TEST_PASSWORD);
initialized = true;
}
@@ -70,9 +69,9 @@ public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
}
}
- private void authenticate(String email, String name, String provider, String secret) {
+ private void authenticate(String email, String firstName, String lastName, String provider, String secret) {
try {
- JSONObject result = invoker.authenticate(email, name, provider, secret);
+ JSONObject result = invoker.authenticate(email, firstName, lastName, provider, secret);
String token = invoker.getToken();
postAuthenticate(result, token);
} catch (IOException e) {
@@ -96,7 +95,21 @@ public class RepeatTestsActFmSync extends AbstractSyncRepeatTests {
@Override
protected void waitAndSync() {
AndroidUtilities.sleepDeep(3000L);
- new ActFmSyncProvider().synchronize(null);
+ new ActFmSyncV2Provider().synchronizeActiveTasks(true, new SyncResultCallbackAdapter() {
+ @Override
+ public void finished() {
+ synchronized(RepeatTestsActFmSync.this) {
+ RepeatTestsActFmSync.this.notify();
+ }
+ }
+ });
+ try {
+ synchronized(this) {
+ wait();
+ }
+ } catch (InterruptedException e) {
+ fail("Interrupted while waiting for sync to finish");
+ }
AndroidUtilities.sleepDeep(3000L);
}
diff --git a/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java b/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java
index 0ce53d716..b4f873f3f 100644
--- a/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java
+++ b/tests-sync/src/com/todoroo/astrid/sync/repeats/RepeatTestsGtasksSync.java
@@ -25,9 +25,9 @@ import com.todoroo.astrid.gtasks.GtasksPreferenceService;
import com.todoroo.astrid.gtasks.api.GtasksApiUtilities;
import com.todoroo.astrid.gtasks.api.GtasksInvoker;
import com.todoroo.astrid.gtasks.auth.GtasksTokenValidator;
-import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
-import com.todoroo.astrid.repeats.RepeatTaskCompleteListener;
+import com.todoroo.astrid.gtasks.sync.GtasksSyncV2Provider;
import com.todoroo.astrid.service.MetadataService;
+import com.todoroo.astrid.sync.SyncResultCallbackAdapter;
public class RepeatTestsGtasksSync extends AbstractSyncRepeatTests {
@@ -45,7 +45,6 @@ public class RepeatTestsGtasksSync extends AbstractSyncRepeatTests