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
Expand Up @@ -19,7 +19,7 @@ import com.google.common.truth.Truth.assertThat
import com.squareup.sample.timemachine.RecorderWorkflow.RecorderProps.PlaybackAt
import com.squareup.sample.timemachine.RecorderWorkflow.RecorderProps.RecordValue
import com.squareup.sample.timemachine.RecorderWorkflow.Recording
import com.squareup.workflow.testing.renderTester
import com.squareup.workflow.testing.testRender
import org.junit.Test
import kotlin.time.ExperimentalTime
import kotlin.time.TestTimeSource
Expand Down Expand Up @@ -72,7 +72,7 @@ class RecorderWorkflowTest {
val startTime = clock.markNow()

workflow
.renderTester(
.testRender(
props = RecordValue("bar"),
initialState = Recording(
startTime = startTime,
Expand All @@ -90,7 +90,7 @@ class RecorderWorkflowTest {
val startTime = clock.markNow()

workflow
.renderTester(
.testRender(
props = PlaybackAt(10.milliseconds),
initialState = Recording(
startTime = startTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import com.squareup.workflow.Sink
import com.squareup.workflow.Workflow
import com.squareup.workflow.makeEventSink
import com.squareup.workflow.stateful
import com.squareup.workflow.testing.testFromStart
import com.squareup.workflow.testing.launchForTestingFromStartWith
import org.junit.Test
import kotlin.time.Duration
import kotlin.time.ExperimentalTime
Expand All @@ -49,7 +49,7 @@ class TimeMachineWorkflowTest {
val clock = TestTimeSource()
val tmWorkflow = TimeMachineWorkflow(delegateWorkflow, clock)

tmWorkflow.testFromStart(Recording(Unit) as TimeMachineProps<Unit>) {
tmWorkflow.launchForTestingFromStartWith(Recording(Unit) as TimeMachineProps<Unit>) {
// Record some renderings.
awaitNextRendering().let { rendering ->
assertThat(rendering.value.state).isEqualTo("initial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import com.squareup.sample.gameworkflow.Ending.Quitted
import com.squareup.sample.gameworkflow.Ending.Victory
import com.squareup.sample.gameworkflow.Player.O
import com.squareup.sample.gameworkflow.Player.X
import com.squareup.workflow.testing.WorkflowTester
import com.squareup.workflow.testing.testFromStart
import com.squareup.workflow.testing.WorkflowTestRuntime
import com.squareup.workflow.testing.launchForTestingFromStartWith
import org.junit.Test

class TakeTurnsWorkflowTest {
Expand All @@ -35,7 +35,7 @@ class TakeTurnsWorkflowTest {
}

@Test fun startsGameWithGivenNames() {
RealTakeTurnsWorkflow().testFromStart(
RealTakeTurnsWorkflow().launchForTestingFromStartWith(
TakeTurnsProps.newGame(PlayerInfo("higgledy", "piggledy"))
) {
val (x, o) = awaitNextRendering().playerInfo
Expand All @@ -48,7 +48,7 @@ class TakeTurnsWorkflowTest {
}

@Test fun xWins() {
RealTakeTurnsWorkflow().testFromStart(
RealTakeTurnsWorkflow().launchForTestingFromStartWith(
TakeTurnsProps.newGame(PlayerInfo("higgledy", "piggledy"))
) {
takeSquare(0, 0)
Expand All @@ -71,7 +71,7 @@ class TakeTurnsWorkflowTest {
}

@Test fun draw() {
RealTakeTurnsWorkflow().testFromStart(
RealTakeTurnsWorkflow().launchForTestingFromStartWith(
TakeTurnsProps.newGame(PlayerInfo("higgledy", "piggledy"))
) {
takeSquare(0, 0) // X - -
Expand Down Expand Up @@ -102,7 +102,7 @@ class TakeTurnsWorkflowTest {
@Test fun quiteAndResume() {
var output: CompletedGame? = null

RealTakeTurnsWorkflow().testFromStart(
RealTakeTurnsWorkflow().launchForTestingFromStartWith(
TakeTurnsProps.newGame(PlayerInfo("higgledy", "piggledy"))
) {
awaitNextRendering().onQuit()
Expand All @@ -111,7 +111,7 @@ class TakeTurnsWorkflowTest {

assertThat(output!!.ending).isSameInstanceAs(Quitted)

RealTakeTurnsWorkflow().testFromStart(
RealTakeTurnsWorkflow().launchForTestingFromStartWith(
TakeTurnsProps.resumeGame(
PlayerInfo("higgledy", "piggledy"),
output!!.lastTurn
Expand All @@ -122,6 +122,6 @@ class TakeTurnsWorkflowTest {
}
}

private fun WorkflowTester<*, *, GamePlayScreen>.takeSquare(row: Int, col: Int) {
private fun WorkflowTestRuntime<*, *, GamePlayScreen>.takeSquare(row: Int, col: Int) {
awaitNextRendering().onClick(row, col)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.squareup.workflow.Workflow
import com.squareup.workflow.action
import com.squareup.workflow.rendering
import com.squareup.workflow.stateless
import com.squareup.workflow.testing.testFromStart
import com.squareup.workflow.testing.launchForTestingFromStartWith
import com.squareup.workflow.ui.backstack.BackStackScreen
import org.junit.Test

Expand All @@ -22,7 +22,7 @@ import org.junit.Test
*/
class MainWorkflowTest {
@Test fun `starts in auth over empty game`() {
MainWorkflow(authWorkflow(), runGameWorkflow()).testFromStart {
MainWorkflow(authWorkflow(), runGameWorkflow()).launchForTestingFromStartWith {
awaitNextRendering()
.let { screen ->
assertThat(screen.panels).hasSize(1)
Expand All @@ -42,7 +42,7 @@ class MainWorkflowTest {
authScreen()
}

MainWorkflow(authWorkflow, runGameWorkflow()).testFromStart {
MainWorkflow(authWorkflow, runGameWorkflow()).launchForTestingFromStartWith {
awaitNextRendering()
.let { screen ->
assertThat(screen.panels).isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.squareup.workflow.Worker
import com.squareup.workflow.Workflow
import com.squareup.workflow.action
import com.squareup.workflow.stateless
import com.squareup.workflow.testing.testFromStart
import com.squareup.workflow.testing.launchForTestingFromStartWith
import io.reactivex.BackpressureStrategy.BUFFER
import io.reactivex.subjects.PublishSubject
import org.reactivestreams.Publisher
Expand All @@ -41,7 +41,7 @@ class PublisherWorkerTest {
runningWorker(worker) { action(it) }
}

workflow.testFromStart {
workflow.launchForTestingFromStartWith {
assertFalse(hasOutput)

subject.onNext("one")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.squareup.workflow.rx2

import com.squareup.workflow.testing.test
import com.squareup.workflow.testing.launchForTestingWith
import io.reactivex.BackpressureStrategy.MISSING
import io.reactivex.Flowable
import io.reactivex.Maybe
Expand All @@ -40,7 +40,7 @@ class RxWorkersTest {
// Should support out-projected parameters.
val worker = (subject as Observable<out String?>).asWorker()

worker.test {
worker.launchForTestingWith {
subject.onNext("foo")
assertEquals("foo", nextOutput())

Expand All @@ -53,7 +53,7 @@ class RxWorkersTest {
val subject = PublishSubject.create<String>()
val worker = subject.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onComplete()
assertFinished()
}
Expand All @@ -63,7 +63,7 @@ class RxWorkersTest {
val subject = PublishSubject.create<String>()
val worker = subject.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onNext("foo")
assertEquals("foo", nextOutput())

Expand All @@ -76,7 +76,7 @@ class RxWorkersTest {
val subject = PublishSubject.create<String>()
val worker = subject.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -90,7 +90,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.test {
worker.launchForTestingWith {
assertEquals(1, subscriptions)
}
}
Expand All @@ -103,7 +103,7 @@ class RxWorkersTest {

assertEquals(0, disposals)

worker.test {
worker.launchForTestingWith {
assertEquals(0, disposals)
cancelWorker()
assertEquals(1, disposals)
Expand All @@ -119,7 +119,7 @@ class RxWorkersTest {
val worker = (subject.toFlowable(MISSING) as Flowable<out String?>)
.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onNext("foo")
assertEquals("foo", nextOutput())

Expand All @@ -133,7 +133,7 @@ class RxWorkersTest {
val worker = subject.toFlowable(MISSING)
.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onComplete()
assertFinished()
}
Expand All @@ -144,7 +144,7 @@ class RxWorkersTest {
val worker = subject.toFlowable(MISSING)
.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onNext("foo")
assertEquals("foo", nextOutput())

Expand All @@ -158,7 +158,7 @@ class RxWorkersTest {
val worker = subject.toFlowable(MISSING)
.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -173,7 +173,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.test {
worker.launchForTestingWith {
assertEquals(1, subscriptions)
}
}
Expand All @@ -187,7 +187,7 @@ class RxWorkersTest {

assertEquals(0, cancels)

worker.test {
worker.launchForTestingWith {
assertEquals(0, cancels)
cancelWorker()
assertEquals(1, cancels)
Expand All @@ -202,7 +202,7 @@ class RxWorkersTest {
val subject = MaybeSubject.create<String>()
val worker = (subject as Maybe<out String?>).asWorker()

worker.test {
worker.launchForTestingWith {
subject.onSuccess("foo")
assertEquals("foo", nextOutput())
assertFinished()
Expand All @@ -213,7 +213,7 @@ class RxWorkersTest {
val subject = MaybeSubject.create<String>()
val worker = subject.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onComplete()
assertFinished()
}
Expand All @@ -223,7 +223,7 @@ class RxWorkersTest {
val subject = MaybeSubject.create<String>()
val worker = subject.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -237,7 +237,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.test {
worker.launchForTestingWith {
assertEquals(1, subscriptions)
}
}
Expand All @@ -250,7 +250,7 @@ class RxWorkersTest {

assertEquals(0, cancels)

worker.test {
worker.launchForTestingWith {
assertEquals(0, cancels)
cancelWorker()
assertEquals(1, cancels)
Expand All @@ -265,7 +265,7 @@ class RxWorkersTest {
val subject = SingleSubject.create<String>()
val worker = (subject as Single<out String?>).asWorker()

worker.test {
worker.launchForTestingWith {
subject.onSuccess("foo")
assertEquals("foo", nextOutput())
assertFinished()
Expand All @@ -276,7 +276,7 @@ class RxWorkersTest {
val subject = SingleSubject.create<String>()
val worker = subject.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -290,7 +290,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.test {
worker.launchForTestingWith {
assertEquals(1, subscriptions)
}
}
Expand All @@ -303,7 +303,7 @@ class RxWorkersTest {

assertEquals(0, cancels)

worker.test {
worker.launchForTestingWith {
assertEquals(0, cancels)
cancelWorker()
assertEquals(1, cancels)
Expand All @@ -318,7 +318,7 @@ class RxWorkersTest {
val subject = CompletableSubject.create()
val worker = subject.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onComplete()
assertFinished()
}
Expand All @@ -328,7 +328,7 @@ class RxWorkersTest {
val subject = CompletableSubject.create()
val worker = subject.asWorker()

worker.test {
worker.launchForTestingWith {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -342,7 +342,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.test {
worker.launchForTestingWith {
assertEquals(1, subscriptions)
}
}
Expand All @@ -355,7 +355,7 @@ class RxWorkersTest {

assertEquals(0, cancels)

worker.test {
worker.launchForTestingWith {
assertEquals(0, cancels)
cancelWorker()
assertEquals(1, cancels)
Expand Down
Loading