Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()))
}
}
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()))
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.squareup.sample.hellobackbutton

import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.pressBack
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
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.actuallyPressBack
import com.squareup.workflow1.ui.internal.test.inAnyView
import com.squareup.workflow1.ui.internal.test.retryBlocking
import leakcanary.DetectLeaksAfterTestSuccess
import org.junit.Rule
import org.junit.Test
Expand All @@ -24,29 +24,32 @@ class HelloBackButtonEspressoTest {

private val scenarioRule = ActivityScenarioRule(HelloBackButtonActivity::class.java)

@get:Rule val rules = RuleChain.outerRule(DetectLeaksAfterTestSuccess())
@get:Rule val rules: RuleChain = RuleChain.outerRule(DetectLeaksAfterTestSuccess())
.around(scenarioRule)
.around(IdlingDispatcherRule)

@Test fun wrappedTakesPrecedence() = retryBlocking {
inAnyView(withId(R.id.hello_message)).apply {
@Test fun wrappedTakesPrecedence() {
onView(withId(R.id.hello_message)).apply {
check(matches(withText("Able")))
perform(click())
check(matches(withText("Baker")))
perform(click())
check(matches(withText("Charlie")))
actuallyPressBack()
perform(pressBack())
check(matches(withText("Baker")))
actuallyPressBack()
perform(pressBack())
check(matches(withText("Able")))
}
}

@Test fun outerHandlerAppliesIfWrappedHandlerIsNull() = retryBlocking {
inAnyView(withId(R.id.hello_message)).apply {
actuallyPressBack()
inAnyView(withText("Are you sure you want to do this thing?"))
.check(matches(isDisplayed()))
@Test fun outerHandlerAppliesIfWrappedHandlerIsNull() {
onView(withId(R.id.hello_message)).apply {
check(matches(isDisplayed()))
perform(pressBack())
}

onView(withText("Are you sure you want to do this thing?"))
.inRoot(isDialog())
.check(matches(isDisplayed()))
}
}
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()))
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.squareup.sample.helloworkflowfragment

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.hamcrest.Matchers.containsString
import org.junit.Rule
Expand All @@ -17,25 +16,24 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
class HelloWorkflowFragmentAppTest {

private val scenarioRule = ActivityScenarioRule(HelloWorkflowFragmentActivity::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(containsString("Hello")))
onView(withText(containsString("Hello")))
.check(matches(isDisplayed()))
.perform(click())

inAnyView(withText(containsString("Goodbye")))
onView(withText(containsString("Goodbye")))
.check(matches(isDisplayed()))
.perform(click())

inAnyView(withText(containsString("Hello")))
onView(withText(containsString("Hello")))
.check(matches(isDisplayed()))
}
}
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()))
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.squareup.sample.stubvisibility

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.withId
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.hamcrest.CoreMatchers.not
import org.junit.Rule
Expand All @@ -18,29 +17,28 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
internal class StubVisibilityAppTest {

private val scenarioRule = ActivityScenarioRule(StubVisibilityActivity::class.java)

@get:Rule val rules = RuleChain.outerRule(DetectLeaksAfterTestSuccess())
@get:Rule val rules: RuleChain = RuleChain.outerRule(DetectLeaksAfterTestSuccess())
.around(scenarioRule)
.around(IdlingDispatcherRule)

@Test fun togglesFooter() {
inAnyView(withId(R.id.should_be_wrapped))
onView(withId(R.id.should_be_wrapped))
.check(matches(not(isDisplayed())))

inAnyView(withText("Click to show footer"))
onView(withText("Click to show footer"))
.perform(click())

inAnyView(withId(R.id.should_be_wrapped))
onView(withId(R.id.should_be_wrapped))
.check(matches(isDisplayed()))

inAnyView(withText("Click to hide footer"))
onView(withText("Click to hide footer"))
.perform(click())

inAnyView(withId(R.id.should_be_wrapped))
onView(withId(R.id.should_be_wrapped))
.check(matches(not(isDisplayed())))
}
}
Loading