Fix test compile

pull/795/head
Alex Baker 6 years ago
parent 8dc7839db0
commit 6e6cf1e51a

@ -18,6 +18,7 @@ import org.tasks.data.TagDataDao;
import org.tasks.data.TaskAttachmentDao; import org.tasks.data.TaskAttachmentDao;
import org.tasks.data.TaskListMetadataDao; import org.tasks.data.TaskListMetadataDao;
import org.tasks.data.UserActivityDao; import org.tasks.data.UserActivityDao;
import org.tasks.jobs.WorkManager;
import org.tasks.notifications.NotificationDao; import org.tasks.notifications.NotificationDao;
import org.tasks.preferences.PermissionChecker; import org.tasks.preferences.PermissionChecker;
import org.tasks.preferences.PermissivePermissionChecker; import org.tasks.preferences.PermissivePermissionChecker;
@ -85,9 +86,9 @@ public class TestModule {
} }
@Provides @Provides
public TaskDao getTaskDao(Database database) { public TaskDao getTaskDao(WorkManager workManager, Database database) {
TaskDao taskDao = database.getTaskDao(); TaskDao taskDao = database.getTaskDao();
taskDao.initialize(context); taskDao.initialize(workManager);
return taskDao; return taskDao;
} }

@ -1,17 +1,20 @@
package org.tasks.preferences; package org.tasks.preferences;
import static androidx.test.InstrumentationRegistry.getTargetContext;
import static junit.framework.Assert.assertEquals;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import androidx.test.runner.AndroidJUnit4;
import java.util.concurrent.TimeUnit;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.tasks.R; import org.tasks.R;
import org.tasks.time.DateTime; import org.tasks.time.DateTime;
import java.util.concurrent.TimeUnit;
import androidx.test.runner.AndroidJUnit4;
import static androidx.test.InstrumentationRegistry.getTargetContext;
import static junit.framework.Assert.assertEquals;
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class PreferenceTests { public class PreferenceTests {
@ -22,7 +25,7 @@ public class PreferenceTests {
@Before @Before
public void setUp() { public void setUp() {
preferences = new Preferences(getTargetContext(), null); preferences = new Preferences(getTargetContext());
preferences.clear(); preferences.clear();
preferences.setBoolean(R.string.p_rmd_enable_quiet, true); preferences.setBoolean(R.string.p_rmd_enable_quiet, true);
} }

@ -1,29 +1,13 @@
package com.todoroo.astrid.gtasks; package com.todoroo.astrid.gtasks;
import static com.natpryce.makeiteasy.MakeItEasy.with;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static org.tasks.makers.GtaskListMaker.ID;
import static org.tasks.makers.GtaskListMaker.LAST_SYNC;
import static org.tasks.makers.GtaskListMaker.NAME;
import static org.tasks.makers.GtaskListMaker.REMOTE_ID;
import static org.tasks.makers.GtaskListMaker.newGtaskList;
import static org.tasks.makers.RemoteGtaskListMaker.newRemoteList;
import static org.tasks.time.DateTimeUtils.currentTimeMillis;
import androidx.test.runner.AndroidJUnit4;
import com.google.api.client.util.DateTime; import com.google.api.client.util.DateTime;
import com.google.api.services.tasks.model.TaskList; import com.google.api.services.tasks.model.TaskList;
import com.todoroo.astrid.dao.TaskDao;
import com.todoroo.astrid.service.TaskDeleter; import com.todoroo.astrid.service.TaskDeleter;
import javax.inject.Inject;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.tasks.LocalBroadcastManager; import org.tasks.LocalBroadcastManager;
import org.tasks.data.GoogleTaskAccount; import org.tasks.data.GoogleTaskAccount;
import org.tasks.data.GoogleTaskDao;
import org.tasks.data.GoogleTaskList; import org.tasks.data.GoogleTaskList;
import org.tasks.data.GoogleTaskListDao; import org.tasks.data.GoogleTaskListDao;
import org.tasks.injection.InjectingTestCase; import org.tasks.injection.InjectingTestCase;
@ -31,13 +15,28 @@ import org.tasks.injection.TestComponent;
import org.tasks.jobs.WorkManager; import org.tasks.jobs.WorkManager;
import org.tasks.makers.RemoteGtaskListMaker; import org.tasks.makers.RemoteGtaskListMaker;
import javax.inject.Inject;
import androidx.test.runner.AndroidJUnit4;
import static com.natpryce.makeiteasy.MakeItEasy.with;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static org.tasks.makers.GtaskListMaker.ID;
import static org.tasks.makers.GtaskListMaker.LAST_SYNC;
import static org.tasks.makers.GtaskListMaker.NAME;
import static org.tasks.makers.GtaskListMaker.REMOTE_ID;
import static org.tasks.makers.GtaskListMaker.newGtaskList;
import static org.tasks.makers.RemoteGtaskListMaker.newRemoteList;
import static org.tasks.time.DateTimeUtils.currentTimeMillis;
@RunWith(AndroidJUnit4.class) @RunWith(AndroidJUnit4.class)
public class GtasksListServiceTest extends InjectingTestCase { public class GtasksListServiceTest extends InjectingTestCase {
@Inject TaskDeleter taskDeleter; @Inject TaskDeleter taskDeleter;
@Inject LocalBroadcastManager localBroadcastManager; @Inject LocalBroadcastManager localBroadcastManager;
@Inject GoogleTaskDao googleTaskDao;
@Inject TaskDao taskDao;
@Inject WorkManager workManager; @Inject WorkManager workManager;
@Inject GoogleTaskListDao googleTaskListDao; @Inject GoogleTaskListDao googleTaskListDao;
@ -49,7 +48,7 @@ public class GtasksListServiceTest extends InjectingTestCase {
workManager.init(); workManager.init();
gtasksListService = gtasksListService =
new GtasksListService( new GtasksListService(
googleTaskListDao, taskDeleter, localBroadcastManager, googleTaskDao, taskDao); googleTaskListDao, taskDeleter, localBroadcastManager);
} }
@Override @Override

Loading…
Cancel
Save