-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for nested results in sibling containers, updated Default…
…ContainerExecutor to correctly support this as would be expected.
- Loading branch information
Showing
10 changed files
with
512 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
121 changes: 121 additions & 0 deletions
121
...c/androidTest/java/dev/enro/test/application/compose/results/ComposeNestedResultsRobot.kt
This file contains 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,121 @@ | ||
package dev.enro.test.application.compose.results | ||
|
||
import androidx.compose.ui.test.junit4.ComposeTestRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.compose.ui.test.performScrollTo | ||
import androidx.test.espresso.Espresso | ||
import dev.enro.test.application.waitForNavigationHandle | ||
import dev.enro.tests.application.compose.results.ComposeNestedResults | ||
|
||
class ComposeNestedResultsRobot( | ||
private val composeRule: ComposeTestRule | ||
) { | ||
init { | ||
composeRule.waitForNavigationHandle { | ||
it.key is ComposeNestedResults | ||
} | ||
} | ||
|
||
fun getReceiver() : ReceiverRobot { | ||
return ReceiverRobot(composeRule) | ||
} | ||
|
||
class ReceiverRobot(private val composeRule: ComposeTestRule) { | ||
init { | ||
composeRule.waitForNavigationHandle { | ||
it.key is ComposeNestedResults.Receiver | ||
} | ||
} | ||
|
||
fun assertCurrentResult(result: String) : ReceiverRobot { | ||
composeRule.onNodeWithText("Current Result: $result") | ||
.assertExists() | ||
return this | ||
} | ||
|
||
fun assertSenderContainerIsVisible() : ReceiverRobot { | ||
composeRule.onNodeWithText("Nested Sender Container") | ||
.assertExists() | ||
return this | ||
} | ||
|
||
fun assertSenderContainerNotVisible() : ReceiverRobot { | ||
composeRule.onNodeWithText("Nested Sender Container") | ||
.assertDoesNotExist() | ||
return this | ||
} | ||
|
||
fun openNestedSenderContainer(): ReceiverRobot { | ||
composeRule.onNodeWithText("Open Nested Sender Container") | ||
.performScrollTo() | ||
.performClick() | ||
|
||
NestedSenderContainerRobot(composeRule) | ||
return this | ||
} | ||
|
||
fun openSender(): SenderRobot { | ||
composeRule.onNodeWithText("Get Result") | ||
.performScrollTo() | ||
.performClick() | ||
|
||
return SenderRobot(composeRule) | ||
} | ||
|
||
} | ||
|
||
class NestedSenderContainerRobot(private val composeRule: ComposeTestRule) { | ||
init { | ||
composeRule.waitForNavigationHandle { | ||
it.key is ComposeNestedResults.NestedSenderContainer | ||
} | ||
} | ||
} | ||
|
||
class SenderRobot(private val composeRule: ComposeTestRule) { | ||
init { | ||
composeRule.waitForNavigationHandle { | ||
it.key is ComposeNestedResults.Sender | ||
} | ||
} | ||
|
||
fun assertIsInsideContainer(): SenderRobot { | ||
composeRule.onNodeWithText("Nested Sender Container") | ||
.assertExists() | ||
return this | ||
} | ||
|
||
fun assertIsNotInContainer(): SenderRobot { | ||
composeRule.onNodeWithText("Nested Sender Container") | ||
.assertDoesNotExist() | ||
return this | ||
} | ||
|
||
fun sendA(): ReceiverRobot { | ||
composeRule.onNodeWithText("Send A") | ||
.performClick() | ||
|
||
return ReceiverRobot(composeRule) | ||
} | ||
|
||
fun sendB(): ReceiverRobot { | ||
composeRule.onNodeWithText("Send B") | ||
.performClick() | ||
|
||
return ReceiverRobot(composeRule) | ||
} | ||
|
||
fun closeWithButton(): ReceiverRobot { | ||
composeRule.onNodeWithText("Close") | ||
.performClick() | ||
|
||
return ReceiverRobot(composeRule) | ||
} | ||
|
||
fun closeWithBackPress(): ReceiverRobot { | ||
Espresso.pressBack() | ||
return ReceiverRobot(composeRule) | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...rc/androidTest/java/dev/enro/test/application/compose/results/ComposeNestedResultsTest.kt
This file contains 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,77 @@ | ||
package dev.enro.test.application.compose.results | ||
|
||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import dev.enro.test.application.SelectDestinationRobot | ||
import dev.enro.tests.application.TestActivity | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ComposeNestedResultsTest { | ||
@get:Rule | ||
val composeRule = createAndroidComposeRule<TestActivity>() | ||
|
||
@Test | ||
fun test() { | ||
SelectDestinationRobot(composeRule) | ||
.openComposeNestedResults() | ||
.getReceiver() | ||
.assertCurrentResult("(None)") | ||
|
||
.openSender() | ||
.assertIsNotInContainer() | ||
.sendA() | ||
.assertCurrentResult("A") | ||
.assertSenderContainerNotVisible() | ||
|
||
.openSender() | ||
.assertIsNotInContainer() | ||
.closeWithButton() | ||
.assertCurrentResult("Closed") | ||
.assertSenderContainerNotVisible() | ||
|
||
.openSender() | ||
.assertIsNotInContainer() | ||
.sendB() | ||
.assertCurrentResult("B") | ||
.assertSenderContainerNotVisible() | ||
|
||
.openSender() | ||
.assertIsNotInContainer() | ||
.closeWithBackPress() | ||
.assertCurrentResult("Closed") | ||
.assertSenderContainerNotVisible() | ||
|
||
.openNestedSenderContainer() | ||
.assertSenderContainerIsVisible() | ||
.openSender() | ||
.assertIsInsideContainer() | ||
.sendB() | ||
.assertCurrentResult("B") | ||
.assertSenderContainerNotVisible() | ||
|
||
.openNestedSenderContainer() | ||
.assertSenderContainerIsVisible() | ||
.openSender() | ||
.assertIsInsideContainer() | ||
.closeWithButton() | ||
.assertCurrentResult("Closed") | ||
.assertSenderContainerNotVisible() | ||
|
||
.openNestedSenderContainer() | ||
.assertSenderContainerIsVisible() | ||
.openSender() | ||
.assertIsInsideContainer() | ||
.sendA() | ||
.assertCurrentResult("A") | ||
.assertSenderContainerNotVisible() | ||
|
||
.openNestedSenderContainer() | ||
.assertSenderContainerIsVisible() | ||
.openSender() | ||
.assertIsInsideContainer() | ||
.closeWithBackPress() | ||
.assertCurrentResult("Closed") | ||
.assertSenderContainerNotVisible() | ||
|
||
} | ||
} |
Oops, something went wrong.