-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
246 additions
and
72 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
1 change: 0 additions & 1 deletion
1
formula-android/src/test/java/com/instacart/formula/android/FragmentDataClassTest.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
31 changes: 31 additions & 0 deletions
31
formula-android/src/test/java/com/instacart/formula/android/internal/UtilsTest.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.instacart.formula.android.internal | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.google.common.truth.Truth | ||
import io.reactivex.rxjava3.core.Observable | ||
import io.reactivex.rxjava3.schedulers.Schedulers | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class UtilsTest { | ||
|
||
@Test | ||
fun `assertMainThread does nothing on main thread`() { | ||
Truth.assertThat(Utils.isMainThread()).isTrue() | ||
Utils.assertMainThread() | ||
} | ||
|
||
@Test | ||
fun `assertMainThread throws exception when on bg thread`() { | ||
val observer = Observable.fromCallable { | ||
Truth.assertThat(Utils.isMainThread()).isFalse() | ||
runCatching { Utils.assertMainThread() } | ||
}.subscribeOn(Schedulers.newThread()).test() | ||
|
||
observer.awaitCount(1) | ||
Truth.assertThat(observer.values().first().exceptionOrNull()).hasMessageThat().contains( | ||
"should be called on main thread:" | ||
) | ||
} | ||
} |
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
Oops, something went wrong.