From 39ade7bdff2827bae36afcfe721f8fb1e5f245b4 Mon Sep 17 00:00:00 2001 From: Shridhar Goel Date: Fri, 6 Nov 2020 12:57:06 +0530 Subject: [PATCH] Fix #2080: Remove injected TestCoroutineDispatchers if not in use (#2083) * Remove injected TestCoroutineDispatchers if not in use * Remove unused imports * Update with required changes * Remove unused import --- .../org/oppia/android/app/faq/FAQListFragmentTest.kt | 6 ------ .../oppia/android/app/faq/FAQSingleActivityTest.kt | 6 ------ .../org/oppia/android/app/help/HelpFragmentTest.kt | 6 ------ .../app/mydownloads/MyDownloadsFragmentTest.kt | 11 ----------- .../org/oppia/android/app/parser/HtmlParserTest.kt | 6 ------ 5 files changed, 35 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt index 56627db3baf..6a341781f1c 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQListFragmentTest.kt @@ -58,7 +58,6 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.testing.TestAccessibilityModule -import org.oppia.android.testing.TestCoroutineDispatchers import org.oppia.android.testing.TestDispatcherModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.util.caching.testing.CachingTestModule @@ -70,7 +69,6 @@ import org.oppia.android.util.parser.HtmlParserEntityTypeModule import org.oppia.android.util.parser.ImageParsingModule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode -import javax.inject.Inject import javax.inject.Singleton /** Tests for [FAQListFragment]. */ @@ -78,19 +76,15 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = FAQListFragmentTest.TestApplication::class, qualifiers = "port-xxhdpi") class FAQListFragmentTest { - @Inject - lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Before fun setUp() { Intents.init() setUpTestApplicationComponent() - testCoroutineDispatchers.registerIdlingResource() } @After fun tearDown() { - testCoroutineDispatchers.unregisterIdlingResource() Intents.release() } diff --git a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt index 7d05df8559e..98e968ef28d 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/faq/FAQSingleActivityTest.kt @@ -53,7 +53,6 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.testing.TestAccessibilityModule -import org.oppia.android.testing.TestCoroutineDispatchers import org.oppia.android.testing.TestDispatcherModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.util.caching.testing.CachingTestModule @@ -78,9 +77,6 @@ class FAQSingleActivityTest { private lateinit var launchedActivity: Activity - @Inject - lateinit var testCoroutineDispatchers: TestCoroutineDispatchers - @Inject lateinit var htmlParserFactory: HtmlParser.Factory @@ -96,7 +92,6 @@ class FAQSingleActivityTest { @Before fun setUp() { setUpTestApplicationComponent() - testCoroutineDispatchers.registerIdlingResource() Intents.init() val intent = createFAQSingleActivity() launchedActivity = activityTestRule.launchActivity(intent) @@ -104,7 +99,6 @@ class FAQSingleActivityTest { @After fun tearDown() { - testCoroutineDispatchers.unregisterIdlingResource() Intents.release() } diff --git a/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt index 6314ab69dd5..29d1af2fba4 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/help/HelpFragmentTest.kt @@ -61,7 +61,6 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.testing.TestAccessibilityModule -import org.oppia.android.testing.TestCoroutineDispatchers import org.oppia.android.testing.TestDispatcherModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.util.caching.testing.CachingTestModule @@ -73,27 +72,22 @@ import org.oppia.android.util.parser.HtmlParserEntityTypeModule import org.oppia.android.util.parser.ImageParsingModule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode -import javax.inject.Inject import javax.inject.Singleton @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(application = HelpFragmentTest.TestApplication::class, qualifiers = "port-xxhdpi") class HelpFragmentTest { - @Inject - lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Before fun setUp() { setUpTestApplicationComponent() - testCoroutineDispatchers.registerIdlingResource() Intents.init() FirebaseApp.initializeApp(ApplicationProvider.getApplicationContext()) } @After fun tearDown() { - testCoroutineDispatchers.unregisterIdlingResource() Intents.release() } diff --git a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt index 952b85caf60..7505fa26b46 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/mydownloads/MyDownloadsFragmentTest.kt @@ -18,7 +18,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import dagger.Component import org.hamcrest.CoreMatchers.allOf import org.hamcrest.CoreMatchers.instanceOf -import org.junit.After import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -51,7 +50,6 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.testing.TestAccessibilityModule -import org.oppia.android.testing.TestCoroutineDispatchers import org.oppia.android.testing.TestDispatcherModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.util.caching.testing.CachingTestModule @@ -63,7 +61,6 @@ import org.oppia.android.util.parser.HtmlParserEntityTypeModule import org.oppia.android.util.parser.ImageParsingModule import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode -import javax.inject.Inject import javax.inject.Singleton /** Tests for [MyDownloadsFragment]. */ @@ -71,18 +68,10 @@ import javax.inject.Singleton @LooperMode(LooperMode.Mode.PAUSED) @Config(application = MyDownloadsFragmentTest.TestApplication::class, qualifiers = "port-xxhdpi") class MyDownloadsFragmentTest { - @Inject - lateinit var testCoroutineDispatchers: TestCoroutineDispatchers @Before fun setUp() { setUpTestApplicationComponent() - testCoroutineDispatchers.registerIdlingResource() - } - - @After - fun tearDown() { - testCoroutineDispatchers.unregisterIdlingResource() } @Test diff --git a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt index e12bda1bd8b..302ad677265 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/parser/HtmlParserTest.kt @@ -53,7 +53,6 @@ import org.oppia.android.domain.oppialogger.loguploader.WorkManagerConfiguration import org.oppia.android.domain.question.QuestionModule import org.oppia.android.domain.topic.PrimeTopicAssetsControllerModule import org.oppia.android.testing.TestAccessibilityModule -import org.oppia.android.testing.TestCoroutineDispatchers import org.oppia.android.testing.TestDispatcherModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.util.caching.testing.CachingTestModule @@ -80,9 +79,6 @@ class HtmlParserTest { private lateinit var launchedActivity: Activity - @Inject - lateinit var testCoroutineDispatchers: TestCoroutineDispatchers - @Inject lateinit var htmlParserFactory: HtmlParser.Factory @@ -98,7 +94,6 @@ class HtmlParserTest { @Before fun setUp() { setUpTestApplicationComponent() - testCoroutineDispatchers.registerIdlingResource() Intents.init() val intent = Intent(Intent.ACTION_PICK) launchedActivity = activityTestRule.launchActivity(intent) @@ -106,7 +101,6 @@ class HtmlParserTest { @After fun tearDown() { - testCoroutineDispatchers.unregisterIdlingResource() Intents.release() }