-
-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref: use hilt for dependency injection (#3880)
* ref: use hilt for dependency injection * fix: fix hilt/dagger errors regarding DI * ref: moved CategoryRepository DI from AppModule to Kotlin file * fix: errors after rebase * ref: little fix * fix: tests
- Loading branch information
Showing
78 changed files
with
930 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 23 additions & 10 deletions
33
...nshots/java/openfoodfacts/github/scrachx/openfood/TakeScreenshotIncompleteProductsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,47 @@ | ||
package openfoodfacts.github.scrachx.openfood | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import openfoodfacts.github.scrachx.openfood.app.OFFApplication | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.android.testing.HiltAndroidRule | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import openfoodfacts.github.scrachx.openfood.features.search.ProductSearchActivity | ||
import openfoodfacts.github.scrachx.openfood.models.SearchInfo | ||
import openfoodfacts.github.scrachx.openfood.test.ScreenshotActivityTestRule | ||
import openfoodfacts.github.scrachx.openfood.test.ScreenshotParameter | ||
import openfoodfacts.github.scrachx.openfood.models.SearchInfo | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Take screenshots... | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
@HiltAndroidTest | ||
class TakeScreenshotIncompleteProductsTest : AbstractScreenshotTest() { | ||
|
||
@get:Rule | ||
var hiltRule = HiltAndroidRule(this) | ||
|
||
@Inject | ||
@ApplicationContext | ||
lateinit var context: Context | ||
|
||
@Rule | ||
var incompleteRule = ScreenshotActivityTestRule( | ||
ProductSearchActivity::class.java, "incompleteProducts", | ||
ProductSearchActivity::class.java, | ||
"incompleteProducts", | ||
context | ||
) | ||
|
||
@Test | ||
fun testTakeScreenshot() = startForAllLocales(createSearchIntent, listOf(incompleteRule)) | ||
fun testTakeScreenshot() = startForAllLocales(createSearchIntent, listOf(incompleteRule), context) | ||
|
||
companion object { | ||
private val createSearchIntent: (ScreenshotParameter) -> List<Intent?> = { | ||
listOf(Intent(OFFApplication.instance, ProductSearchActivity::class.java).apply { | ||
putExtra(ProductSearchActivity.SEARCH_INFO, SearchInfo.emptySearchInfo()) | ||
}) | ||
} | ||
private val createSearchIntent: (ScreenshotParameter) -> List<Intent?> = { | ||
listOf(Intent(context, ProductSearchActivity::class.java).apply { | ||
putExtra(ProductSearchActivity.SEARCH_INFO, SearchInfo.emptySearchInfo()) | ||
}) | ||
} | ||
} |
22 changes: 19 additions & 3 deletions
22
...tScreenshots/java/openfoodfacts/github/scrachx/openfood/TakeScreenshotMainActivityTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,43 @@ | ||
package openfoodfacts.github.scrachx.openfood | ||
|
||
import android.content.Context | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.android.testing.HiltAndroidRule | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import openfoodfacts.github.scrachx.openfood.features.MainActivity | ||
import openfoodfacts.github.scrachx.openfood.features.welcome.WelcomeActivity | ||
import openfoodfacts.github.scrachx.openfood.test.ScreenshotActivityTestRule | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Take screenshots... | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
@HiltAndroidTest | ||
class TakeScreenshotMainActivityTest : AbstractScreenshotTest() { | ||
|
||
|
||
@get:Rule | ||
var hiltRule = HiltAndroidRule(this) | ||
|
||
@Inject | ||
@ApplicationContext | ||
lateinit var context: Context | ||
|
||
|
||
@Rule | ||
var activityRule = ScreenshotActivityTestRule(MainActivity::class.java) | ||
var activityRule = ScreenshotActivityTestRule(MainActivity::class.java, context = context) | ||
|
||
@Rule | ||
var welcomeActivityRule = ScreenshotActivityTestRule(WelcomeActivity::class.java) | ||
var welcomeActivityRule = ScreenshotActivityTestRule(WelcomeActivity::class.java, context = context) | ||
|
||
@Test | ||
fun testTakeScreenshotMainActivity() { | ||
welcomeActivityRule.firstTimeLaunched = true | ||
startForAllLocales(rules = listOf(welcomeActivityRule, activityRule)) | ||
startForAllLocales(rules = listOf(welcomeActivityRule, activityRule), context = context) | ||
} | ||
} |
Oops, something went wrong.