Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhalanskyjb committed Nov 17, 2021
1 parent 91f8f1f commit 9105415
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions kotlinx-coroutines-test/common/src/DelayController.kt
Expand Up @@ -13,8 +13,10 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
* Testing libraries may expose this interface to the tests instead of [TestCoroutineDispatcher].
*/
@ExperimentalCoroutinesApi
@Deprecated("Use `TestCoroutineScheduler` to control virtual time.",
level = DeprecationLevel.WARNING)
@Deprecated(
"Use `TestCoroutineScheduler` to control virtual time.",
level = DeprecationLevel.WARNING
)
public interface DelayController {
/**
* Returns the current virtual clock-time as it is known to this Dispatcher.
Expand Down Expand Up @@ -123,20 +125,25 @@ public interface DelayController {
public fun resumeDispatcher()
}

internal interface SchedulerAsDelayController: DelayController {
internal interface SchedulerAsDelayController : DelayController {
public val scheduler: TestCoroutineScheduler

/** @suppress */
@Deprecated("This property delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
@Deprecated(
"This property delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
ReplaceWith("this.scheduler.currentTime"),
level = DeprecationLevel.WARNING)
override val currentTime: Long get() = scheduler.currentTime
level = DeprecationLevel.WARNING
)
override val currentTime: Long
get() = scheduler.currentTime


/** @suppress */
@Deprecated("This function delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
@Deprecated(
"This function delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
ReplaceWith("this.scheduler.apply { advanceTimeBy(delayTimeMillis); runCurrent() }"),
level = DeprecationLevel.WARNING)
level = DeprecationLevel.WARNING
)
override fun advanceTimeBy(delayTimeMillis: Long): Long {
val oldTime = scheduler.currentTime
scheduler.advanceTimeBy(delayTimeMillis)
Expand All @@ -145,19 +152,23 @@ internal interface SchedulerAsDelayController: DelayController {
}

/** @suppress */
@Deprecated("This function delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
@Deprecated(
"This function delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
ReplaceWith("this.scheduler.advanceUntilIdle()"),
level = DeprecationLevel.WARNING)
level = DeprecationLevel.WARNING
)
override fun advanceUntilIdle(): Long {
val oldTime = scheduler.currentTime
scheduler.advanceUntilIdle()
return scheduler.currentTime - oldTime
}

/** @suppress */
@Deprecated("This function delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
@Deprecated(
"This function delegates to the test scheduler, which may cause confusing behavior unless made explicit.",
ReplaceWith("this.scheduler.runCurrent()"),
level = DeprecationLevel.WARNING)
level = DeprecationLevel.WARNING
)
override fun runCurrent(): Unit = scheduler.runCurrent()

/** @suppress */
Expand Down

0 comments on commit 9105415

Please sign in to comment.