mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-1568 App | Tech | Moving calls off main thread when needed (#228)
This commit is contained in:
parent
afdd5bc4f1
commit
fb2a2d4429
29 changed files with 157 additions and 136 deletions
|
@ -6,6 +6,7 @@ import androidx.security.crypto.EncryptedSharedPreferences
|
|||
import androidx.security.crypto.MasterKeys
|
||||
import com.anytypeio.anytype.app.DefaultAppActionManager
|
||||
import com.anytypeio.anytype.app.DefaultMetricsProvider
|
||||
import com.anytypeio.anytype.core_utils.tools.ThreadInfo
|
||||
import com.anytypeio.anytype.data.auth.config.DefaultFeaturesConfigProvider
|
||||
import com.anytypeio.anytype.data.auth.repo.AuthCache
|
||||
import com.anytypeio.anytype.data.auth.repo.AuthCacheDataStore
|
||||
|
@ -216,8 +217,15 @@ object DataModule {
|
|||
service: MiddlewareService,
|
||||
factory: MiddlewareFactory,
|
||||
logger: MiddlewareProtobufLogger,
|
||||
protobufConverter: ProtobufConverterProvider
|
||||
): Middleware = Middleware(service, factory, logger, protobufConverter)
|
||||
protobufConverter: ProtobufConverterProvider,
|
||||
threadInfo: ThreadInfo
|
||||
): Middleware = Middleware(
|
||||
service = service,
|
||||
factory = factory,
|
||||
logger = logger,
|
||||
protobufConverter = protobufConverter,
|
||||
threadInfo = threadInfo
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
|
|
|
@ -4,12 +4,14 @@ import android.content.Context
|
|||
import android.content.SharedPreferences
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.anytypeio.anytype.BuildConfig
|
||||
import com.anytypeio.anytype.app.TogglePrefs
|
||||
import com.anytypeio.anytype.app.DefaultFeatureToggles
|
||||
import com.anytypeio.anytype.app.TogglePrefs
|
||||
import com.anytypeio.anytype.core_utils.tools.AppInfo
|
||||
import com.anytypeio.anytype.core_utils.tools.DefaultAppInfo
|
||||
import com.anytypeio.anytype.core_utils.tools.DefaultThreadInfo
|
||||
import com.anytypeio.anytype.core_utils.tools.DefaultUrlValidator
|
||||
import com.anytypeio.anytype.core_utils.tools.FeatureToggles
|
||||
import com.anytypeio.anytype.core_utils.tools.ThreadInfo
|
||||
import com.anytypeio.anytype.core_utils.tools.UrlValidator
|
||||
import com.anytypeio.anytype.domain.config.Gateway
|
||||
import com.anytypeio.anytype.domain.misc.UrlBuilder
|
||||
|
@ -44,6 +46,10 @@ object UtilModule {
|
|||
@Module
|
||||
interface Bindings {
|
||||
|
||||
@Binds
|
||||
@Singleton
|
||||
fun bindThreadInfo(info: DefaultThreadInfo): ThreadInfo
|
||||
|
||||
@Binds
|
||||
@Singleton
|
||||
fun bindUrlValidator(applicator: DefaultUrlValidator): UrlValidator
|
||||
|
|
|
@ -15,7 +15,6 @@ import android.net.Uri
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
import android.os.Looper
|
||||
import android.provider.MediaStore
|
||||
import android.text.Editable
|
||||
import android.text.InputType
|
||||
|
@ -424,6 +423,4 @@ fun BaseBottomSheetComposeFragment.setupBottomSheetBehavior(paddingTop: Int) {
|
|||
state = BottomSheetBehavior.STATE_EXPANDED
|
||||
skipCollapsed = true
|
||||
}
|
||||
}
|
||||
|
||||
fun isOnMainThread() = Looper.myLooper() == Looper.getMainLooper()
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.anytypeio.anytype.core_utils.tools
|
||||
|
||||
import android.os.Looper
|
||||
import javax.inject.Inject
|
||||
|
||||
interface ThreadInfo {
|
||||
fun isOnMainThread(): Boolean
|
||||
}
|
||||
|
||||
class DefaultThreadInfo @Inject constructor() : ThreadInfo {
|
||||
override fun isOnMainThread(): Boolean {
|
||||
return Looper.myLooper() == Looper.getMainLooper()
|
||||
}
|
||||
}
|
|
@ -92,5 +92,9 @@ abstract class ResultInteractor<in P, R>(
|
|||
* */
|
||||
suspend fun execute(params: P): Resultat<R> = runCatchingL { doWork(params) }
|
||||
|
||||
suspend fun async(params: P): Resultat<R> = withContext(context) {
|
||||
runCatchingL { doWork(params) }
|
||||
}
|
||||
|
||||
protected abstract suspend fun doWork(params: P): R
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package com.anytypeio.anytype.middleware.interactor
|
||||
|
||||
import androidx.annotation.WorkerThread
|
||||
import anytype.Rpc
|
||||
import anytype.model.Block
|
||||
import anytype.model.Range
|
||||
|
@ -30,7 +29,7 @@ import com.anytypeio.anytype.core_models.SearchResult
|
|||
import com.anytypeio.anytype.core_models.Struct
|
||||
import com.anytypeio.anytype.core_models.Url
|
||||
import com.anytypeio.anytype.core_models.WidgetLayout
|
||||
import com.anytypeio.anytype.core_utils.ext.isOnMainThread
|
||||
import com.anytypeio.anytype.core_utils.tools.ThreadInfo
|
||||
import com.anytypeio.anytype.middleware.BuildConfig
|
||||
import com.anytypeio.anytype.middleware.auth.toAccountSetup
|
||||
import com.anytypeio.anytype.middleware.const.Constants
|
||||
|
@ -46,14 +45,15 @@ import com.anytypeio.anytype.middleware.mappers.toMiddlewareModel
|
|||
import com.anytypeio.anytype.middleware.mappers.toPayload
|
||||
import com.anytypeio.anytype.middleware.model.CreateWalletResponse
|
||||
import com.anytypeio.anytype.middleware.service.MiddlewareService
|
||||
import javax.inject.Inject
|
||||
import timber.log.Timber
|
||||
|
||||
@WorkerThread
|
||||
class Middleware(
|
||||
class Middleware @Inject constructor(
|
||||
private val service: MiddlewareService,
|
||||
private val factory: MiddlewareFactory,
|
||||
private val logger: MiddlewareProtobufLogger,
|
||||
private val protobufConverter: ProtobufConverterProvider,
|
||||
private val threadInfo: ThreadInfo
|
||||
) {
|
||||
|
||||
@Throws(Exception::class)
|
||||
|
@ -2210,7 +2210,7 @@ class Middleware(
|
|||
|
||||
private fun logRequest(any: Any) {
|
||||
logger.logRequest(any).also {
|
||||
if (BuildConfig.DEBUG && isOnMainThread()) {
|
||||
if (BuildConfig.DEBUG && threadInfo.isOnMainThread()) {
|
||||
Timber.w("Main thread is used for operation: ${any::class.qualifiedName}")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.anytypeio.anytype.middleware.service
|
||||
|
||||
import androidx.annotation.WorkerThread
|
||||
import anytype.Rpc
|
||||
import com.anytypeio.anytype.core_models.exceptions.AccountIsDeletedException
|
||||
import com.anytypeio.anytype.core_models.exceptions.CreateAccountException
|
||||
|
@ -13,7 +12,6 @@ import com.anytypeio.anytype.data.auth.exception.UndoRedoExhaustedException
|
|||
import javax.inject.Inject
|
||||
import service.Service
|
||||
|
||||
@WorkerThread
|
||||
class MiddlewareServiceImplementation @Inject constructor(
|
||||
featureToggles: FeatureToggles
|
||||
) : MiddlewareService {
|
||||
|
|
|
@ -12,6 +12,8 @@ import com.anytypeio.anytype.middleware.interactor.Middleware
|
|||
import com.anytypeio.anytype.middleware.interactor.MiddlewareFactory
|
||||
import com.anytypeio.anytype.middleware.service.MiddlewareService
|
||||
import com.anytypeio.anytype.test_utils.MockDataFactory
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
|
@ -23,8 +25,6 @@ import org.mockito.kotlin.stub
|
|||
import org.mockito.kotlin.times
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.verifyNoMoreInteractions
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
typealias CBlock = com.anytypeio.anytype.core_models.Block
|
||||
typealias CFields = com.anytypeio.anytype.core_models.Block.Fields
|
||||
|
@ -44,7 +44,13 @@ class MiddlewareTest {
|
|||
@Before
|
||||
fun setup() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
middleware = Middleware(service, factory, mock(), mock())
|
||||
middleware = Middleware(
|
||||
service = service,
|
||||
factory = factory,
|
||||
logger = mock(),
|
||||
protobufConverter = mock(),
|
||||
threadInfo = mock()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -983,7 +983,7 @@ class EditorViewModel(
|
|||
|
||||
val startTime = System.currentTimeMillis()
|
||||
viewModelScope.launch {
|
||||
openPage.execute(id).fold(
|
||||
openPage.async(id).fold(
|
||||
onSuccess = { result ->
|
||||
when (result) {
|
||||
is Result.Success -> {
|
||||
|
@ -1151,7 +1151,7 @@ class EditorViewModel(
|
|||
Session.IDLE -> navigate(EventWrapper(AppNavigation.Command.Exit))
|
||||
Session.OPEN -> {
|
||||
viewModelScope.launch {
|
||||
closePage.execute(context).fold(
|
||||
closePage.async(context).fold(
|
||||
onSuccess = { navigate(EventWrapper(AppNavigation.Command.Exit)) },
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while closing document: $context")
|
||||
|
@ -1169,7 +1169,7 @@ class EditorViewModel(
|
|||
|
||||
private fun exitDashboard() {
|
||||
viewModelScope.launch {
|
||||
closePage.execute(context).fold(
|
||||
closePage.async(context).fold(
|
||||
onSuccess = { navigateToDesktop() },
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while closing this page: $context")
|
||||
|
@ -3122,7 +3122,7 @@ class EditorViewModel(
|
|||
val startTime = System.currentTimeMillis()
|
||||
|
||||
viewModelScope.launch {
|
||||
createBlockLinkWithObject.execute(
|
||||
createBlockLinkWithObject.async(
|
||||
params = params
|
||||
).fold(
|
||||
onFailure = {
|
||||
|
@ -3150,7 +3150,7 @@ class EditorViewModel(
|
|||
|
||||
val startTime = System.currentTimeMillis()
|
||||
jobs += viewModelScope.launch {
|
||||
createObject.execute(CreateObject.Param(type = null))
|
||||
createObject.async(CreateObject.Param(type = null))
|
||||
.fold(
|
||||
onSuccess = { result ->
|
||||
sendAnalyticsObjectCreateEvent(
|
||||
|
@ -4133,7 +4133,7 @@ class EditorViewModel(
|
|||
|
||||
fun proceedWithOpeningObject(target: Id) {
|
||||
viewModelScope.launch {
|
||||
closePage.execute(context).fold(
|
||||
closePage.async(context).fold(
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while closing object")
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenObject(target)))
|
||||
|
@ -4147,7 +4147,7 @@ class EditorViewModel(
|
|||
|
||||
fun proceedWithOpeningDataViewObject(target: Id, isPopUpToDashboard: Boolean = false) {
|
||||
viewModelScope.launch {
|
||||
closePage.execute(context).fold(
|
||||
closePage.async(context).fold(
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while closing object")
|
||||
navigate(
|
||||
|
@ -4299,7 +4299,7 @@ class EditorViewModel(
|
|||
ctx = context,
|
||||
sources = emptyList()
|
||||
)
|
||||
objectToSet.execute(params).fold(
|
||||
objectToSet.async(params).fold(
|
||||
onFailure = { error -> Timber.e(error, "Error convert object to set") },
|
||||
onSuccess = {
|
||||
proceedWithOpeningDataViewObject(target = context, isPopUpToDashboard = true)
|
||||
|
@ -4309,7 +4309,7 @@ class EditorViewModel(
|
|||
|
||||
private suspend fun proceedWithConvertingToCollection() {
|
||||
val params = ConvertObjectToCollection.Params(ctx = context)
|
||||
objectToCollection.execute(params).fold(
|
||||
objectToCollection.async(params).fold(
|
||||
onFailure = { error -> Timber.e(error, "Error convert object to collection") },
|
||||
onSuccess = {
|
||||
proceedWithOpeningDataViewObject(target = context, isPopUpToDashboard = true)
|
||||
|
@ -4807,7 +4807,7 @@ class EditorViewModel(
|
|||
},
|
||||
keys = ObjectSearchConstants.defaultKeysObjectType
|
||||
)
|
||||
getObjectTypes.execute(params).fold(
|
||||
getObjectTypes.async(params).fold(
|
||||
onFailure = { Timber.e(it, "Error while getting library object types") },
|
||||
onSuccess = { types ->
|
||||
val views = types.getObjectTypeViewsForSBPage(
|
||||
|
@ -5656,7 +5656,7 @@ class EditorViewModel(
|
|||
fun onAddMentionNewPageClicked(mentionText: String) {
|
||||
Timber.d("onAddMentionNewPageClicked, mentionText:[$mentionText]")
|
||||
viewModelScope.launch {
|
||||
getDefaultPageType.execute(Unit).fold(
|
||||
getDefaultPageType.async(Unit).fold(
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while getting default object type")
|
||||
proceedWithCreateNewObject(objectType = null, mentionText = mentionText)
|
||||
|
@ -5677,7 +5677,7 @@ class EditorViewModel(
|
|||
val startTime = System.currentTimeMillis()
|
||||
|
||||
viewModelScope.launch {
|
||||
createObjectAsMentionOrLink.execute(
|
||||
createObjectAsMentionOrLink.async(
|
||||
params = params
|
||||
).fold(
|
||||
onFailure = {
|
||||
|
@ -5908,7 +5908,7 @@ class EditorViewModel(
|
|||
},
|
||||
keys = ObjectSearchConstants.defaultKeysObjectType
|
||||
)
|
||||
getObjectTypes.execute(params).fold(
|
||||
getObjectTypes.async(params).fold(
|
||||
onFailure = { Timber.e(it, "Error while getting library object types") },
|
||||
onSuccess = { types ->
|
||||
val views = types.getObjectTypeViewsForSBPage(
|
||||
|
@ -5924,7 +5924,7 @@ class EditorViewModel(
|
|||
}
|
||||
|
||||
private suspend fun proceedWithSortingObjectTypesForObjectTypeWidget(views: List<ObjectTypeView>) {
|
||||
getDefaultPageType.execute(Unit).fold(
|
||||
getDefaultPageType.async(Unit).fold(
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while getting default object type")
|
||||
},
|
||||
|
@ -5986,7 +5986,7 @@ class EditorViewModel(
|
|||
fun proceedToCreateObjectAndAddToTextAsLink(name: String) {
|
||||
Timber.d("proceedToCreateObjectAndAddToTextAsLink, name:[$name]")
|
||||
viewModelScope.launch {
|
||||
getDefaultPageType.execute(Unit).fold(
|
||||
getDefaultPageType.async(Unit).fold(
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while getting default object type")
|
||||
},
|
||||
|
@ -6024,7 +6024,7 @@ class EditorViewModel(
|
|||
private suspend fun createObjectAddProceedToAddToTextAsLink(name: String, type: String?) {
|
||||
val startTime = System.currentTimeMillis()
|
||||
val params = CreateObjectAsMentionOrLink.Params(name, type)
|
||||
createObjectAsMentionOrLink.execute(params).fold(
|
||||
createObjectAsMentionOrLink.async(params).fold(
|
||||
onFailure = { Timber.e(it, "Error while creating new page with params: $params") },
|
||||
onSuccess = { result ->
|
||||
proceedToAddObjectToTextAsLink(id = result.id)
|
||||
|
|
|
@ -103,7 +103,7 @@ class Orchestrator(
|
|||
when (intent) {
|
||||
is Intent.CRUD.Create -> {
|
||||
val startTime = System.currentTimeMillis()
|
||||
createBlock.execute(
|
||||
createBlock.async(
|
||||
params = CreateBlock.Params(
|
||||
context = intent.context,
|
||||
target = intent.target,
|
||||
|
@ -450,7 +450,7 @@ class Orchestrator(
|
|||
)
|
||||
}
|
||||
is Intent.Media.ShareFile -> {
|
||||
documentFileShareDownloader.execute(
|
||||
documentFileShareDownloader.async(
|
||||
params = MiddlewareShareDownloader.Params(
|
||||
hash = intent.hash,
|
||||
name = intent.name
|
||||
|
|
|
@ -335,7 +335,7 @@ class HomeScreenViewModel(
|
|||
|
||||
private fun proceedWithClosingWidgetObject(widgetObject: Id) {
|
||||
viewModelScope.launch {
|
||||
saveWidgetSession.execute(
|
||||
saveWidgetSession.async(
|
||||
SaveWidgetSession.Params(
|
||||
WidgetSession(
|
||||
collapsed = collapsedWidgetStateHolder.get(),
|
||||
|
@ -875,7 +875,7 @@ class HomeScreenViewModel(
|
|||
if (!isWidgetSessionRestored) {
|
||||
viewModelScope.launch {
|
||||
val session = withContext(appCoroutineDispatchers.io) {
|
||||
getWidgetSession.execute(Unit).getOrNull()
|
||||
getWidgetSession.async(Unit).getOrNull()
|
||||
}
|
||||
if (session != null) {
|
||||
collapsedWidgetStateHolder.set(session.collapsed)
|
||||
|
@ -984,7 +984,7 @@ class HomeScreenViewModel(
|
|||
|
||||
private fun proceedWithSettingUpShortcuts() {
|
||||
viewModelScope.launch {
|
||||
getDefaultPageType.execute(Unit).fold(
|
||||
getDefaultPageType.async(Unit).fold(
|
||||
onSuccess = {
|
||||
Pair(it.name, it.type).letNotNull { name, type ->
|
||||
appActionManager.setup(
|
||||
|
|
|
@ -121,7 +121,7 @@ open class ObjectSearchViewModel(
|
|||
),
|
||||
keys = ObjectSearchConstants.defaultKeysObjectType
|
||||
)
|
||||
getObjectTypes.execute(params).fold(
|
||||
getObjectTypes.async(params).fold(
|
||||
onFailure = { Timber.e(it, "Error while getting object types") },
|
||||
onSuccess = {
|
||||
types.value = Resultat.success(it)
|
||||
|
|
|
@ -5,7 +5,6 @@ import androidx.lifecycle.ViewModel
|
|||
import androidx.lifecycle.viewModelScope
|
||||
import com.anytypeio.anytype.analytics.base.Analytics
|
||||
import com.anytypeio.anytype.analytics.base.EventsDictionary
|
||||
import com.anytypeio.anytype.analytics.base.sendEvent
|
||||
import com.anytypeio.anytype.core_models.DVViewer
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
|
@ -556,7 +555,7 @@ class ObjectSetViewModel(
|
|||
}
|
||||
|
||||
private suspend fun proceedWithClosingAndExit() {
|
||||
closeBlock.execute(context).fold(
|
||||
closeBlock.async(context).fold(
|
||||
onSuccess = { dispatch(AppNavigation.Command.Exit) },
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while closing object set: $context").also {
|
||||
|
@ -902,7 +901,7 @@ class ObjectSetViewModel(
|
|||
) {
|
||||
val startTime = System.currentTimeMillis()
|
||||
viewModelScope.launch {
|
||||
createDataViewObject.execute(params).fold(
|
||||
createDataViewObject.async(params).fold(
|
||||
onFailure = { Timber.e(it, "Error while creating new record") },
|
||||
onSuccess = { result ->
|
||||
proceedWithNewDataViewObject(params, result.objectId)
|
||||
|
@ -1105,7 +1104,7 @@ class ObjectSetViewModel(
|
|||
private suspend fun proceedWithOpeningObject(target: Id) {
|
||||
isCustomizeViewPanelVisible.value = false
|
||||
jobs += viewModelScope.launch {
|
||||
closeBlock.execute(context).fold(
|
||||
closeBlock.async(context).fold(
|
||||
onSuccess = {
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenObject(id = target)))
|
||||
},
|
||||
|
@ -1120,7 +1119,7 @@ class ObjectSetViewModel(
|
|||
private suspend fun proceedWithOpeningObjectCollection(target: Id) {
|
||||
isCustomizeViewPanelVisible.value = false
|
||||
jobs += viewModelScope.launch {
|
||||
closeBlock.execute(context).fold(
|
||||
closeBlock.async(context).fold(
|
||||
onSuccess = {
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenSetOrCollection(target = target)))
|
||||
},
|
||||
|
@ -1142,7 +1141,7 @@ class ObjectSetViewModel(
|
|||
ObjectType.Layout.FILE,
|
||||
ObjectType.Layout.BOOKMARK -> proceedWithOpeningObject(target)
|
||||
ObjectType.Layout.SET, ObjectType.Layout.COLLECTION -> {
|
||||
closeBlock.execute(context).fold(
|
||||
closeBlock.async(context).fold(
|
||||
onSuccess = {
|
||||
navigate(EventWrapper(AppNavigation.Command.OpenSetOrCollection(target)))
|
||||
},
|
||||
|
@ -1174,7 +1173,7 @@ class ObjectSetViewModel(
|
|||
|
||||
fun onHomeButtonClicked() {
|
||||
viewModelScope.launch {
|
||||
closeBlock.execute(context).fold(
|
||||
closeBlock.async(context).fold(
|
||||
onSuccess = { dispatch(AppNavigation.Command.ExitToDesktop) },
|
||||
onFailure = {
|
||||
Timber.e(it, "Error while closing object set: $context").also {
|
||||
|
@ -1194,7 +1193,7 @@ class ObjectSetViewModel(
|
|||
|
||||
val startTime = System.currentTimeMillis()
|
||||
jobs += viewModelScope.launch {
|
||||
createObject.execute(CreateObject.Param(type = null)).fold(
|
||||
createObject.async(CreateObject.Param(type = null)).fold(
|
||||
onSuccess = { result ->
|
||||
proceedWithOpeningObject(result.objectId)
|
||||
sendAnalyticsObjectCreateEvent(
|
||||
|
@ -1229,7 +1228,7 @@ class ObjectSetViewModel(
|
|||
|
||||
fun onSearchButtonClicked() {
|
||||
viewModelScope.launch {
|
||||
closeBlock.execute(context).fold(
|
||||
closeBlock.async(context).fold(
|
||||
onSuccess = { dispatch(AppNavigation.Command.OpenPageSearch) },
|
||||
onFailure = { Timber.e(it, "Error while closing object set: $context") }
|
||||
)
|
||||
|
|
|
@ -66,13 +66,13 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
objectId = newObjectId,
|
||||
objectType = ObjectTypeIds.NOTE
|
||||
)
|
||||
doReturn(Resultat.success(result)).`when`(createDataViewObject).execute(
|
||||
doReturn(Resultat.success(result)).`when`(createDataViewObject).async(
|
||||
CreateDataViewObject.Params.SetByType(
|
||||
type = ObjectTypeIds.NOTE,
|
||||
filters = mockObjectSet.filters
|
||||
)
|
||||
)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).execute(mockObjectSet.root)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
|
@ -84,7 +84,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
advanceUntilIdle()
|
||||
|
||||
verifyBlocking(createDataViewObject, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
CreateDataViewObject.Params.SetByType(
|
||||
type = ObjectTypeIds.NOTE,
|
||||
filters = mockObjectSet.filters
|
||||
|
@ -92,7 +92,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
}
|
||||
|
||||
verifyBlocking(closeBlock, times(1)) { execute(mockObjectSet.root)}
|
||||
verifyBlocking(closeBlock, times(1)) { async(mockObjectSet.root)}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -122,13 +122,13 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
objectId = newObjectId,
|
||||
objectType = ObjectTypeIds.PAGE
|
||||
)
|
||||
doReturn(Resultat.success(result)).`when`(createDataViewObject).execute(
|
||||
doReturn(Resultat.success(result)).`when`(createDataViewObject).async(
|
||||
CreateDataViewObject.Params.SetByType(
|
||||
type = ObjectTypeIds.PAGE,
|
||||
filters = mockObjectSet.filters
|
||||
)
|
||||
)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).execute(mockObjectSet.root)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
|
@ -143,7 +143,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
advanceUntilIdle()
|
||||
|
||||
verifyBlocking(createDataViewObject, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
CreateDataViewObject.Params.SetByType(
|
||||
type = ObjectTypeIds.PAGE,
|
||||
filters = mockObjectSet.filters
|
||||
|
@ -181,13 +181,13 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
objectId = newObjectId,
|
||||
objectType = ObjectTypeIds.NOTE
|
||||
)
|
||||
doReturn(Resultat.success(result)).`when`(createDataViewObject).execute(
|
||||
doReturn(Resultat.success(result)).`when`(createDataViewObject).async(
|
||||
CreateDataViewObject.Params.SetByRelation(
|
||||
relations = listOf(mockObjectSet.relationObject3.id),
|
||||
filters = mockObjectSet.filters
|
||||
)
|
||||
)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).execute(mockObjectSet.root)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
|
@ -199,7 +199,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
advanceUntilIdle()
|
||||
|
||||
verifyBlocking(createDataViewObject, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
CreateDataViewObject.Params.SetByRelation(
|
||||
relations = listOf(mockObjectSet.relationObject3.id),
|
||||
filters = mockObjectSet.filters
|
||||
|
@ -207,7 +207,7 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
)
|
||||
}
|
||||
|
||||
verifyBlocking(closeBlock, times(1)) { execute(mockObjectSet.root)}
|
||||
verifyBlocking(closeBlock, times(1)) { async(mockObjectSet.root)}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -243,10 +243,10 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
objectId = newObjectId,
|
||||
objectType = ObjectTypeIds.NOTE
|
||||
)
|
||||
doReturn(Resultat.success(result)).`when`(createDataViewObject).execute(
|
||||
doReturn(Resultat.success(result)).`when`(createDataViewObject).async(
|
||||
CreateDataViewObject.Params.Collection
|
||||
)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).execute(objectCollection.root)
|
||||
doReturn(Resultat.success(Unit)).`when`(closeBlock).async(objectCollection.root)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
|
@ -258,9 +258,9 @@ class ObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
advanceUntilIdle()
|
||||
|
||||
verifyBlocking(createDataViewObject, times(1)) {
|
||||
execute(CreateDataViewObject.Params.Collection)
|
||||
async(CreateDataViewObject.Params.Collection)
|
||||
}
|
||||
|
||||
verifyBlocking(closeBlock, times(1)) { execute(objectCollection.root)}
|
||||
verifyBlocking(closeBlock, times(1)) { async(objectCollection.root)}
|
||||
}
|
||||
}
|
|
@ -90,7 +90,6 @@ import com.anytypeio.anytype.domain.unsplash.UnsplashRepository
|
|||
import com.anytypeio.anytype.domain.workspace.FileLimitsEventChannel
|
||||
import com.anytypeio.anytype.domain.workspace.InterceptFileLimitEvents
|
||||
import com.anytypeio.anytype.domain.workspace.WorkspaceManager
|
||||
import com.anytypeio.anytype.presentation.BuildConfig
|
||||
import com.anytypeio.anytype.presentation.MockBlockFactory
|
||||
import com.anytypeio.anytype.presentation.common.Action
|
||||
import com.anytypeio.anytype.presentation.common.Delegator
|
||||
|
@ -410,7 +409,7 @@ open class EditorViewModelTest {
|
|||
|
||||
vm.onStart(root)
|
||||
|
||||
runBlockingTest { verify(openPage, times(1)).execute(param) }
|
||||
runBlockingTest { verify(openPage, times(1)).async(param) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -489,7 +488,7 @@ open class EditorViewModelTest {
|
|||
vm.onSystemBackPressed(editorHasChildrenScreens = false)
|
||||
|
||||
runBlockingTest {
|
||||
verify(closePage, times(1)).execute(any())
|
||||
verify(closePage, times(1)).async(any())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -753,7 +752,7 @@ open class EditorViewModelTest {
|
|||
vm.onAddTextBlockClicked(style = Block.Content.Text.Style.P)
|
||||
|
||||
runBlockingTest {
|
||||
verify(createBlock, times(1)).execute(any())
|
||||
verify(createBlock, times(1)).async(any())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2096,7 +2095,7 @@ open class EditorViewModelTest {
|
|||
)
|
||||
|
||||
runBlockingTest {
|
||||
verify(createBlock, times(1)).execute(
|
||||
verify(createBlock, times(1)).async(
|
||||
params = eq(
|
||||
CreateBlock.Params(
|
||||
context = root,
|
||||
|
@ -2228,7 +2227,7 @@ open class EditorViewModelTest {
|
|||
)
|
||||
|
||||
runBlockingTest {
|
||||
verify(createBlock, times(1)).execute(
|
||||
verify(createBlock, times(1)).async(
|
||||
params = eq(
|
||||
CreateBlock.Params(
|
||||
context = root,
|
||||
|
@ -2558,7 +2557,7 @@ open class EditorViewModelTest {
|
|||
vm.startSharingFile(id = file.id)
|
||||
|
||||
runTest {
|
||||
verify(documentFileShareDownloader, times(1)).execute(
|
||||
verify(documentFileShareDownloader, times(1)).async(
|
||||
params = eq(
|
||||
MiddlewareShareDownloader.Params(
|
||||
name = file.content<Block.Content.File>().name.orEmpty(),
|
||||
|
@ -2806,7 +2805,7 @@ open class EditorViewModelTest {
|
|||
vm.proceedWithExitingBack()
|
||||
|
||||
runBlockingTest {
|
||||
verify(closePage, times(1)).execute(
|
||||
verify(closePage, times(1)).async(
|
||||
params = eq(root)
|
||||
)
|
||||
}
|
||||
|
@ -3608,7 +3607,7 @@ open class EditorViewModelTest {
|
|||
objectRestrictions: List<ObjectRestriction> = emptyList()
|
||||
) {
|
||||
openPage.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(
|
||||
onBlocking { async(any()) } doReturn Resultat.success(
|
||||
Result.Success(
|
||||
Payload(
|
||||
context = root,
|
||||
|
@ -3633,12 +3632,12 @@ open class EditorViewModelTest {
|
|||
) {
|
||||
|
||||
closePage.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(Unit)
|
||||
onBlocking { async(any()) } doReturn Resultat.success(Unit)
|
||||
}
|
||||
|
||||
exception?.let {
|
||||
closePage.stub {
|
||||
onBlocking { execute(any()) } doAnswer { invocationOnMock -> throw exception }
|
||||
onBlocking { async(any()) } doAnswer { invocationOnMock -> throw exception }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3662,7 +3661,7 @@ open class EditorViewModelTest {
|
|||
events: List<Event> = emptyList()
|
||||
) {
|
||||
openPage.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(
|
||||
onBlocking { async(any()) } doReturn Resultat.success(
|
||||
Result.Success(
|
||||
Payload(
|
||||
context = context,
|
||||
|
@ -3722,7 +3721,7 @@ open class EditorViewModelTest {
|
|||
|
||||
private fun stubCreateBlock(root: String) {
|
||||
createBlock.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(
|
||||
onBlocking { async(any()) } doReturn Resultat.success(
|
||||
Pair(
|
||||
MockDataFactory.randomString(), Payload(
|
||||
context = root,
|
||||
|
@ -3747,7 +3746,7 @@ open class EditorViewModelTest {
|
|||
|
||||
private fun givenSharedFile() {
|
||||
documentFileShareDownloader.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(Uri.EMPTY)
|
||||
onBlocking { async(any()) } doReturn Resultat.success(Uri.EMPTY)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4368,7 +4367,7 @@ open class EditorViewModelTest {
|
|||
|
||||
private fun givenDelegateId(id: String) {
|
||||
createObject.stub {
|
||||
onBlocking { execute(CreateObject.Param(null)) } doReturn Resultat.success(
|
||||
onBlocking { async(CreateObject.Param(null)) } doReturn Resultat.success(
|
||||
CreateObject.Result(
|
||||
objectId = id,
|
||||
event = Payload(
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package com.anytypeio.anytype.presentation.editor.editor
|
||||
|
||||
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
|
||||
import com.anytypeio.anytype.domain.page.CloseBlock
|
||||
import com.anytypeio.anytype.presentation.MockTypicalDocumentFactory
|
||||
import com.anytypeio.anytype.presentation.util.CoroutinesTestRule
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mockito.MockitoAnnotations
|
||||
import org.mockito.kotlin.times
|
||||
import org.mockito.kotlin.verifyBlocking
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
class EditorBackButtonTest : EditorPresentationTestSetup() {
|
||||
|
||||
|
@ -51,6 +50,6 @@ class EditorBackButtonTest : EditorPresentationTestSetup() {
|
|||
|
||||
assertTrue(stateBackPressed?.styleTextToolbar?.isVisible == false)
|
||||
|
||||
verifyBlocking(closePage, times(1)) { execute(root) }
|
||||
verifyBlocking(closePage, times(1)) { async(root) }
|
||||
}
|
||||
}
|
|
@ -80,7 +80,7 @@ class EditorCreateBlockTest : EditorPresentationTestSetup() {
|
|||
)
|
||||
|
||||
//VERIFY
|
||||
verify(createBlock, times(1)).execute(
|
||||
verify(createBlock, times(1)).async(
|
||||
params = eq(
|
||||
CreateBlock.Params(
|
||||
context = root,
|
||||
|
|
|
@ -91,7 +91,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
vm.onOutsideClicked()
|
||||
|
||||
verifyBlocking(createBlock, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
params = eq(
|
||||
CreateBlock.Params(
|
||||
context = root,
|
||||
|
@ -144,7 +144,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
vm.onOutsideClicked()
|
||||
|
||||
verifyBlocking(createBlock, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
params = eq(
|
||||
CreateBlock.Params(
|
||||
context = root,
|
||||
|
@ -191,7 +191,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
vm.onOutsideClicked()
|
||||
|
||||
verifyBlocking(createBlock, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
params = eq(
|
||||
CreateBlock.Params(
|
||||
target = "",
|
||||
|
@ -340,7 +340,7 @@ class EditorEmptySpaceInteractionTest : EditorPresentationTestSetup() {
|
|||
vm.onOutsideClicked()
|
||||
|
||||
verifyBlocking(createBlock, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
params = eq(
|
||||
CreateBlock.Params(
|
||||
target = "",
|
||||
|
|
|
@ -14,7 +14,6 @@ import com.anytypeio.anytype.domain.base.Resultat
|
|||
import com.anytypeio.anytype.domain.event.interactor.InterceptEvents
|
||||
import com.anytypeio.anytype.domain.icon.DocumentEmojiIconProvider
|
||||
import com.anytypeio.anytype.domain.page.CreateObjectAsMentionOrLink
|
||||
import com.anytypeio.anytype.presentation.BuildConfig
|
||||
import com.anytypeio.anytype.presentation.editor.EditorViewModel
|
||||
import com.anytypeio.anytype.presentation.editor.editor.control.ControlPanelState
|
||||
import com.anytypeio.anytype.presentation.editor.editor.mention.MentionConst.MENTION_TITLE_EMPTY
|
||||
|
@ -320,7 +319,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
createObjectAsMentionOrLink.stub {
|
||||
onBlocking {
|
||||
execute(
|
||||
async(
|
||||
CreateObjectAsMentionOrLink.Params(
|
||||
name = newPageName,
|
||||
type = ObjectTypeIds.NOTE
|
||||
|
@ -359,7 +358,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
}
|
||||
|
||||
verifyBlocking(createObjectAsMentionOrLink, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
CreateObjectAsMentionOrLink.Params(
|
||||
name = newPageName,
|
||||
type = ObjectTypeIds.NOTE
|
||||
|
@ -484,7 +483,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
|
||||
createObjectAsMentionOrLink.stub {
|
||||
onBlocking {
|
||||
execute(
|
||||
async(
|
||||
CreateObjectAsMentionOrLink.Params(
|
||||
name = newPageName,
|
||||
type = "_otarticle"
|
||||
|
@ -523,7 +522,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
}
|
||||
|
||||
verifyBlocking(createObjectAsMentionOrLink, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
CreateObjectAsMentionOrLink.Params(
|
||||
name = newPageName,
|
||||
type = "_otarticle"
|
||||
|
@ -860,7 +859,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
val params = InterceptEvents.Params(context = root)
|
||||
|
||||
openPage.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(
|
||||
onBlocking { async(any()) } doReturn Resultat.success(
|
||||
Result.Success(
|
||||
Payload(
|
||||
context = root,
|
||||
|
@ -1003,7 +1002,7 @@ class EditorMentionTest : EditorPresentationTestSetup() {
|
|||
val params = InterceptEvents.Params(context = root)
|
||||
|
||||
openPage.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(
|
||||
onBlocking { async(any()) } doReturn Resultat.success(
|
||||
Result.Success(
|
||||
Payload(
|
||||
context = root,
|
||||
|
|
|
@ -479,7 +479,7 @@ open class EditorPresentationTestSetup {
|
|||
relationLinks: List<RelationLink> = emptyList()
|
||||
) {
|
||||
openPage.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(
|
||||
onBlocking { async(any()) } doReturn Resultat.success(
|
||||
Result.Success(
|
||||
Payload(
|
||||
context = root,
|
||||
|
@ -570,17 +570,9 @@ open class EditorPresentationTestSetup {
|
|||
}
|
||||
}
|
||||
|
||||
fun stubTurnIntoDocument(
|
||||
params: TurnIntoDocument.Params = any()
|
||||
) {
|
||||
turnIntoDocument.stub {
|
||||
onBlocking { invoke(params) } doReturn Either.Right(emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
fun stubCreateBlock(root: String) {
|
||||
createBlock.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(
|
||||
onBlocking { async(any()) } doReturn Resultat.success(
|
||||
Pair(
|
||||
MockDataFactory.randomString(), Payload(
|
||||
context = root,
|
||||
|
@ -606,7 +598,7 @@ open class EditorPresentationTestSetup {
|
|||
fun stubCreateBlockLinkWithObject(root: String, target: String) {
|
||||
createBlockLinkWithObject.stub {
|
||||
onBlocking {
|
||||
execute(any())
|
||||
async(any())
|
||||
} doReturn Resultat.success(
|
||||
CreateBlockLinkWithObject.Result(
|
||||
id = root,
|
||||
|
@ -652,7 +644,7 @@ open class EditorPresentationTestSetup {
|
|||
|
||||
fun stubClosePage() {
|
||||
closePage.stub {
|
||||
onBlocking { execute(any()) } doReturn Resultat.success(Unit)
|
||||
onBlocking { async(any()) } doReturn Resultat.success(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -711,7 +703,7 @@ open class EditorPresentationTestSetup {
|
|||
|
||||
fun stubGetDefaultObjectType(type: String? = null, name: String? = null) {
|
||||
getDefaultPageType.stub {
|
||||
onBlocking { execute(Unit) } doReturn Resultat.success(
|
||||
onBlocking { async(Unit) } doReturn Resultat.success(
|
||||
GetDefaultPageType.Response(
|
||||
type,
|
||||
name
|
||||
|
@ -724,7 +716,7 @@ open class EditorPresentationTestSetup {
|
|||
val params = CreateObjectAsMentionOrLink.Params(name, type)
|
||||
val result = CreateObjectAsMentionOrLink.Result(id, name)
|
||||
createObjectAsMentionOrLink.stub {
|
||||
onBlocking { execute(params) } doReturn Resultat.success(result)
|
||||
onBlocking { async(params) } doReturn Resultat.success(result)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,7 +742,7 @@ open class EditorPresentationTestSetup {
|
|||
fun stubGetObjectTypes(types: List<ObjectWrapper.Type>) {
|
||||
getObjectTypes.stub {
|
||||
onBlocking {
|
||||
execute(any())
|
||||
async(any())
|
||||
} doReturn Resultat.success(types)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ class EditorSlashWidgetObjectTypeTest : EditorPresentationTestSetup() {
|
|||
type = type2.id
|
||||
)
|
||||
|
||||
verifyBlocking(createBlockLinkWithObject, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlockLinkWithObject, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -143,6 +143,6 @@ class EditorSlashWidgetObjectTypeTest : EditorPresentationTestSetup() {
|
|||
type = type2.id
|
||||
)
|
||||
|
||||
verifyBlocking(createBlockLinkWithObject, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlockLinkWithObject, times(1)) { async(params) }
|
||||
}
|
||||
}
|
|
@ -139,7 +139,7 @@ class EditorSlashWidgetRelationsTest: EditorPresentationTestSetup() {
|
|||
prototype = Block.Prototype.Relation(key = r2.key)
|
||||
)
|
||||
|
||||
verifyBlocking(createBlock, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlock, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -277,7 +277,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION)
|
||||
|
||||
verifyBlocking(createBlock, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
params = eq(
|
||||
CreateBlock.Params(
|
||||
context = root,
|
||||
|
@ -450,7 +450,7 @@ class EditorSplitTest : EditorPresentationTestSetup() {
|
|||
coroutineTestRule.advanceTime(EditorViewModel.TEXT_CHANGES_DEBOUNCE_DURATION)
|
||||
|
||||
verifyBlocking(createBlock, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
params = eq(
|
||||
CreateBlock.Params(
|
||||
context = root,
|
||||
|
|
|
@ -116,7 +116,7 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() {
|
|||
target = block.id
|
||||
)
|
||||
)
|
||||
inOrder.verify(closePage, times(1)).execute(root)
|
||||
inOrder.verify(closePage, times(1)).async(root)
|
||||
}
|
||||
|
||||
// RELEASING PENDING COROUTINES
|
||||
|
@ -191,7 +191,7 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() {
|
|||
vm.onHomeButtonClicked()
|
||||
|
||||
verifyBlocking(closePage, times(1)) {
|
||||
execute(root)
|
||||
async(root)
|
||||
}
|
||||
|
||||
verifyNoMoreInteractions(updateText)
|
||||
|
@ -261,7 +261,7 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() {
|
|||
target = block.id
|
||||
)
|
||||
)
|
||||
inOrder.verify(closePage, times(1)).execute(
|
||||
inOrder.verify(closePage, times(1)).async(
|
||||
root
|
||||
)
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ class EditorTextUpdateTest : EditorPresentationTestSetup() {
|
|||
vm.onSystemBackPressed(false)
|
||||
|
||||
verifyBlocking(closePage, times(1)) {
|
||||
execute(root)
|
||||
async(root)
|
||||
}
|
||||
|
||||
verifyNoMoreInteractions(updateText)
|
||||
|
|
|
@ -92,7 +92,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() {
|
|||
onAddTextBlockClicked(style)
|
||||
}
|
||||
|
||||
verifyBlocking(createBlock, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlock, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -147,7 +147,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() {
|
|||
onAddTextBlockClicked(style)
|
||||
}
|
||||
|
||||
verifyBlocking(createBlock, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlock, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -195,7 +195,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() {
|
|||
onAddFileBlockClicked(type = type)
|
||||
}
|
||||
|
||||
verifyBlocking(createBlock, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlock, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -254,7 +254,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() {
|
|||
onAddFileBlockClicked(type = type)
|
||||
}
|
||||
|
||||
verifyBlocking(createBlock, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlock, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -295,7 +295,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() {
|
|||
onAddBookmarkBlockClicked()
|
||||
}
|
||||
|
||||
verifyBlocking(createBlock, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlock, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -347,7 +347,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() {
|
|||
onAddBookmarkBlockClicked()
|
||||
}
|
||||
|
||||
verifyBlocking(createBlock, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlock, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -388,7 +388,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() {
|
|||
onAddDividerBlockClicked(style = Block.Content.Divider.Style.LINE)
|
||||
}
|
||||
|
||||
verifyBlocking(createBlock, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlock, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -440,7 +440,7 @@ class EditorTitleAddBlockTest : EditorPresentationTestSetup() {
|
|||
onAddDividerBlockClicked(style = Block.Content.Divider.Style.LINE)
|
||||
}
|
||||
|
||||
verifyBlocking(createBlock, times(1)) { execute(params) }
|
||||
verifyBlocking(createBlock, times(1)) { async(params) }
|
||||
}
|
||||
|
||||
private fun stubCreateBlock(
|
||||
|
|
|
@ -252,7 +252,7 @@ class HomeScreenViewModelTest {
|
|||
) {
|
||||
getWidgetSession.stub {
|
||||
onBlocking {
|
||||
execute(any())
|
||||
async(any())
|
||||
} doReturn Resultat.Success(session)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class ObjectSetDataViewObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
dvFilters = mockObjectSet.filters,
|
||||
objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2)
|
||||
)
|
||||
doReturn(Unit).`when`(createDataViewObject).execute(
|
||||
doReturn(Unit).`when`(createDataViewObject).async(
|
||||
CreateDataViewObject.Params.SetByType(
|
||||
type = mockObjectSet.setOf,
|
||||
filters = mockObjectSet.filters
|
||||
|
@ -76,7 +76,7 @@ class ObjectSetDataViewObjectCreateTest : ObjectSetViewModelTestSetup() {
|
|||
|
||||
advanceUntilIdle()
|
||||
verifyBlocking(createDataViewObject, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
CreateDataViewObject.Params.SetByType(
|
||||
type = mockObjectSet.setOf,
|
||||
filters = mockObjectSet.filters
|
||||
|
|
|
@ -188,7 +188,7 @@ class ObjectSetNavigationTest : ObjectSetViewModelTestSetup() {
|
|||
dvFilters = mockObjectSet.filters
|
||||
)
|
||||
|
||||
doReturn(Unit).`when`(closeBlock).execute(mockObjectSet.root)
|
||||
doReturn(Unit).`when`(closeBlock).async(mockObjectSet.root)
|
||||
|
||||
// TESTING
|
||||
viewModel.onStart(ctx = root)
|
||||
|
@ -207,7 +207,7 @@ class ObjectSetNavigationTest : ObjectSetViewModelTestSetup() {
|
|||
// CHECK CLOSE BLOCK COMMAND
|
||||
advanceUntilIdle()
|
||||
verifyBlocking(closeBlock, times(1)) {
|
||||
execute(mockObjectSet.root)
|
||||
async(mockObjectSet.root)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class SetByRelationTest : ObjectSetViewModelTestSetup() {
|
|||
objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2),
|
||||
dvFilters = mockObjectSet.filters
|
||||
)
|
||||
doReturn(Unit).`when`(createDataViewObject).execute(
|
||||
doReturn(Unit).`when`(createDataViewObject).async(
|
||||
CreateDataViewObject.Params.SetByType(
|
||||
type = mockObjectSet.setOf,
|
||||
filters = mockObjectSet.filters
|
||||
|
@ -80,7 +80,7 @@ class SetByRelationTest : ObjectSetViewModelTestSetup() {
|
|||
|
||||
advanceUntilIdle()
|
||||
verifyBlocking(createDataViewObject, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
CreateDataViewObject.Params.SetByType(
|
||||
type = mockObjectSet.setOf,
|
||||
filters = mockObjectSet.filters
|
||||
|
@ -111,7 +111,7 @@ class SetByRelationTest : ObjectSetViewModelTestSetup() {
|
|||
objects = listOf(mockObjectSet.obj1, mockObjectSet.obj2),
|
||||
dvFilters = mockObjectSet.filters
|
||||
)
|
||||
doReturn(Unit).`when`(createDataViewObject).execute(
|
||||
doReturn(Unit).`when`(createDataViewObject).async(
|
||||
CreateDataViewObject.Params.SetByRelation(
|
||||
relations = listOf(mockObjectSet.relationObject3.id),
|
||||
filters = mockObjectSet.filters
|
||||
|
@ -133,7 +133,7 @@ class SetByRelationTest : ObjectSetViewModelTestSetup() {
|
|||
|
||||
advanceUntilIdle()
|
||||
verifyBlocking(createDataViewObject, times(1)) {
|
||||
execute(
|
||||
async(
|
||||
CreateDataViewObject.Params.SetByRelation(
|
||||
relations = listOf(mockObjectSet.relationObject3.id),
|
||||
filters = mockObjectSet.filters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue