public class RuntimeEnvironment extends Object
Modifier and Type | Field and Description |
---|---|
static Application |
application
Deprecated.
Please migrate to
androidx.test.core.app.ApplicationProvider#getApplicationContext |
static Path |
compileTimeSystemResourcesFile |
static Context |
systemContext |
Constructor and Description |
---|
RuntimeEnvironment() |
Modifier and Type | Method and 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)
Tests if the given thread is currently set as the main thread.
thread
- the thread to test.isMainThread()
public static boolean isMainThread()
Tests if the current thread is currently set as the main thread.
public static Thread getMainThread()
Retrieves the main thread. The main thread is the thread to which the main looper is attached. Defaults to the thread that initialises the RuntimeEnvironment class.
setMainThread(Thread)
,
isMainThread()
public static void setMainThread(Thread newMainThread)
Sets the main thread. The main thread is the thread to which the main looper is attached. Defaults to the thread that initialises the RuntimeEnvironment class.
newMainThread
- the new main thread.setMainThread(Thread)
,
isMainThread()
public static Object getActivityThread()
public static void setActivityThread(Object newActivityThread)
public static String getQualifiers()
Returns a qualifier string describing the current Configuration
of the system resources.
public static String getQualifiers(Configuration configuration, DisplayMetrics displayMetrics)
Returns a qualifier string describing the given configuration and display metrics.
configuration
- the configuration.displayMetrics
- the display metrics.public static void setQualifiers(String newQualifiers)
Overrides the current device configuration.
If 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()
Retrieves the current master scheduler. This scheduler is always used by the main Looper
, and if the global scheduler option is set it is also used for the background scheduler and for all other Looper
s
see org.robolectric.Robolectric#getForegroundThreadScheduler()
see org.robolectric.Robolectric#getBackgroundThreadScheduler()
public static void setMasterScheduler(Scheduler masterScheduler)
Sets the current master scheduler. See 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()
Internal only.
@Deprecated public static void setUseLegacyResources(boolean useLegacyResources)
Internal only.