-
Notifications
You must be signed in to change notification settings - Fork 112
Nested overlays sample, small bug fixes #967
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
9 changes: 3 additions & 6 deletions
9
...containers/app-poetry/src/androidTest/java/com/squareup/sample/poetryapp/PoetryAppTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,29 @@ | ||
| package com.squareup.sample.poetryapp | ||
|
|
||
| import androidx.test.espresso.Espresso.onView | ||
| 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 com.squareup.sample.container.poetryapp.R | ||
| import com.squareup.workflow1.ui.WorkflowUiExperimentalApi | ||
| import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule | ||
| import com.squareup.workflow1.ui.internal.test.inAnyView | ||
| import leakcanary.DetectLeaksAfterTestSuccess | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.rules.RuleChain | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| @OptIn(WorkflowUiExperimentalApi::class) | ||
| class PoetryAppTest { | ||
|
|
||
| private val scenarioRule = ActivityScenarioRule(PoetryActivity::class.java) | ||
|
|
||
| @get:Rule val rules = RuleChain.outerRule(DetectLeaksAfterTestSuccess()) | ||
| @get:Rule val rules: RuleChain = RuleChain.outerRule(DetectLeaksAfterTestSuccess()) | ||
| .around(scenarioRule) | ||
| .around(IdlingDispatcherRule) | ||
|
|
||
| @Test fun launches() { | ||
| inAnyView(withText(R.string.poems)) | ||
| .check(matches(isDisplayed())) | ||
| onView(withText(R.string.poems)).check(matches(isDisplayed())) | ||
| } | ||
| } |
8 changes: 3 additions & 5 deletions
8
...es/containers/app-raven/src/androidTest/java/com/squareup/sample/ravenapp/RavenAppTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,29 @@ | ||
| package com.squareup.sample.ravenapp | ||
|
|
||
| import androidx.test.espresso.Espresso.onView | ||
| 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 com.squareup.workflow1.ui.WorkflowUiExperimentalApi | ||
| import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule | ||
| import com.squareup.workflow1.ui.internal.test.inAnyView | ||
| import leakcanary.DetectLeaksAfterTestSuccess | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.rules.RuleChain | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| @OptIn(WorkflowUiExperimentalApi::class) | ||
| class RavenAppTest { | ||
|
|
||
| private val scenarioRule = ActivityScenarioRule(RavenActivity::class.java) | ||
|
|
||
| @get:Rule val rules = RuleChain.outerRule(DetectLeaksAfterTestSuccess()) | ||
| @get:Rule val rules: RuleChain = RuleChain.outerRule(DetectLeaksAfterTestSuccess()) | ||
| .around(scenarioRule) | ||
| .around(IdlingDispatcherRule) | ||
|
|
||
| @Test fun launches() { | ||
| inAnyView(withText("The Raven")) | ||
| onView(withText("The Raven")) | ||
| .check(matches(isDisplayed())) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
samples/dungeon/app/src/androidTest/java/com/squareup/sample/dungeon/DungeonAppTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,29 @@ | ||
| package com.squareup.sample.dungeon | ||
|
|
||
| import androidx.test.espresso.Espresso.onView | ||
| 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 com.squareup.workflow1.ui.WorkflowUiExperimentalApi | ||
| import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule | ||
| import com.squareup.workflow1.ui.internal.test.inAnyView | ||
| import leakcanary.DetectLeaksAfterTestSuccess | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.rules.RuleChain | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| @OptIn(WorkflowUiExperimentalApi::class) | ||
| class DungeonAppTest { | ||
|
|
||
| private val scenarioRule = ActivityScenarioRule(DungeonActivity::class.java) | ||
|
|
||
| @get:Rule val rules = RuleChain.outerRule(DetectLeaksAfterTestSuccess()) | ||
| @get:Rule val rules: RuleChain = RuleChain.outerRule(DetectLeaksAfterTestSuccess()) | ||
| .around(scenarioRule) | ||
| .around(IdlingDispatcherRule) | ||
|
|
||
| @Test fun loadsBoardsList() { | ||
| inAnyView(withText(R.string.boards_list_label)) | ||
| onView(withText(R.string.boards_list_label)) | ||
| .check(matches(isDisplayed())) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 5 additions & 7 deletions
12
...o-workflow/src/androidTest/java/com/squareup/sample/helloworkflow/HelloWorkflowAppTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,38 @@ | ||
| package com.squareup.sample.helloworkflow | ||
|
|
||
| import androidx.test.espresso.Espresso.onView | ||
| 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 com.squareup.workflow1.ui.WorkflowUiExperimentalApi | ||
| import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule | ||
| import com.squareup.workflow1.ui.internal.test.inAnyView | ||
| import leakcanary.DetectLeaksAfterTestSuccess | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.rules.RuleChain | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| @OptIn(WorkflowUiExperimentalApi::class) | ||
| class HelloWorkflowAppTest { | ||
|
|
||
| private val scenarioRule = ActivityScenarioRule(HelloWorkflowActivity::class.java) | ||
|
|
||
| @get:Rule val rules = RuleChain.outerRule(DetectLeaksAfterTestSuccess()) | ||
| @get:Rule val rules: RuleChain = RuleChain.outerRule(DetectLeaksAfterTestSuccess()) | ||
| .around(scenarioRule) | ||
| .around(IdlingDispatcherRule) | ||
|
|
||
| @Test fun togglesHelloAndGoodbye() { | ||
| inAnyView(withText("Hello")) | ||
| onView(withText("Hello")) | ||
| .check(matches(isDisplayed())) | ||
| .perform(click()) | ||
|
|
||
| inAnyView(withText("Goodbye")) | ||
| onView(withText("Goodbye")) | ||
| .check(matches(isDisplayed())) | ||
| .perform(click()) | ||
|
|
||
| inAnyView(withText("Hello")) | ||
| onView(withText("Hello")) | ||
| .check(matches(isDisplayed())) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| plugins { | ||
| id("com.android.application") | ||
| `kotlin-android` | ||
| `android-sample-app` | ||
| `android-ui-tests` | ||
| } | ||
|
|
||
| android { | ||
| defaultConfig { | ||
| applicationId = "com.squareup.sample.nestedoverlays" | ||
| } | ||
| namespace = "com.squareup.sample.nestedoverlays" | ||
| } | ||
|
|
||
| dependencies { | ||
| debugImplementation(libs.squareup.leakcanary.android) | ||
|
|
||
| implementation(libs.androidx.activity.ktx) | ||
| implementation(libs.androidx.lifecycle.viewmodel.ktx) | ||
| implementation(libs.androidx.lifecycle.viewmodel.savedstate) | ||
| implementation(libs.androidx.viewbinding) | ||
|
|
||
| implementation(project(":workflow-ui:core-android")) | ||
| implementation(project(":workflow-ui:core-common")) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <issues format="6" by="lint 7.4.1" type="baseline" client="gradle" dependencies="false" name="AGP (7.4.1)" variant="fatal" version="7.4.1"> | ||
|
|
||
| </issues> | ||
99 changes: 99 additions & 0 deletions
99
...overlays/src/androidTest/java/com/squareup/sample/nestedoverlays/NestedOverlaysAppTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| package com.squareup.sample.nestedoverlays | ||
|
|
||
| import androidx.test.espresso.Espresso.onView | ||
| import androidx.test.espresso.ViewInteraction | ||
| import androidx.test.espresso.action.ViewActions.click | ||
| import androidx.test.espresso.assertion.ViewAssertions.doesNotExist | ||
| import androidx.test.espresso.assertion.ViewAssertions.matches | ||
| import androidx.test.espresso.matcher.ViewMatchers.isDisplayed | ||
| import androidx.test.espresso.matcher.ViewMatchers.withParent | ||
| import androidx.test.espresso.matcher.ViewMatchers.withParentIndex | ||
| import androidx.test.espresso.matcher.ViewMatchers.withText | ||
| import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
| import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule | ||
| import leakcanary.DetectLeaksAfterTestSuccess | ||
| import org.hamcrest.core.AllOf.allOf | ||
| import org.hamcrest.core.IsNot.not | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import org.junit.rules.RuleChain | ||
| import org.junit.runner.RunWith | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| class NestedOverlaysAppTest { | ||
|
|
||
| private val scenarioRule = ActivityScenarioRule(NestedOverlaysActivity::class.java) | ||
|
|
||
| @get:Rule val rules: RuleChain = RuleChain.outerRule(DetectLeaksAfterTestSuccess()) | ||
| .around(scenarioRule) | ||
| .around(IdlingDispatcherRule) | ||
|
|
||
| @Test fun basics() { | ||
| onTopCoverBody().assertDisplayed() | ||
| onTopCoverEverything().assertDisplayed() | ||
| onBottomCoverBody().assertDisplayed() | ||
| onBottomCoverEverything().assertDisplayed() | ||
|
|
||
| onTopCoverBody().perform(click()) | ||
| onView(withText("Close")).perform(click()) | ||
| onTopCoverEverything().perform(click()) | ||
| onView(withText("Close")).perform(click()) | ||
|
|
||
| onView(withText("Hide Top Bar")).perform(click()) | ||
| onTopCoverBody().assertNotDisplayed() | ||
| onTopCoverEverything().assertNotDisplayed() | ||
| onBottomCoverBody().assertDisplayed() | ||
| onBottomCoverEverything().assertDisplayed() | ||
|
|
||
| onView(withText("Hide Bottom Bar")).perform(click()) | ||
| onTopCoverBody().assertNotDisplayed() | ||
| onTopCoverEverything().assertNotDisplayed() | ||
| onBottomCoverBody().assertNotDisplayed() | ||
| onBottomCoverEverything().assertNotDisplayed() | ||
| } | ||
|
|
||
| // https://github.com/square/workflow-kotlin/issues/966 | ||
| @Test fun canInsertDialog() { | ||
| onTopCoverEverything().perform(click()) | ||
| onView(withText("Hide Top Bar")).check(doesNotExist()) | ||
| onView(withText("Cover Body")).perform(click()) | ||
|
|
||
| // This line fails due to https://github.com/square/workflow-kotlin/issues/966 | ||
| // onView(withText("Hide Top Bar")).check(doesNotExist()) | ||
|
|
||
| // Should continue to close the top sheet and assert that the inner sheet is visible. | ||
| } | ||
|
|
||
| // So far can't express this in Espresso. Considering move to Maestro | ||
| // @Test fun canClickPastInnerWindow() { | ||
| // onView(allOf(withText("Cover Everything"), withParent(withParentIndex(0)))) | ||
| // .perform(click()) | ||
| // | ||
| // scenario.onActivity { activity -> | ||
| // onView(allOf(withText("Cover Everything"), withParent(withParentIndex(0)))) | ||
| // .inRoot(withDecorView(not(`is`(activity.window.decorView)))) | ||
| // .perform(click()) | ||
| // } | ||
| // } | ||
|
|
||
| private fun ViewInteraction.assertNotDisplayed() { | ||
| check(matches(not(isDisplayed()))) | ||
| } | ||
|
|
||
| private fun ViewInteraction.assertDisplayed() { | ||
| check(matches(isDisplayed())) | ||
| } | ||
|
|
||
| private fun onBottomCoverEverything() = | ||
| onView(allOf(withText("Cover Everything"), withParent(withParentIndex(2)))) | ||
|
|
||
| private fun onBottomCoverBody() = | ||
| onView(allOf(withText("Cover Body"), withParent(withParentIndex(2)))) | ||
|
|
||
| private fun onTopCoverBody() = | ||
| onView(allOf(withText("Cover Body"), withParent(withParentIndex(0)))) | ||
|
|
||
| private fun onTopCoverEverything() = | ||
| onView(allOf(withText("Cover Everything"), withParent(withParentIndex(0)))) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.