Package org.robolectric.shadows
Class ShadowTrace
- java.lang.Object
-
- org.robolectric.shadows.ShadowTrace
-
@Implements(android.os.Trace.class) public class ShadowTrace extends Object
Shadow implementation forTrace, which stores the traces locally in arrays (unlike the real implementation) and allows reading them.The shadow doesn't enforce the constrains by default (e.g., null section names, or incorrect {@link ShadowTrace.beginSection(String)} / {@link ShadowTrace.endSection()} sequences), but can be configured to do so by calling {@link ShadowTrace.setCrashOnIncorrectUsage(boolean)}.
-
-
Constructor Summary
Constructors Constructor Description ShadowTrace()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static voidbeginSection(String sectionName)Starts a new trace section with given name.static voiddoNotUseSetCrashOnIncorrectUsage(boolean crashOnIncorrectUsage)Do not use this method unless absolutely necessary.protected static voidendSection()Ends the most recent active trace section.static Deque<String>getCurrentSections()Returns a stack of the currently active trace sections for the current thread.static Queue<String>getPreviousSections()Returns a queue of all the previously active trace sections for the current thread.protected static booleanisEnabled()Returns whether systrace is enabled.protected static booleanisTagEnabled(long traceTag)static voidreset()Resets internal lists of active trace sections.protected static voidsetAppTracingAllowed(boolean appTracingAllowed)static voidsetEnabled(boolean enabled)Sets the systrace to enabled or disabled.
-
-
-
Method Detail
-
beginSection
@Implementation(minSdk=18) protected static void beginSection(String sectionName)
Starts a new trace section with given name.
-
endSection
@Implementation(minSdk=18) protected static void endSection()
Ends the most recent active trace section.
-
isTagEnabled
@Implementation(minSdk=18) protected static boolean isTagEnabled(long traceTag)
-
setAppTracingAllowed
@Implementation(minSdk=18) protected static void setAppTracingAllowed(boolean appTracingAllowed)
-
isEnabled
@Implementation(minSdk=29) protected static boolean isEnabled()
Returns whether systrace is enabled.
-
setEnabled
public static void setEnabled(boolean enabled)
Sets the systrace to enabled or disabled.
-
getCurrentSections
public static Deque<String> getCurrentSections()
Returns a stack of the currently active trace sections for the current thread.
-
getPreviousSections
public static Queue<String> getPreviousSections()
Returns a queue of all the previously active trace sections for the current thread.
-
doNotUseSetCrashOnIncorrectUsage
public static void doNotUseSetCrashOnIncorrectUsage(boolean crashOnIncorrectUsage)
Do not use this method unless absolutely necessary. Prefer fixing the tests instead.Sets whether to crash on incorrect usage (e.g., calling
endSection()beforebeginSection(java.lang.String). Default value -false.
-
reset
@Resetter public static void reset()
Resets internal lists of active trace sections.
-
-