Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/make-parent-property-protected' …
Browse files Browse the repository at this point in the history
…into make-parent-property-protected
  • Loading branch information
KovalevAndrey committed Oct 12, 2022
2 parents dc727dc + 19171a7 commit 62436e2
Show file tree
Hide file tree
Showing 23 changed files with 111 additions and 170 deletions.
67 changes: 37 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ name: Build
on:
push:
branches:
- main
- 1.x
- 2.x
pull_request:
workflow_dispatch:

env:
MAIN_BRANCH: ${{ github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x' }}

jobs:
build:
name: Build
Expand All @@ -20,33 +24,35 @@ jobs:
- uses: gradle/wrapper-validation-action@v1
- uses: gradle/gradle-build-action@v2
with:
arguments: |
build
projectHealth
mergeLintSarif
mergeDetektSarif
:plugins:buildPlugins
--continue
# checks integrity of release tasks, update publish workflows too if does not work
- uses: gradle/gradle-build-action@v2
with:
arguments: |
publishAppyxReleasePublicationToOSSRHRepository
publishAppyxReleasePublicationToSonatypeSnapshotRepository
--dry-run
--no-parallel
- uses: gradle/gradle-build-action@v2
if: github.ref == 'refs/heads/main' && github.repository == 'bumble-tech/appyx'
cache-read-only: ${{ env.MAIN_BRANCH != 'true' }}
- name: Build
run: >
./gradlew
build
projectHealth
mergeLintSarif
mergeDetektSarif
:plugins:buildPlugins
--continue
- name: Check publication setup
run: >
./gradlew
publishAppyxReleasePublicationToOSSRHRepository
publishAppyxReleasePublicationToSonatypeSnapshotRepository
--dry-run
--no-parallel
- name: Deploy snapshot
if: env.MAIN_BRANCH == 'true' && github.repository == 'bumble-tech/appyx'
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
with:
arguments: |
publishAppyxReleasePublicationToSonatypeSnapshotRepository
-Psnapshot=true
--no-parallel
-Psigning.password=${{ secrets.SIGNING_PASSWORD }}
-Psonatype.username=${{ secrets.SONATYPE_USERNAME }}
-Psonatype.password=${{ secrets.SONATYPE_PASSWORD }}
run: >
./gradlew
publishAppyxReleasePublicationToSonatypeSnapshotRepository
-Psnapshot=true
--no-parallel
-Psigning.password=${{ secrets.SIGNING_PASSWORD }}
-Psonatype.username=${{ secrets.SONATYPE_USERNAME }}
-Psonatype.password=${{ secrets.SONATYPE_PASSWORD }}
- uses: github/codeql-action/upload-sarif@v2
if: success() || failure()
with:
Expand All @@ -67,18 +73,19 @@ jobs:
instrumentation-tests:
name: Instrumentation tests
runs-on: macOS-latest
timeout-minutes: 60
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- uses: gradle/wrapper-validation-action@v1
- name: Pre build sources before launching emulator
uses: gradle/gradle-build-action@v2
- uses: gradle/gradle-build-action@v2
with:
arguments: compileDebugAndroidTestSources
cache-read-only: ${{ env.MAIN_BRANCH != 'true' }}
- name: Pre build sources before launching emulator
run: ./gradlew compileDebugAndroidTestSources
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy mkdocs to GitHub Pages
on:
push:
branches:
- main
- 1.x
workflow_dispatch:

jobs:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Pending changes

- [#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
- [#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.
- [#173](https://github.com/bumble-tech/appyx/pull/173)**Breaking change**: `ActivityStarter` and `PermissionRequester` now exposes coroutine based API instead of `minimal.reactive`.
- [#200](https://github.com/bumble-tech/appyx/pull/200)**Breaking change**: Reordered the parameters for `ParentNode<NavTarget>.Child` and `fun <N : Node> NodeHost` to meet Compose guidelines.
Expand Down
4 changes: 2 additions & 2 deletions documentation/releases/downloads.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ dependencies {

## Snapshot

Snapshot version is available for all modules, use the provided repository url and `main-SNAPSHOT` version.
Snapshot version is available for all modules, use the provided repository url and `1-SNAPSHOT` version.

```groovy
repositories {
maven { url = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
implementation "com.bumble.appyx:core:main-SNAPSHOT"
implementation "com.bumble.appyx:core:v1-SNAPSHOT"
}
```
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ org.gradle.caching=true
org.gradle.parallel=true
android.useAndroidX=true
kotlin.code.style=official
library.version=1.0-alpha09
library.version=1.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import androidx.test.core.app.ActivityScenario
import com.bumble.appyx.core.integration.NodeFactory
import com.bumble.appyx.core.integration.NodeHost
import com.bumble.appyx.core.node.Node
import com.bumble.appyx.testing.ui.rules.AppyxViewActivity
import com.bumble.appyx.testing.ui.rules.AppyxTestActivity
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit

/**
* [com.bumble.appyx.testing.ui.rules.AppyxTestRule] based on [ActivityScenario] to support lifecycle tests.
* [com.bumble.appyx.testing.ui.rules.AppyxActivityTestRule] based on [ActivityScenario] to support lifecycle tests.
*
* TODO: Consider merging with AppyxTestRule.
*/
Expand All @@ -27,7 +27,7 @@ class AppyxTestScenario<T : Node>(
@get:WorkerThread
val activityScenario: ActivityScenario<BackPressHandlerTestActivity> by lazy {
val awaitNode = CountDownLatch(1)
AppyxViewActivity.composableView = { activity ->
AppyxTestActivity.composableView = { activity ->
decorator {
NodeHost(integrationPoint = activity.appyxIntegrationPoint, factory = { buildContext ->
node = nodeFactory.create(buildContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package com.bumble.appyx.core.plugin
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import androidx.lifecycle.lifecycleScope
import com.bumble.appyx.testing.ui.rules.AppyxViewActivity
import com.bumble.appyx.testing.ui.rules.AppyxTestActivity
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch

class BackPressHandlerTestActivity : AppyxViewActivity() {
class BackPressHandlerTestActivity : AppyxTestActivity() {

private val callback = object : OnBackPressedCallback(handleBackPress.value) {
override fun handleOnBackPressed() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object EmptyNodeView : NodeView {
override fun View(modifier: Modifier) = Unit
}

class EmptyParentNodeView<NavTarget : Any> : AbstractParentNodeView<NavTarget>() {
class EmptyParentNodeView<NavTarget : Any> : ParentNodeView<NavTarget> {

@Composable
override fun ParentNode<NavTarget>.NodeView(modifier: Modifier) = Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import com.bumble.appyx.core.children.nodeOrNull
import com.bumble.appyx.core.composable.ChildRenderer
import com.bumble.appyx.core.lifecycle.ChildNodeLifecycleManager
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.navigation.NavKey
import com.bumble.appyx.core.navigation.NavModel
import com.bumble.appyx.core.navigation.Resolver
import com.bumble.appyx.core.navigation.NavKey
import com.bumble.appyx.core.navigation.isTransitioning
import com.bumble.appyx.core.navigation.model.combined.plus
import com.bumble.appyx.core.navigation.model.permanent.PermanentNavModel
Expand Down Expand Up @@ -57,7 +57,7 @@ abstract class ParentNode<NavTarget : Any>(
) : Node(
view = view,
buildContext = buildContext,
plugins = plugins + navModel + childAware + view
plugins = plugins + navModel + childAware
), Resolver<NavTarget> {

private val permanentNavModel = PermanentNavModel<NavTarget>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@ package com.bumble.appyx.core.node

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.bumble.appyx.core.plugin.NodeAware

interface ParentNodeView<NavTarget : Any> : NodeView, NodeAware<ParentNode<NavTarget>> {
interface ParentNodeView<NavTarget : Any> : NodeView {

@Composable
fun ParentNode<NavTarget>.NodeView(modifier: Modifier)

/**
* Do not override this function. Parent views should implement NodeView method.
*/
@Suppress("UNCHECKED_CAST")
@Composable
override fun View(modifier: Modifier) {
val node = LocalNode.current as? ParentNode<NavTarget>
?: error("${this::class.qualifiedName} is not provided to the appropriate ParentNode")
node.NodeView(modifier = modifier)
}
}
2 changes: 1 addition & 1 deletion libraries/testing-ui-activity/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<application>
<activity
android:name="com.bumble.appyx.testing.ui.rules.AppyxViewActivity"
android:name="com.bumble.appyx.testing.ui.rules.AppyxTestActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import com.bumble.appyx.core.integrationpoint.NodeActivity

open class AppyxViewActivity : NodeActivity() {
open class AppyxTestActivity : NodeActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val composableView = composableView
setContent {
requireNotNull(composableView) { "AppyxViewActivity View has not been setup" }
requireNotNull(composableView) { "AppyxTestActivity View has not been setup" }
composableView(this)
}
}

companion object {
var composableView: (@Composable (activity: AppyxViewActivity) -> Unit)? = null
var composableView: (@Composable (activity: AppyxTestActivity) -> Unit)? = null
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement

open class AppyxTestRule<T : Node>(
open class AppyxActivityTestRule<T : Node>(
private val launchActivity: Boolean = true,
private val composeTestRule: ComposeTestRule = createEmptyComposeRule(),
/** Add decorations like custom theme or CompositionLocalProvider. Do not forget to invoke `content()`. */
private val decorator: (@Composable (content: @Composable () -> Unit) -> Unit) = { content -> content() },
private val nodeFactory: NodeFactory<T>,
) : ActivityTestRule<AppyxViewActivity>(
/* activityClass = */ AppyxViewActivity::class.java,
) : ActivityTestRule<AppyxTestActivity>(
/* activityClass = */ AppyxTestActivity::class.java,
/* initialTouchMode = */ true,
/* launchActivity = */ launchActivity
), ComposeTestRule by composeTestRule {
Expand All @@ -42,7 +42,7 @@ open class AppyxTestRule<T : Node>(
}

override fun beforeActivityLaunched() {
AppyxViewActivity.composableView = { activity ->
AppyxTestActivity.composableView = { activity ->
decorator {
NodeHost(integrationPoint = activity.appyxIntegrationPoint, factory = { buildContext ->
node = nodeFactory.create(buildContext)
Expand All @@ -53,7 +53,7 @@ open class AppyxTestRule<T : Node>(
}

override fun afterActivityLaunched() {
AppyxViewActivity.composableView = null
AppyxTestActivity.composableView = null
}

@CallSuper
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.bumble.appyx.testing.ui.rules

import androidx.annotation.CallSuper
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.junit4.createEmptyComposeRule
import androidx.test.rule.ActivityTestRule
import com.bumble.appyx.core.node.LocalNode
import com.bumble.appyx.core.node.NodeView
import com.bumble.appyx.core.node.ViewFactory
import com.bumble.appyx.testing.ui.utils.DummyParentNode
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
Expand All @@ -15,8 +18,8 @@ open class AppyxViewTestRule<View : NodeView>(
viewFactory: ViewFactory<View>,
private val launchActivity: Boolean = true,
private val composeTestRule: ComposeTestRule = createEmptyComposeRule()
) : ActivityTestRule<AppyxViewActivity>(
/* activityClass = */ AppyxViewActivity::class.java,
) : ActivityTestRule<AppyxTestActivity>(
/* activityClass = */ AppyxTestActivity::class.java,
/* initialTouchMode = */ true,
/* launchActivity = */ launchActivity
), ComposeTestRule by composeTestRule {
Expand Down Expand Up @@ -46,13 +49,17 @@ open class AppyxViewTestRule<View : NodeView>(
}

override fun beforeActivityLaunched() {
AppyxViewActivity.composableView = {
view.View(modifier = Modifier)
AppyxTestActivity.composableView = {
CompositionLocalProvider(
LocalNode provides DummyParentNode<Any>(),
) {
view.View(modifier = Modifier)
}
}
}

override fun afterActivityLaunched() {
AppyxViewActivity.composableView = null
AppyxTestActivity.composableView = null
}

@CallSuper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import com.bumble.appyx.core.navigation.onscreen.OnScreenStateResolver
class DummyNavModel<NavTarget : Any, State> : BaseNavModel<NavTarget, State>(
savedStateMap = null,
finalState = null,
screenResolver = object : OnScreenStateResolver<State> {
override fun isOnScreen(state: State) = true
}
screenResolver = OnScreenStateResolver { true }
) {
override val initialElements: NavElements<NavTarget, State>
get() = emptyList()
Expand Down
Loading

0 comments on commit 62436e2

Please sign in to comment.