Skip to content

Commit

Permalink
Merge pull request #214 from KovalevAndrey/always-start-test-activity…
Browse files Browse the repository at this point in the history
…-explicitly

Always explicitly start test activity
  • Loading branch information
KovalevAndrey authored Oct 12, 2022
2 parents 2909f7d + 2f0eb4e commit 9a2b3ed
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Pending changes

- [#214](https://github.com/bumble-tech/appyx/pull/214)**Breaking change**: `AppyxViewTestRule` stops supporting automatic launching activity. Activities should be started explicitly in tests.
- [#197](https://github.com/bumble-tech/appyx/pull/197)**Breaking change**: `ParentNodeView` does not implement plugin anymore. Node instance is retrieved via LocalComposition. `AppyxParentViewTestRule` and `AbstractParentNodeView` have been removed.
- [#196](https://github.com/bumble-tech/appyx/pull/196)**Breaking change**: `InteropBuilder` now should be supplied with Appyx `IntegrationPointProvider` to attach it at the same time Appyx Node is created.
- [#185](https://github.com/bumble-tech/appyx/issues/185)**Breaking change**: `Activity` must implement `IntegrationPointProvider` and create `IntegrationPoint` manually. Weak references usage has been removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ import org.junit.runners.model.Statement

open class AppyxViewTestRule<View : NodeView>(
viewFactory: ViewFactory<View>,
private val launchActivity: Boolean = true,
private val composeTestRule: ComposeTestRule = createEmptyComposeRule()
) : ActivityTestRule<AppyxTestActivity>(
/* activityClass = */ AppyxTestActivity::class.java,
/* initialTouchMode = */ true,
/* launchActivity = */ launchActivity
/* launchActivity = */ false
), ComposeTestRule by composeTestRule {

val view by lazy { viewFactory.invoke() }
Expand All @@ -35,9 +34,6 @@ open class AppyxViewTestRule<View : NodeView>(

@Suppress("TooGenericExceptionCaught") // launchActivity does throw RuntimeException
fun start() {
require(!launchActivity) {
"Activity will be launched automatically, launchActivity parameter was passed into constructor"
}
try {
launchActivity(null)
} catch (e: RuntimeException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class MviCoreExampleViewTest {
private var title = "Title"

@get:Rule
val rule = appyxViewRule(launchActivity = false) {
val rule = appyxViewRule {
createView()
}

Expand All @@ -33,7 +33,6 @@ internal class MviCoreExampleViewTest {
with(screen) {
titleText.assert(hasText(title))
loader.assertIsDisplayed()

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package com.bumble.appyx.sandbox.client.test

import com.bumble.appyx.testing.ui.rules.AppyxViewTestRule
import com.bumble.appyx.core.node.NodeView
import com.bumble.appyx.core.node.ViewFactory
import com.bumble.appyx.testing.ui.rules.AppyxViewTestRule
import io.reactivex.ObservableSource
import io.reactivex.functions.Consumer
import io.reactivex.observers.TestObserver

class AppyxMviViewTestRule<ViewModel : Any, Event : Any, View : NodeView>(
launchActivity: Boolean = true,
private val modelConsumer: (View) -> Consumer<in ViewModel>,
private val eventObservable: (View) -> ObservableSource<out Event>,
viewFactory: ViewFactory<View>,
) : AppyxViewTestRule<View>(
launchActivity = launchActivity,
viewFactory = viewFactory,
) {
private lateinit var _modelConsumer: Consumer<in ViewModel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import io.reactivex.ObservableSource
import io.reactivex.functions.Consumer

fun <ViewModel : Any, Event : Any, View> appyxViewRule(
launchActivity: Boolean = true,
viewFactory: ViewFactory<View>,
) where View : NodeView, View : Consumer<in ViewModel>, View : ObservableSource<out Event> =
AppyxMviViewTestRule(
launchActivity = launchActivity,
modelConsumer = { it },
eventObservable = { it },
viewFactory = viewFactory
Expand Down

0 comments on commit 9a2b3ed

Please sign in to comment.