From b4565c26749b1946aed163427ef6f6ff35def0cd Mon Sep 17 00:00:00 2001 From: Ray Ryan Date: Tue, 9 Nov 2021 11:31:17 -0800 Subject: [PATCH 1/2] Disables HelloWorkflowFragmentAppTest on API 21 b/c LeakCanary Or more likely, b/c LeakCanary exposes an obscure bug in Jetpack and life is just too short. Fixes #582. --- .../HelloWorkflowFragmentAppTest.kt | 5 +++++ .../sample/helloworkflowfragment/StubTest.kt | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 samples/hello-workflow-fragment/src/androidTest/java/com/squareup/sample/helloworkflowfragment/StubTest.kt diff --git a/samples/hello-workflow-fragment/src/androidTest/java/com/squareup/sample/helloworkflowfragment/HelloWorkflowFragmentAppTest.kt b/samples/hello-workflow-fragment/src/androidTest/java/com/squareup/sample/helloworkflowfragment/HelloWorkflowFragmentAppTest.kt index c36f2b84b3..dd6ba08340 100644 --- a/samples/hello-workflow-fragment/src/androidTest/java/com/squareup/sample/helloworkflowfragment/HelloWorkflowFragmentAppTest.kt +++ b/samples/hello-workflow-fragment/src/androidTest/java/com/squareup/sample/helloworkflowfragment/HelloWorkflowFragmentAppTest.kt @@ -1,11 +1,13 @@ package com.squareup.sample.helloworkflowfragment +import android.os.Build import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.SdkSuppress import com.squareup.workflow1.ui.WorkflowUiExperimentalApi import com.squareup.workflow1.ui.internal.test.inAnyView import org.hamcrest.Matchers.containsString @@ -13,6 +15,9 @@ import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +// Life is too short to debug why LeakCanary breaks this on API 21 +// https://github.com/square/workflow-kotlin/issues/582 +@SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) @RunWith(AndroidJUnit4::class) @OptIn(WorkflowUiExperimentalApi::class) class HelloWorkflowFragmentAppTest { diff --git a/samples/hello-workflow-fragment/src/androidTest/java/com/squareup/sample/helloworkflowfragment/StubTest.kt b/samples/hello-workflow-fragment/src/androidTest/java/com/squareup/sample/helloworkflowfragment/StubTest.kt new file mode 100644 index 0000000000..bc7778b33b --- /dev/null +++ b/samples/hello-workflow-fragment/src/androidTest/java/com/squareup/sample/helloworkflowfragment/StubTest.kt @@ -0,0 +1,19 @@ +package com.squareup.sample.helloworkflowfragment + +import androidx.test.ext.junit.runners.AndroidJUnit4 +import com.squareup.workflow1.ui.WorkflowUiExperimentalApi +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Stub test to avoid failing b/c no tests when suppressing [HelloWorkflowFragmentAppTest] + * on API 21. + * + * https://github.com/square/workflow-kotlin/issues/582 + */ +@RunWith(AndroidJUnit4::class) +@OptIn(WorkflowUiExperimentalApi::class) +class StubTest { + @Test fun fml() { + } +} From 53cf69d0864aa955df9cff2a448216f9d67346a3 Mon Sep 17 00:00:00 2001 From: Ray Ryan Date: Tue, 9 Nov 2021 13:21:20 -0800 Subject: [PATCH 2/2] Suppresses lifecycle_replace_after_pause on API 21 Flaky, but only on such ancient AVDs. Closes #559 --- .../workflow1/ui/backstack/test/BackstackContainerTest.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/workflow-ui/container-android/src/androidTest/java/com/squareup/workflow1/ui/backstack/test/BackstackContainerTest.kt b/workflow-ui/container-android/src/androidTest/java/com/squareup/workflow1/ui/backstack/test/BackstackContainerTest.kt index 1e677a839c..fed23dcc47 100644 --- a/workflow-ui/container-android/src/androidTest/java/com/squareup/workflow1/ui/backstack/test/BackstackContainerTest.kt +++ b/workflow-ui/container-android/src/androidTest/java/com/squareup/workflow1/ui/backstack/test/BackstackContainerTest.kt @@ -1,10 +1,12 @@ package com.squareup.workflow1.ui.backstack.test +import android.os.Build import android.view.View import androidx.lifecycle.Lifecycle.State.CREATED import androidx.lifecycle.Lifecycle.State.RESUMED import androidx.lifecycle.Lifecycle.State.STARTED import androidx.test.ext.junit.rules.ActivityScenarioRule +import androidx.test.filters.SdkSuppress import com.google.common.truth.Truth.assertThat import com.squareup.workflow1.ui.WorkflowUiExperimentalApi import com.squareup.workflow1.ui.backstack.test.fixtures.BackStackContainerLifecycleActivity @@ -339,6 +341,8 @@ internal class BackstackContainerTest { } } + // https://github.com/square/workflow-kotlin/issues/559 + @SdkSuppress(minSdkVersion = Build.VERSION_CODES.M) @Test fun lifecycle_replace_after_pause() { assertThat(scenario.state).isEqualTo(RESUMED) scenario.onActivity {