Skip to content

Commit

Permalink
Revert change with R namespace change, update robolectric
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkranzler5 committed Dec 14, 2023
1 parent e7980dc commit 03d0061
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 26 deletions.
4 changes: 2 additions & 2 deletions formula-android-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ apply {
}

android {
namespace = "com.instacart.formula.samples"
namespace = "com.instacart.formula"
defaultConfig {
applicationId = "com.instacart.formula.samples"
applicationId = "com.instacart.formula"
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package com.instacart.formula.test
import android.os.Bundle
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.FragmentKey
import com.instacart.formula.android.FormulaAppCompatActivity
import com.instacart.formula.samples.R

class TestFragmentActivity : FormulaAppCompatActivity() {
@VisibleForTesting lateinit var initialContract: FragmentKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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.FormulaAppCompatActivity
import com.instacart.formula.samples.R
import com.jakewharton.rxrelay3.PublishRelay
import org.junit.Before
import org.junit.Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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.FormulaAppCompatActivity
import com.instacart.formula.samples.R
import io.reactivex.rxjava3.core.Observable
import org.junit.Before
import org.junit.Rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ 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.samples.R
import com.instacart.formula.test.TestFragmentActivity
import com.instacart.formula.test.TestLifecycleKey
import io.reactivex.rxjava3.core.Observable
Expand All @@ -29,7 +28,7 @@ class FragmentAndroidEventTest {
configureActivity = {
initialContract = TestLifecycleKey()
},
contracts = {
contracts = {

bind<TestLifecycleKey> { _, _ ->
Feature(
Expand All @@ -53,17 +52,14 @@ class FragmentAndroidEventTest {

private val activityRule = ActivityScenarioRule(TestFragmentActivity::class.java)

@get:Rule
val rule = RuleChain.outerRule(formulaRule).around(activityRule)
@get:Rule val rule = RuleChain.outerRule(formulaRule).around(activityRule)
lateinit var scenario: ActivityScenario<TestFragmentActivity>

@Before
fun setup() {
@Before fun setup() {
scenario = activityRule.scenario
}

@Test
fun `activity result`() {
@Test fun `activity result`() {
FormulaAndroid.onActivityResult(scenario.activity(), 1, 2, null)

val expected = listOf(ActivityResult(1, 2, null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ 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.FormulaFragment
import com.instacart.formula.android.ActivityStoreContext
import com.instacart.formula.android.FeatureFactory
import com.instacart.formula.android.FormulaFragment
import com.instacart.formula.android.FragmentKey
import com.instacart.formula.samples.R
import com.instacart.formula.test.TestFragmentActivity
import com.instacart.formula.test.TestKey
import com.instacart.formula.test.TestKeyWithId
import com.instacart.formula.test.TestFragmentActivity
import io.reactivex.rxjava3.core.Observable
import org.junit.Before
import org.junit.Rule
Expand All @@ -37,7 +36,7 @@ class FragmentLifecycleStateTest {
configureActivity = {
initialContract = TestKey()
},
contracts = {
contracts = {
bind(featureFactory<TestKey>(this@activity))
bind(featureFactory<TestKeyWithId>(this@activity))
}
Expand All @@ -58,21 +57,18 @@ class FragmentLifecycleStateTest {
scenario = activityRule.scenario
}

@Test
fun `is fragment started`() {
@Test fun `is fragment started`() {
val events = selectStartedEvents(TestKey())
assertThat(events).containsExactly(false, true).inOrder()
}

@Test
fun `is fragment resumed`() {
@Test fun `is fragment resumed`() {
val events = selectResumedEvents(TestKey())
assertThat(events).containsExactly(false, true).inOrder()
}

@LooperMode(LooperMode.Mode.LEGACY)
@Test
fun `navigate forward`() {
@Test fun `navigate forward`() {
navigateToTaskDetail()

val contract = TestKey()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import com.google.common.truth.Truth.assertThat
import com.instacart.formula.android.Feature
import com.instacart.formula.android.FeatureFactory
import com.instacart.formula.android.ViewFactory
import com.instacart.formula.samples.R
import com.instacart.formula.test.TestFragmentActivity
import com.instacart.formula.test.TestFragmentLifecycleCallback
import com.instacart.formula.test.TestLifecycleKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.instacart.formula.android.Feature
import com.instacart.formula.android.FeatureFactory
import com.instacart.formula.android.FragmentKey
import com.instacart.formula.android.ViewFactory
import com.instacart.formula.samples.R
import com.instacart.formula.test.TestFragmentActivity
import io.reactivex.rxjava3.core.Observable

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ lifecycle = "2.2.0"
lifecycleKtx = '2.4.0-alpha03'
androidTest = "1.4.0"
espresso = "3.4.0"
robolectric = "4.6.1"
robolectric = "4.11.1"
lint = "30.0.0"
autoService = "1.0-rc7"

Expand Down

0 comments on commit 03d0061

Please sign in to comment.