Fixed one unit test, GTask integration tests are still broken

pull/14/head
Joshua Gross 15 years ago
parent 4958a29f96
commit 50203ecd9f

@ -42,10 +42,5 @@
<type>2</type> <type>2</type>
<locationURI>_android_astridApi_98e6a2cf/src</locationURI> <locationURI>_android_astridApi_98e6a2cf/src</locationURI>
</link> </link>
<link>
<name>astridApi_src</name>
<type>2</type>
<locationURI>_android_astridApi_98e6a2cf/src</locationURI>
</link>
</linkedResources> </linkedResources>
</projectDescription> </projectDescription>

@ -14,7 +14,6 @@ import org.json.JSONException;
import android.app.Activity; import android.app.Activity;
import android.app.Notification; import android.app.Notification;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.text.TextUtils; import android.text.TextUtils;
@ -150,7 +149,7 @@ public class GtasksSyncProvider extends SyncProvider<GtasksTaskContainer> {
* initiate sync in background * initiate sync in background
*/ */
@Override @Override
protected void initiateBackground(Service service) { protected void initiateBackground() {
try { try {
String authToken = gtasksPreferenceService.getToken(); String authToken = gtasksPreferenceService.getToken();

@ -15,7 +15,6 @@ import org.json.JSONObject;
import android.app.Activity; import android.app.Activity;
import android.app.Notification; import android.app.Notification;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.text.TextUtils; import android.text.TextUtils;
@ -146,7 +145,7 @@ public class ProducteevSyncProvider extends SyncProvider<ProducteevTaskContainer
* initiate sync in background * initiate sync in background
*/ */
@Override @Override
protected void initiateBackground(Service service) { protected void initiateBackground() {
dataService = ProducteevDataService.getInstance(); dataService = ProducteevDataService.getInstance();
try { try {

@ -35,7 +35,6 @@ import org.weloveastrid.rmilk.data.MilkNoteFields;
import android.app.Activity; import android.app.Activity;
import android.app.Notification; import android.app.Notification;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.app.Service;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
@ -154,7 +153,7 @@ public class MilkSyncProvider extends SyncProvider<MilkTaskContainer> {
*/ */
@Override @Override
@SuppressWarnings("nls") @SuppressWarnings("nls")
protected void initiateBackground(Service service) { protected void initiateBackground() {
DependencyInjectionService.getInstance().inject(this); DependencyInjectionService.getInstance().inject(this);
try { try {

@ -144,7 +144,7 @@ public class UpdateMessageService {
return gtasksPreferenceService.isLoggedIn(); return gtasksPreferenceService.isLoggedIn();
} }
else if(PLUGIN_RMILK.equals(plugin)) { else if(PLUGIN_RMILK.equals(plugin)) {
return !MilkUtilities.INSTANCE.isLoggedIn(); return MilkUtilities.INSTANCE.isLoggedIn();
} }
else else
return addOnService.isInstalled(plugin); return addOnService.isInstalled(plugin);

@ -1,5 +1,6 @@
package com.todoroo.astrid.gtasks; package com.todoroo.astrid.gtasks;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import com.todoroo.andlib.service.Autowired; import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.andlib.utility.DateUtilities;
@ -8,6 +9,7 @@ import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider; import com.todoroo.astrid.gtasks.sync.GtasksSyncProvider;
import com.todoroo.astrid.service.TaskService; import com.todoroo.astrid.service.TaskService;
import com.todoroo.astrid.test.DatabaseTestCase; import com.todoroo.astrid.test.DatabaseTestCase;
import com.todoroo.gtasks.GoogleConnectionManager;
import com.todoroo.gtasks.GoogleTaskListInfo; import com.todoroo.gtasks.GoogleTaskListInfo;
import com.todoroo.gtasks.GoogleTaskService; import com.todoroo.gtasks.GoogleTaskService;
import com.todoroo.gtasks.GoogleTaskTask; import com.todoroo.gtasks.GoogleTaskTask;
@ -18,7 +20,7 @@ import com.todoroo.gtasks.actions.ListActions;
public class GtasksSyncTest extends DatabaseTestCase { public class GtasksSyncTest extends DatabaseTestCase {
private static final String TEST_USERNAME = "tasktest@todoroo.com"; private static final String TEST_USERNAME = "astridtasktest@gmail.com";
private static final String TEST_PASSWORD = "tasktest0000"; private static final String TEST_PASSWORD = "tasktest0000";
private static boolean initialized = false; private static boolean initialized = false;
@ -26,6 +28,7 @@ public class GtasksSyncTest extends DatabaseTestCase {
private static GoogleTaskListInfo taskList; private static GoogleTaskListInfo taskList;
@Autowired TaskService taskService; @Autowired TaskService taskService;
@Autowired GtasksPreferenceService gtasksPreferenceService;
// --- tests // --- tests
@ -68,7 +71,8 @@ public class GtasksSyncTest extends DatabaseTestCase {
} }
private GoogleTaskTask thenAssertTaskExistsRemotely(Task task) throws Exception { private GoogleTaskTask thenAssertTaskExistsRemotely(Task task) throws Exception {
for(GoogleTaskTask remote : testService.getTasks(taskList.getId())) { List<GoogleTaskTask> tasks = testService.getTasks(taskList.getId());
for(GoogleTaskTask remote : tasks) {
if(remote.getName().equals(task.getValue(Task.TITLE))) if(remote.getName().equals(task.getValue(Task.TITLE)))
return remote; return remote;
} }
@ -82,7 +86,7 @@ public class GtasksSyncTest extends DatabaseTestCase {
private Task givenTask(String title) { private Task givenTask(String title) {
Task task = new Task(); Task task = new Task();
task.setValue(Task.TITLE, title); task.setValue(Task.TITLE, title + System.currentTimeMillis());
taskService.save(task); taskService.save(task);
return task; return task;
} }
@ -106,8 +110,9 @@ public class GtasksSyncTest extends DatabaseTestCase {
testService.executeListActions(taskList.getId(), actions.toArray(new ListAction[actions.size()])); testService.executeListActions(taskList.getId(), actions.toArray(new ListAction[actions.size()]));
} }
public static void initializeTestService() throws Exception { public void initializeTestService() throws Exception {
testService = new GoogleTaskService(TEST_USERNAME, TEST_PASSWORD); GoogleConnectionManager gcm = new GoogleConnectionManager(TEST_USERNAME, TEST_PASSWORD);
testService = new GoogleTaskService(gcm);
GoogleTaskView taskView = testService.getTaskView(); GoogleTaskView taskView = testService.getTaskView();
GoogleTaskListInfo[] lists = taskView.getAllLists(); GoogleTaskListInfo[] lists = taskView.getAllLists();
outer: { outer: {
@ -124,6 +129,7 @@ public class GtasksSyncTest extends DatabaseTestCase {
Preferences.setString(GtasksPreferenceService.PREF_DEFAULT_LIST, taskList.getId()); Preferences.setString(GtasksPreferenceService.PREF_DEFAULT_LIST, taskList.getId());
Preferences.setString(GtasksPreferenceService.PREF_USER_NAME, TEST_USERNAME); Preferences.setString(GtasksPreferenceService.PREF_USER_NAME, TEST_USERNAME);
Preferences.setString(GtasksPreferenceService.PREF_PASSWORD, TEST_PASSWORD); Preferences.setString(GtasksPreferenceService.PREF_PASSWORD, TEST_PASSWORD);
gtasksPreferenceService.setToken(gcm.getToken());
} }

Loading…
Cancel
Save