TurbolinksSession implements TurbolinksScrollUpCallback { @SuppressLint("JavascriptInterface") public void addJavascriptInterface(Object object, String name) { if (TextUtils.equals(name, JAVASCRIPT_INTERFACE_NAME)) { throw new IllegalArgumentException(JAVASCRIPT_INTERFACE_NAME + " is a reserved Javascript Interface name."); } if (javascriptInterfaces.get(name) == null) { javascriptInterfaces.put(name, object); webView.addJavascriptInterface(object, name); TurbolinksLog.d("Adding JavascriptInterface: " + name + " for " + object.getClass().toString()); } } private  TurbolinksSession(final Context context); static TurbolinksSession getNew(Context context); static TurbolinksSession getDefault(Context context); static void resetDefault(); static void setDebugLoggingEnabled(boolean enabled); TurbolinksSession activity(Activity activity); TurbolinksSession adapter(TurbolinksAdapter turbolinksAdapter); TurbolinksSession view(TurbolinksView turbolinksView); void visit(String location); TurbolinksSession progressView(View progressView, int progressIndicatorResId, int progressIndicatorDelay); TurbolinksSession restoreWithCachedSnapshot(boolean restoreWithCachedSnapshot); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void visitProposedToLocationWithAction(final String location, final String action); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void visitStarted(String visitIdentifier, boolean visitHasCachedSnapshot); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void visitRequestCompleted(String visitIdentifier); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void visitRequestFailedWithStatusCode(final String visitIdentifier, final int statusCode); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void visitRendered(String visitIdentifier); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void visitCompleted(String visitIdentifier, String restorationIdentifier); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void pageInvalidated(); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void hideProgressView(final String visitIdentifier); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void setTurbolinksIsReady(boolean turbolinksIsReady); @SuppressWarnings("unused") @android.webkit.JavascriptInterface void turbolinksDoesNotExist(); @SuppressLint("JavascriptInterface") void addJavascriptInterface(Object object, String name); Activity getActivity(); WebView getWebView(); void resetToColdBoot(); void runJavascript(final String functionName, final Object... params); void runJavascriptRaw(String rawJavascript); void setScreenshotsEnabled(boolean enabled); void setPullToRefreshEnabled(boolean enabled); boolean turbolinksIsReady(); void visitLocationWithAction(String location, String action); @Override boolean canChildScrollUp();  }
@Test(expected = IllegalArgumentException.class) public void addJavascriptInterfaceWithReservedName() { turbolinksSession.addJavascriptInterface(new Object(), TurbolinksSession.JAVASCRIPT_INTERFACE_NAME); }
@Test public void addJavascriptInterfaceAddsToMap() { assertThat(turbolinksSession.javascriptInterfaces.size()).isEqualTo(0); turbolinksSession.addJavascriptInterface(new Object(), "TestJavascriptInterface"); assertThat(turbolinksSession.javascriptInterfaces.size()).isEqualTo(1); }