Skip to content

Commit

Permalink
Deprecate FragmentContract and Integration. (#279)
Browse files Browse the repository at this point in the history
* Deprecate FragmentContract and Integration.

* Rename.
  • Loading branch information
Laimiux authored Jun 28, 2022
1 parent fc8630b commit d30fd57
Show file tree
Hide file tree
Showing 37 changed files with 361 additions and 419 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import androidx.annotation.VisibleForTesting
import com.instacart.formula.FormulaAndroid
import com.instacart.formula.R
import com.instacart.formula.android.FormulaFragment
import com.instacart.formula.android.FragmentContract
import com.instacart.formula.android.FragmentKey
import com.instacart.formula.android.FormulaAppCompatActivity

class TestFragmentActivity : FormulaAppCompatActivity() {
@VisibleForTesting lateinit var initialContract: FragmentContract<*>
@VisibleForTesting val renderCalls = mutableListOf<Pair<FragmentContract<*>, *>>()
@VisibleForTesting lateinit var initialContract: FragmentKey
@VisibleForTesting val renderCalls = mutableListOf<Pair<FragmentKey, *>>()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.instacart.formula.test

import android.os.Bundle
import android.view.View
import com.instacart.formula.android.FragmentLifecycleCallback

class TestFragmentLifecycleCallback : FragmentLifecycleCallback {
var hasOnViewCreated = false
var hasOnActivityCreated = false
var hasOnStart = false
var hasOnResume = false
var hasOnPauseEvent = false
var hasOnStop = false
var hasOnSaveInstanceState = false
var hasOnDestroyView = false

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
hasOnViewCreated = true
}

override fun onActivityCreated(savedInstanceState: Bundle?) {
hasOnActivityCreated = true
}

override fun onStart() {
hasOnStart = true
}

override fun onResume() {
hasOnResume = true
}

// teardown
override fun onPause() {
hasOnPauseEvent = true
}

override fun onStop() {
hasOnStop = true
}

override fun onSaveInstanceState(outState: Bundle) {
hasOnSaveInstanceState = true
}

override fun onDestroyView() {
hasOnDestroyView
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.instacart.formula.test

import com.instacart.formula.android.FragmentKey
import kotlinx.parcelize.Parcelize

@Parcelize
data class TestKey(
override val tag: String = "test key",
) : FragmentKey
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.instacart.formula.test

import com.instacart.formula.android.FragmentKey
import kotlinx.parcelize.Parcelize

@Parcelize
data class TestKeyWithId(
val id: Int,
override val tag: String = "test-key-$id",
) : FragmentKey

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.instacart.formula.test

import com.instacart.formula.android.FragmentKey
import kotlinx.parcelize.Parcelize

@Parcelize
data class TestLifecycleKey(
override val tag: String = "task list",
) : FragmentKey
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
import com.instacart.formula.android.Feature
import com.instacart.formula.android.ViewFactory
import com.instacart.formula.android.events.ActivityResult
import com.instacart.formula.test.TestFragmentActivity
import com.instacart.formula.test.TestLifecycleContract
import com.instacart.formula.test.TestLifecycleKey
import io.reactivex.rxjava3.core.Observable
import org.junit.Before
import org.junit.Rule
Expand All @@ -24,14 +26,20 @@ class FragmentAndroidEventTest {
activity<TestFragmentActivity> {
store(
configureActivity = {
initialContract = TestLifecycleContract()
initialContract = TestLifecycleKey()
},
contracts = {
bind(TestLifecycleContract::class) { _ ->
activityResults().flatMap {
activityResults.add(it)
Observable.empty<Any>()
}

bind<TestLifecycleKey> { _, _ ->
Feature(
state = activityResults().flatMap {
activityResults.add(it)
Observable.empty()
},
viewFactory = ViewFactory.fromLayout(R.layout.test_empty_layout) {
featureView { }
}
)
}
}
)
Expand Down
Loading

0 comments on commit d30fd57

Please sign in to comment.