Package org.robolectric.shadows
Class ShadowProcess
java.lang.Object
org.robolectric.shadows.ShadowProcess
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
protected static int
getThreadPriority
(int tid) Returns priority stored for the given thread.protected static void
killProcess
(int pid) Stores requests for killing processes.protected static int
myPid()
protected static String
Returns the name of the process.protected static int
myTid()
Returns the identifier (Thread.getId()
) of the current thread (Thread.currentThread()
).protected static int
myUid()
Returns the identifier of this process's uid.static void
reset()
static void
setPid
(int pid) Sets the identifier of this process.static void
setProcessName
(String processName) Sets the process name returned bymyProcessName()
.protected static void
setThreadPriority
(int priority) Stores priority for the current thread, but doesn't actually change it to not mess up with test runner.protected static void
setThreadPriority
(int tid, int priority) Stores priority for the given thread, but doesn't actually change it to not mess up with test runner.static void
setUid
(int uid) Sets the identifier of this process.static boolean
wasKilled
(int pid) Gets an indication of whether or not a process was killed (usingkillProcess(int)
).
-
Constructor Details
-
ShadowProcess
public ShadowProcess()
-
-
Method Details
-
killProcess
Stores requests for killing processes. Processe that were requested to be killed can be retrieved by callingwasKilled(int)
. UseclearKilledProcesses()
to clear the list. -
myPid
-
myUid
Returns the identifier of this process's uid. Unlike Android UIDs are randomly initialized to prevent tests from depending on any given value. Tests should access the current process UID viaProcess.myUid()
. You can override this value by callingsetUid(int)
. -
myTid
Returns the identifier (Thread.getId()
) of the current thread (Thread.currentThread()
). -
setThreadPriority
Stores priority for the current thread, but doesn't actually change it to not mess up with test runner. Unlike real implementation does not throw any exceptions. -
setThreadPriority
Stores priority for the given thread, but doesn't actually change it to not mess up with test runner. Unlike real implementation does not throw any exceptions.- Parameters:
tid
- The identifier of the thread. If equals zero, the identifier of the calling thread will be used.priority
- The priority to be set for the thread. The range of values accepted is specified byProcess.setThreadPriority(int, int)
, which is [-20,19].
-
getThreadPriority
Returns priority stored for the given thread.- Parameters:
tid
- The identifier of the thread. If equals zero, the identifier of the calling thread will be used.
-
clearKilledProcesses
public static void clearKilledProcesses() -
setUid
public static void setUid(int uid) Sets the identifier of this process. -
setPid
public static void setPid(int pid) Sets the identifier of this process. -
reset
-
wasKilled
public static boolean wasKilled(int pid) Gets an indication of whether or not a process was killed (usingkillProcess(int)
). -
myProcessName
Returns the name of the process. You can override this value by callingsetProcessName(String)
.- Returns:
- process name.
-
setProcessName
Sets the process name returned bymyProcessName()
.- Parameters:
processName
- New process name to set. Cannot be null.
-