aboutsummaryrefslogtreecommitdiff
path: root/app/src/test/kotlin/com/pitchedapps/frost/internal
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2018-01-18 23:23:56 -0500
committerAllan Wang <me@allanwang.ca>2018-01-20 16:42:37 -0500
commitd766100c297bc094491de150f24c04719ffa8f4e (patch)
treeb69863dace2fcb45d5fd25c276ca450e07305c44 /app/src/test/kotlin/com/pitchedapps/frost/internal
parent78b3cc41e4c9f8d141ad46ee75e476fa2d177f19 (diff)
downloadfrost-d766100c297bc094491de150f24c04719ffa8f4e.tar.gz
frost-d766100c297bc094491de150f24c04719ffa8f4e.tar.bz2
frost-d766100c297bc094491de150f24c04719ffa8f4e.zip
Enhancement/speed up (#650)
* Revert back to m.facebook * Add initial speedup * Update theme * Fix link press for event status * Move web states to fb const * Fix images and email * Fix up flyweight for requests * Ensure frost request is synchronous * Prepare diff utils * Improve speed and fix blank overlay * Update comments * Add debugger and fix searchview * Theme discover pages. Resolves #654 * Fix duplicate reload * Fix image loading * Update changelog * Update tests * Rename test Update dependencies Update gitignore
Diffstat (limited to 'app/src/test/kotlin/com/pitchedapps/frost/internal')
-rw-r--r--app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt38
1 files changed, 37 insertions, 1 deletions
diff --git a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt
index fb2b2a45..2af98eda 100644
--- a/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt
+++ b/app/src/test/kotlin/com/pitchedapps/frost/internal/Internal.kt
@@ -1,13 +1,18 @@
package com.pitchedapps.frost.internal
-import com.pitchedapps.frost.facebook.*
+import com.pitchedapps.frost.facebook.FB_USER_MATCHER
+import com.pitchedapps.frost.facebook.FbItem
+import com.pitchedapps.frost.facebook.get
import com.pitchedapps.frost.facebook.requests.RequestAuth
import com.pitchedapps.frost.facebook.requests.getAuth
import com.pitchedapps.frost.utils.frostJsoup
+import io.reactivex.Completable
import org.junit.Assume
+import org.junit.Test
import java.io.File
import java.io.FileInputStream
import java.util.*
+import java.util.concurrent.TimeUnit
import kotlin.reflect.full.starProjectedType
import kotlin.test.assertEquals
import kotlin.test.assertTrue
@@ -74,4 +79,35 @@ fun Any.assertComponentsNotEmpty() {
fun <T : Comparable<T>> List<T>.assertDescending(tag: String) {
assertEquals(sortedDescending(), this, "$tag not sorted in descending order")
+}
+
+interface CompletableCallback {
+ fun onComplete()
+ fun onError(message: String)
+}
+
+inline fun concurrentTest(crossinline caller: (callback: CompletableCallback) -> Unit) {
+ val result = Completable.create { emitter ->
+ caller(object : CompletableCallback {
+ override fun onComplete() = emitter.onComplete()
+ override fun onError(message: String) = emitter.onError(Throwable(message))
+ })
+ }.blockingGet(5, TimeUnit.SECONDS)
+ if (result != null)
+ throw RuntimeException("Concurrent fail: ${result.message}")
+}
+
+class InternalTest {
+ @Test
+ fun concurrentTest() = try {
+ concurrentTest { result ->
+ Thread().run {
+ Thread.sleep(100)
+ result.onError("Intentional fail")
+ }
+ }
+ fail("Did not throw exception")
+ } catch (e: Exception) {
+ // pass
+ }
} \ No newline at end of file