aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2021-09-13 20:57:56 -0700
committerAllan Wang <me@allanwang.ca>2021-09-13 20:57:56 -0700
commit47fcc3a2947be85a57086f7621ef1bdfcbd8a404 (patch)
treed9b4ef4daa9b28f26a8bf440be4ce997ad761192
parent2cea05c08619984947f2d997a0677459a7c42acf (diff)
downloadfrost-47fcc3a2947be85a57086f7621ef1bdfcbd8a404.tar.gz
frost-47fcc3a2947be85a57086f7621ef1bdfcbd8a404.tar.bz2
frost-47fcc3a2947be85a57086f7621ef1bdfcbd8a404.zip
Create initial hilt tests
-rw-r--r--app/src/androidTest/kotlin/com/pitchedapps/frost/activities/ActivityConstructionTest.kt24
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt15
2 files changed, 32 insertions, 7 deletions
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/activities/ActivityConstructionTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/activities/ActivityConstructionTest.kt
new file mode 100644
index 00000000..bad484ef
--- /dev/null
+++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/activities/ActivityConstructionTest.kt
@@ -0,0 +1,24 @@
+package com.pitchedapps.frost.activities
+
+import android.app.Activity
+import android.os.Bundle
+import androidx.test.core.app.ActivityScenario
+import dagger.hilt.android.testing.HiltAndroidRule
+import dagger.hilt.android.testing.HiltAndroidTest
+import org.junit.Rule
+import org.junit.Test
+
+@HiltAndroidTest
+class ActivityConstructionTest {
+
+ @get:Rule
+ val hiltRule = HiltAndroidRule(this)
+
+ @Test
+ fun imageActivity() {
+ launch<ImageActivity>()
+ }
+
+ private inline fun <reified A : Activity> launch(activityOptions: Bundle? = null) =
+ ActivityScenario.launch(A::class.java, activityOptions)
+} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
index c5b8bdaa..e3b607a3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt
@@ -137,8 +137,9 @@ class ImageActivity : KauBaseActivity() {
lateinit var binding: ActivityImageBinding
private var bottomBehavior: BottomSheetBehavior<View>? = null
- private val baseBackgroundColor = if (prefs.blackMediaBg) Color.BLACK
- else themeProvider.bgColor.withMinAlpha(235)
+ private val baseBackgroundColor: Int
+ get() = if (prefs.blackMediaBg) Color.BLACK
+ else themeProvider.bgColor.withMinAlpha(235)
private fun loadError(e: Throwable) {
if (e.message?.contains("<!DOCTYPE html>") == true) {
@@ -226,11 +227,11 @@ class ImageActivity : KauBaseActivity() {
setState(FabStates.SHARE)
}
imagePhoto.setOnImageEventListener(object :
- SubsamplingScaleImageView.DefaultOnImageEventListener() {
- override fun onImageLoadError(e: Exception) {
- loadError(e)
- }
- })
+ SubsamplingScaleImageView.DefaultOnImageEventListener() {
+ override fun onImageLoadError(e: Exception) {
+ loadError(e)
+ }
+ })
activityThemer.setFrostColors {
themeWindow = false
}