diff options
author | Allan Wang <me@allanwang.ca> | 2020-03-01 23:22:58 -0800 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2020-03-01 23:22:58 -0800 |
commit | 2798abf62bd5960abebf6e3b917b9013aa468134 (patch) | |
tree | 31055e3434d6e685a6207ceea7b20ed5edf21dcc /app/src | |
parent | e19c87ae367154bd5bbf59f080eee4976e64e2da (diff) | |
download | frost-2798abf62bd5960abebf6e3b917b9013aa468134.tar.gz frost-2798abf62bd5960abebf6e3b917b9013aa468134.tar.bz2 frost-2798abf62bd5960abebf6e3b917b9013aa468134.zip |
Fix image activity tests
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/androidTest/kotlin/com/pitchedapps/frost/activities/ImageActivityTest.kt | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/app/src/androidTest/kotlin/com/pitchedapps/frost/activities/ImageActivityTest.kt b/app/src/androidTest/kotlin/com/pitchedapps/frost/activities/ImageActivityTest.kt index 5f1735f5..b582baf6 100644 --- a/app/src/androidTest/kotlin/com/pitchedapps/frost/activities/ImageActivityTest.kt +++ b/app/src/androidTest/kotlin/com/pitchedapps/frost/activities/ImageActivityTest.kt @@ -19,6 +19,7 @@ package com.pitchedapps.frost.activities import android.content.Intent import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.rule.ActivityTestRule +import ca.allanwang.kau.utils.isVisible import com.pitchedapps.frost.FrostTestRule import com.pitchedapps.frost.helper.getResource import com.pitchedapps.frost.utils.ARG_COOKIE @@ -44,6 +45,7 @@ import org.junit.rules.RuleChain import org.junit.rules.TestRule import org.junit.rules.Timeout import org.junit.runner.RunWith +import kotlin.test.assertNotNull @RunWith(AndroidJUnit4::class) class ImageActivityTest { @@ -110,11 +112,13 @@ class ImageActivityTest { mockServer.takeRequest() with(activity.activity) { assertEquals(1, mockServer.requestCount, "One http request expected") - assertEquals( - FabStates.DOWNLOAD, - fabAction, - "Image should be successful, image should be downloaded" - ) +// assertEquals( +// FabStates.DOWNLOAD, +// fabAction, +// "Image should be successful, image should be downloaded" +// ) + assertFalse(binding.error.isVisible, "Error should not be shown") + val tempFile = assertNotNull(tempFile, "Temp file not created") assertTrue(tempFile.exists(), "Image should be located at temp file") assertTrue( System.currentTimeMillis() - tempFile.lastModified() < 2000L, @@ -131,13 +135,15 @@ class ImageActivityTest { mockServer.takeRequest() with(activity.activity) { assertEquals(1, mockServer.requestCount, "One http request expected") - assertEquals( - FabStates.ERROR, - fabAction, - "Text should not be a valid image format, error state expected" - ) + assertTrue(binding.error.isVisible, "Error should be shown") + +// assertEquals( +// FabStates.ERROR, +// fabAction, +// "Text should not be a valid image format, error state expected" +// ) assertEquals("Image format not supported", errorRef?.message, "Error message mismatch") - assertFalse(tempFile.exists(), "Temp file should have been removed") + assertFalse(tempFile?.exists() == true, "Temp file should have been removed") } } @@ -147,13 +153,14 @@ class ImageActivityTest { mockServer.takeRequest() with(activity.activity) { assertEquals(1, mockServer.requestCount, "One http request expected") - assertEquals(FabStates.ERROR, fabAction, "Error response code, error state expected") + assertTrue(binding.error.isVisible, "Error should be shown") +// assertEquals(FabStates.ERROR, fabAction, "Error response code, error state expected") assertEquals( "Unsuccessful response for image: Error mock response", errorRef?.message, "Error message mismatch" ) - assertFalse(tempFile.exists(), "Temp file should have been removed") + assertFalse(tempFile?.exists() == true, "Temp file should have been removed") } } } |