public class RuntimeEnvironment extends Object
Modifier and Type | Field | Description |
---|---|---|
static Application |
application |
Deprecated.
Please migrate to
androidx.test.core.app.ApplicationProvider#getApplicationContext |
static Path |
compileTimeSystemResourcesFile |
|
static Context |
systemContext |
Constructor | Description |
---|---|
RuntimeEnvironment() |
Modifier and Type | Method | Description |
---|---|---|
static Number |
castNativePtr(long ptr) |
|
static Object |
getActivityThread() |
|
static Path |
getAndroidFrameworkJarPath() |
|
static int |
getApiLevel() |
|
static ResourceTable |
getAppResourceTable() |
|
static ResourceTable |
getCompileTimeResourceTable() |
|
static Thread |
getMainThread() |
Retrieves the main thread.
|
static Scheduler |
getMasterScheduler() |
Retrieves the current master scheduler.
|
static String |
getQualifiers() |
Returns a qualifier string describing the current
Configuration of the system resources. |
static String |
getQualifiers(Configuration configuration,
DisplayMetrics displayMetrics) |
Returns a qualifier string describing the given configuration and display metrics.
|
static ResourceTable |
getSystemResourceTable() |
|
static TempDirectory |
getTempDirectory() |
|
static boolean |
isMainThread() |
Tests if the current thread is currently set as the main thread.
|
static boolean |
isMainThread(Thread thread) |
Tests if the given thread is currently set as the main thread.
|
static void |
setActivityThread(Object newActivityThread) |
|
static void |
setAndroidFrameworkJarPath(Path localArtifactPath) |
|
static void |
setAppResourceTable(ResourceTable appResourceTable) |
|
static void |
setCompileTimeResourceTable(ResourceTable compileTimeResourceTable) |
|
static void |
setMainThread(Thread newMainThread) |
Sets the main thread.
|
static void |
setMasterScheduler(Scheduler masterScheduler) |
Sets the current master scheduler.
|
static void |
setQualifiers(String newQualifiers) |
Overrides the current device configuration.
|
static void |
setSystemResourceTable(ResourceTable systemResourceTable) |
|
static void |
setTempDirectory(TempDirectory tempDirectory) |
|
static void |
setUseLegacyResources(boolean useLegacyResources) |
Deprecated.
Do not use.
|
static boolean |
useLegacyResources() |
Deprecated.
Do not use.
|
public static Context systemContext
@Deprecated public static Application application
androidx.test.core.app.ApplicationProvider#getApplicationContext
public static Path compileTimeSystemResourcesFile
public static boolean isMainThread(Thread thread)
thread
- the thread to test.isMainThread()
public static boolean isMainThread()
Not supported in realistic looper mode.
public static Thread getMainThread()
RuntimeEnvironment
class.
Not supported in realistic looper mode.
setMainThread(Thread)
,
isMainThread()
public static void setMainThread(Thread newMainThread)
RuntimeEnvironment
class.
Not supported in realistic looper mode.
newMainThread
- the new main thread.setMainThread(Thread)
,
isMainThread()
public static Object getActivityThread()
public static void setActivityThread(Object newActivityThread)
public static String getQualifiers()
Configuration
of the system resources.public static String getQualifiers(Configuration configuration, DisplayMetrics displayMetrics)
configuration
- the configuration.displayMetrics
- the display metrics.public static void setQualifiers(String newQualifiers)
If {@param newQualifiers} starts with a plus ('+'), the prior configuration is used as the base configuration, with the given changes applied additively. Otherwise, default values are used for unspecified properties, as described here.
newQualifiers
- the qualifiers to applypublic static int getApiLevel()
public static Number castNativePtr(long ptr)
public static Scheduler getMasterScheduler()
Looper
, and if the global scheduler option is set it is also used for
the background scheduler and for all other Looper
ssee org.robolectric.Robolectric#getForegroundThreadScheduler()
see org.robolectric.Robolectric#getBackgroundThreadScheduler()
public static void setMasterScheduler(Scheduler masterScheduler)
getMasterScheduler()
for details.
Note that this method is primarily intended to be called by the Robolectric core setup code.
Changing the master scheduler during a test will have unpredictable results.masterScheduler
- the new master scheduler.see org.robolectric.Robolectric#getForegroundThreadScheduler()
see org.robolectric.Robolectric#getBackgroundThreadScheduler()
public static void setSystemResourceTable(ResourceTable systemResourceTable)
public static void setAppResourceTable(ResourceTable appResourceTable)
public static ResourceTable getSystemResourceTable()
public static ResourceTable getAppResourceTable()
public static void setCompileTimeResourceTable(ResourceTable compileTimeResourceTable)
public static ResourceTable getCompileTimeResourceTable()
public static void setTempDirectory(TempDirectory tempDirectory)
public static TempDirectory getTempDirectory()
public static void setAndroidFrameworkJarPath(Path localArtifactPath)
public static Path getAndroidFrameworkJarPath()
@Deprecated public static boolean useLegacyResources()
@Deprecated public static void setUseLegacyResources(boolean useLegacyResources)