Issue#67 Extract runOnUIAwaitOnCurrent into separate module
This commit is contained in:
parent
4932b4b2e0
commit
689aee9702
12 changed files with 74 additions and 6 deletions
|
|
@ -110,6 +110,7 @@ dependencies {
|
|||
androidTestImplementation testFixtures(project(':core'))
|
||||
implementation project(':test-util-shared-robolectric')
|
||||
androidTestImplementation project(':test-util-shared-android')
|
||||
|
||||
implementation project(':test-util-android')
|
||||
androidTestImplementation project(':test-util-android')
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package org.fnives.test.showcase.testutils.idling
|
|||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
||||
import kotlinx.coroutines.test.TestDispatcher
|
||||
import org.fnives.test.showcase.testutils.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.android.testutil.synchronization.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.testutils.storage.TestDatabaseInitialization
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import kotlinx.coroutines.test.StandardTestDispatcher
|
|||
import kotlinx.coroutines.test.TestDispatcher
|
||||
import kotlinx.coroutines.test.resetMain
|
||||
import kotlinx.coroutines.test.setMain
|
||||
import org.fnives.test.showcase.testutils.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.android.testutil.synchronization.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.testutils.storage.TestDatabaseInitialization
|
||||
import org.junit.rules.TestRule
|
||||
import org.junit.runner.Description
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
|||
import androidx.swiperefreshlayout.widget.listener
|
||||
import androidx.test.espresso.UiController
|
||||
import androidx.test.espresso.ViewAction
|
||||
import org.fnives.test.showcase.testutils.runOnUIAwaitOnCurrent
|
||||
import org.fnives.test.showcase.android.testutil.synchronization.runOnUIAwaitOnCurrent
|
||||
import org.hamcrest.BaseMatcher
|
||||
import org.hamcrest.CoreMatchers.isA
|
||||
import org.hamcrest.Description
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ project.ext {
|
|||
def testing_androidx_junit_version = propertyOrNull('androidx_junit_version') ?: "1.1.3"
|
||||
def testing_espresso_version = propertyOrNull('espresso_version') ?: "3.4.0"
|
||||
def testing_androidx_arch_core_version = propertyOrNull('arch_core_version') ?: "2.1.0"
|
||||
def test_coroutines_version = propertyOrNull('coroutines_versionx') ?: "1.6.0"
|
||||
def test_coroutines_version = propertyOrNull('coroutines_version') ?: "1.6.0"
|
||||
def testing_kotlin_mockito_version = propertyOrNull('mockito_version') ?: "3.1.0"
|
||||
def testing_koin_version = propertyOrNull('koin_version') ?: "3.1.2"
|
||||
def testing_json_assert_version = propertyOrNull('json_assert_version') ?: "1.5.0"
|
||||
|
|
|
|||
|
|
@ -6,3 +6,4 @@ include ':network'
|
|||
include ':app'
|
||||
include ':test-util-shared-android'
|
||||
include ':test-util-shared-robolectric'
|
||||
include ':test-util-android'
|
||||
|
|
|
|||
1
test-util-android/.gitignore
vendored
Normal file
1
test-util-android/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/build
|
||||
34
test-util-android/build.gradle
Normal file
34
test-util-android/build.gradle
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk 31
|
||||
|
||||
defaultConfig {
|
||||
minSdk 21
|
||||
targetSdk 31
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '1.8'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"
|
||||
}
|
||||
0
test-util-android/consumer-rules.pro
Normal file
0
test-util-android/consumer-rules.pro
Normal file
21
test-util-android/proguard-rules.pro
vendored
Normal file
21
test-util-android/proguard-rules.pro
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
5
test-util-android/src/main/AndroidManifest.xml
Normal file
5
test-util-android/src/main/AndroidManifest.xml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.fnives.test.showcase.android.testutil">
|
||||
|
||||
</manifest>
|
||||
|
|
@ -1,10 +1,15 @@
|
|||
package org.fnives.test.showcase.testutils
|
||||
package org.fnives.test.showcase.android.testutil.synchronization
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.runBlocking
|
||||
|
||||
/**
|
||||
* Runs the given action on the MainThread and blocks currentThread, until it is completed.
|
||||
*
|
||||
* It is safe to call this from the MainThread.
|
||||
*/
|
||||
fun runOnUIAwaitOnCurrent(action: () -> Unit) {
|
||||
if (Looper.myLooper() === Looper.getMainLooper()) {
|
||||
action()
|
||||
Loading…
Add table
Add a link
Reference in a new issue