Package org.robolectric.shadows
Class ShadowProcess
java.lang.Object
org.robolectric.shadows.ShadowProcess
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidprotected static intgetThreadPriority(int tid) Returns priority stored for the given thread.protected static voidkillProcess(int pid) Stores requests for killing processes.protected static intmyPid()protected static StringReturns the name of the process.protected static intmyTid()Returns the identifier (Thread.getId()) of the current thread (Thread.currentThread()).protected static intmyUid()Returns the identifier of this process's uid.static voidreset()static voidsetPid(int pid) Sets the identifier of this process.static voidsetProcessName(String processName) Sets the process name returned bymyProcessName().protected static voidsetThreadPriority(int priority) Stores priority for the current thread, but doesn't actually change it to not mess up with test runner.protected static voidsetThreadPriority(int tid, int priority) Stores priority for the given thread, but doesn't actually change it to not mess up with test runner.static voidsetUid(int uid) Sets the identifier of this process.static booleanwasKilled(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.
-