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 for
Trace, which stores the traces locally in arrays (unlike the
real implementation) and allows reading them.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classShadowTrace.AsyncTraceSectionAutoValue representation of a trace triggered by one of the async apisstatic classShadowTrace.CounterCounters emitted with the setCounter API -
Constructor Summary
Constructors Constructor Description ShadowTrace() -
Method Summary
Modifier and Type Method Description protected static voidbeginAsyncSection(String sectionName, int cookie)Starts a new async trace section with given name.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 voidendAsyncSection(String sectionName, int cookie)Ends async trace trace section.protected static voidendSection()Ends the most recent active trace section.static com.google.common.collect.ImmutableList<ShadowTrace.Counter>getCounters()Returns an ordered list of previous counters.static com.google.common.collect.ImmutableSet<ShadowTrace.AsyncTraceSection>getCurrentAsyncSections()Returns a set of all the current active async trace sections.static Deque<String>getCurrentSections()Returns a stack of the currently active trace sections for the current thread.static com.google.common.collect.ImmutableSet<ShadowTrace.AsyncTraceSection>getPreviousAsyncSections()Returns a set of all the previously active async trace sections.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 longnativeGetEnabledTags()static voidreset()Resets internal lists of active trace sections.protected static voidsetAppTracingAllowed(boolean appTracingAllowed)protected static voidsetCounter(String counterName, long counterValue)static voidsetEnabled(boolean enabled)Sets the systrace to enabled or disabled.
-
Constructor Details
-
ShadowTrace
public ShadowTrace()
-
-
Method Details
-
beginSection
Starts a new trace section with given name. -
endSection
Ends the most recent active trace section. -
beginAsyncSection
Starts a new async trace section with given name. -
endAsyncSection
Ends async trace trace section. -
nativeGetEnabledTags
-
setAppTracingAllowed
-
isEnabled
Returns whether systrace is enabled. -
setCounter
-
setEnabled
public static void setEnabled(boolean enabled)Sets the systrace to enabled or disabled. -
getCurrentSections
Returns a stack of the currently active trace sections for the current thread. -
getPreviousSections
Returns a queue of all the previously active trace sections for the current thread. -
getCurrentAsyncSections
public static com.google.common.collect.ImmutableSet<ShadowTrace.AsyncTraceSection> getCurrentAsyncSections()Returns a set of all the current active async trace sections. -
getPreviousAsyncSections
public static com.google.common.collect.ImmutableSet<ShadowTrace.AsyncTraceSection> getPreviousAsyncSections()Returns a set of all the previously active async trace sections. -
getCounters
Returns an ordered list of previous counters. -
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 -true. -
reset
Resets internal lists of active trace sections.
-