public enum

WorkManagerTestInitHelper.ExecutorsMode

extends java.lang.Enum<WorkManagerTestInitHelper.ExecutorsMode>

 java.lang.Object

↳java.lang.Enum<WorkManagerTestInitHelper.ExecutorsMode>

↳androidx.work.testing.WorkManagerTestInitHelper.ExecutorsMode

Overview

Modes that control which executors are used in tests.

Summary

Enum Constants
LEGACY_OVERRIDE_WITH_SYNCHRONOUS_EXECUTORSPreserve old behavior of WorkManagerTestInitHelper.initializeTestWorkManager(Context) and WorkManagerTestInitHelper.initializeTestWorkManager(Context, Configuration).
PRESERVE_EXECUTORSUse executors as they are configured in passed Configuration and preserving real main thread.
USE_TIME_BASED_SCHEDULINGLike WorkManagerTestInitHelper.ExecutorsMode.PRESERVE_EXECUTORS, but uses the real Clock and RunnableScheduler in the provided Configuration instead of the TestDriver setDelayMet() methods to run scheduled work.
Methods
public static WorkManagerTestInitHelper.ExecutorsModevalueOf(java.lang.String name)

public static WorkManagerTestInitHelper.ExecutorsModevalues()

from java.lang.Enum<E>clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
from java.lang.ObjectgetClass, notify, notifyAll, wait, wait, wait

Enum Constants

PRESERVE_EXECUTORS

Use executors as they are configured in passed Configuration and preserving real main thread.

LEGACY_OVERRIDE_WITH_SYNCHRONOUS_EXECUTORS

Preserve old behavior of WorkManagerTestInitHelper.initializeTestWorkManager(Context) and WorkManagerTestInitHelper.initializeTestWorkManager(Context, Configuration).

In this mode SynchronousExecutor is used instead of main thread. Similarly, SynchronousExecutor is used as Configuration.getTaskExecutor(), unless Configuration.getTaskExecutor() was explicitly set in configuration passed in WorkManagerTestInitHelper.initializeTestWorkManager(Context, Configuration, WorkManagerTestInitHelper.ExecutorsMode)

USE_TIME_BASED_SCHEDULING

Like WorkManagerTestInitHelper.ExecutorsMode.PRESERVE_EXECUTORS, but uses the real Clock and RunnableScheduler in the provided Configuration instead of the TestDriver setDelayMet() methods to run scheduled work.

Work will be passed to RunnableScheduler with appropriate time-based delay, and the RunnableScheduler must reschedule the work itself when the clock delay has passed. TestDriver.setInitialDelayMet(UUID) and TestDriver.setPeriodDelayMet(UUID) throw exceptions when this configuration is used.

This mode is intended for integrated fake clock / schedule test frameworks, eg. with

Methods

public static WorkManagerTestInitHelper.ExecutorsMode valueOf(java.lang.String name)