AndroidRuntime implements RuntimeDialect { @Override public String getCallerClassName(final int depth) { return getCallerStackTraceElement(depth + 1).getClassName(); } AndroidRuntime(); @Override boolean isAndroid(); @Override String getDefaultWriter(); @Override long getProcessId(); @Override Timestamp getStartTime(); @Override String getCallerClassName(final int depth); @Override String getCallerClassName(final String loggerClassName); @Override StackTraceElement getCallerStackTraceElement(final int depth); @Override StackTraceElement getCallerStackTraceElement(final String loggerClassName); @Override Timestamp createTimestamp(); @Override TimestampFormatter createTimestampFormatter(final String pattern, final Locale locale);  }
@Test public void callerClassNameByIndex() { AndroidRuntime runtime = new AndroidRuntime(); Method method = Whitebox.getMethod(AndroidRuntimeTest.class, "fillStackTraceElements", Thread.class, StackTraceElement[].class); Whitebox.setInternalState(runtime, Method.class, method); Whitebox.setInternalState(runtime, int.class, 5); assertThat(runtime.getCallerClassName(1)).isEqualTo(AndroidRuntimeTest.class.getName()); }
@Test public void callerClassNameBySuccessor() { AndroidRuntime runtime = new AndroidRuntime(); Method method = Whitebox.getMethod(AndroidRuntimeTest.class, "fillStackTraceElements", Thread.class, StackTraceElement[].class); Whitebox.setInternalState(runtime, Method.class, method); Whitebox.setInternalState(runtime, int.class, 5); assertThat(runtime.getCallerClassName(AndroidRuntime.class.getName())).isEqualTo(AndroidRuntimeTest.class.getName()); }