From ca5b7daa36a5a6250ee97e9fe9d4a63378a75caa Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Sat, 6 Jul 2024 04:11:26 -0500 Subject: [PATCH] Fix tests --- .../com/todoroo/astrid/adapter/OfflineSubtaskTest.kt | 12 +++++------- .../com/todoroo/astrid/subtasks/SubtasksTestCase.kt | 6 +++--- .../tasks/ui/editviewmodel/TaskListViewModelTest.kt | 6 +++--- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/src/androidTest/java/com/todoroo/astrid/adapter/OfflineSubtaskTest.kt b/app/src/androidTest/java/com/todoroo/astrid/adapter/OfflineSubtaskTest.kt index 5f2fb7773..46a7dd543 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/adapter/OfflineSubtaskTest.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/adapter/OfflineSubtaskTest.kt @@ -1,12 +1,8 @@ package com.todoroo.astrid.adapter -import android.content.Context -import androidx.test.core.app.ApplicationProvider import com.natpryce.makeiteasy.MakeItEasy.with import com.natpryce.makeiteasy.PropertyValue -import com.todoroo.astrid.core.BuiltInFilterExposer import com.todoroo.astrid.dao.TaskDao -import org.tasks.data.entity.Task import com.todoroo.astrid.service.TaskMover import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -15,10 +11,12 @@ import org.junit.Assert.assertEquals import org.junit.Before import org.junit.Test import org.tasks.LocalBroadcastManager -import org.tasks.data.dao.CaldavDao -import org.tasks.data.dao.GoogleTaskDao import org.tasks.data.TaskContainer import org.tasks.data.TaskListQuery.getQuery +import org.tasks.data.dao.CaldavDao +import org.tasks.data.dao.GoogleTaskDao +import org.tasks.data.entity.Task +import org.tasks.filters.MyTasksFilter import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule import org.tasks.makers.TaskMaker.PARENT @@ -38,7 +36,7 @@ class OfflineSubtaskTest : InjectingTestCase() { private lateinit var adapter: TaskAdapter private val tasks = ArrayList() - private val filter = BuiltInFilterExposer.getMyTasksFilter(ApplicationProvider.getApplicationContext().resources) + private val filter = runBlocking { MyTasksFilter.create() } private val dataSource = object : TaskAdapterDataSource { override fun getItem(position: Int) = tasks[position] diff --git a/app/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.kt b/app/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.kt index 8aa934529..a2d018f51 100644 --- a/app/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.kt +++ b/app/src/androidTest/java/com/todoroo/astrid/subtasks/SubtasksTestCase.kt @@ -1,13 +1,13 @@ package com.todoroo.astrid.subtasks -import androidx.test.InstrumentationRegistry -import com.todoroo.astrid.core.BuiltInFilterExposer import com.todoroo.astrid.dao.TaskDao +import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertNotNull import org.tasks.data.dao.TaskListMetadataDao import org.tasks.data.entity.Task import org.tasks.filters.AstridOrderingFilter +import org.tasks.filters.MyTasksFilter import org.tasks.injection.InjectingTestCase import org.tasks.preferences.Preferences import javax.inject.Inject @@ -21,7 +21,7 @@ abstract class SubtasksTestCase : InjectingTestCase() { override fun setUp() { super.setUp() - filter = BuiltInFilterExposer.getMyTasksFilter(InstrumentationRegistry.getTargetContext().resources) + filter = runBlocking { MyTasksFilter.create() } preferences.clear(SubtasksFilterUpdater.ACTIVE_TASKS_ORDER) updater = SubtasksFilterUpdater(taskListMetadataDao, taskDao) } diff --git a/app/src/androidTest/java/org/tasks/ui/editviewmodel/TaskListViewModelTest.kt b/app/src/androidTest/java/org/tasks/ui/editviewmodel/TaskListViewModelTest.kt index e30a5bfc8..3939eee8d 100644 --- a/app/src/androidTest/java/org/tasks/ui/editviewmodel/TaskListViewModelTest.kt +++ b/app/src/androidTest/java/org/tasks/ui/editviewmodel/TaskListViewModelTest.kt @@ -1,7 +1,5 @@ package org.tasks.ui.editviewmodel -import com.todoroo.astrid.core.BuiltInFilterExposer -import org.tasks.data.entity.Task import com.todoroo.astrid.service.TaskDeleter import dagger.hilt.android.testing.HiltAndroidTest import dagger.hilt.android.testing.UninstallModules @@ -15,6 +13,8 @@ import org.tasks.analytics.Firebase import org.tasks.billing.Inventory import org.tasks.data.dao.DeletionDao import org.tasks.data.dao.TaskDao +import org.tasks.data.entity.Task +import org.tasks.filters.MyTasksFilter import org.tasks.injection.InjectingTestCase import org.tasks.injection.ProductionModule import org.tasks.preferences.Preferences @@ -47,7 +47,7 @@ class TaskListViewModelTest : InjectingTestCase() { inventory = inventory, firebase = firebase, ) - viewModel.setFilter(BuiltInFilterExposer.getMyTasksFilter(context.resources)) + viewModel.setFilter(runBlocking { MyTasksFilter.create() }) } @Test