public void testShouldOverrideUrlLoading_OnReceivedError() {
    try {
      String url = "file:///android_asset/does_not_exist.html";
      ShouldOverrideUrlLoadingHelper mShouldOverrideUrlLoadingHelper =
          mTestHelperBridge.getShouldOverrideUrlLoadingHelper();
      OnReceivedErrorHelper onReceivedErrorHelper = mTestHelperBridge.getOnReceivedErrorHelper();
      int onReceivedErrorCallCount = onReceivedErrorHelper.getCallCount();
      int shouldOverrideUrlLoadingCallCount = mShouldOverrideUrlLoadingHelper.getCallCount();
      mShouldOverrideUrlLoadingHelper.setShouldOverrideUrlLoadingReturnValue(true);
      loadUrlSync(url);
      mShouldOverrideUrlLoadingHelper.waitForCallback(shouldOverrideUrlLoadingCallCount);
      assertEquals(onReceivedErrorCallCount, onReceivedErrorHelper.getCallCount());

      onReceivedErrorCallCount = onReceivedErrorHelper.getCallCount();
      shouldOverrideUrlLoadingCallCount = mShouldOverrideUrlLoadingHelper.getCallCount();
      mShouldOverrideUrlLoadingHelper.setShouldOverrideUrlLoadingReturnValue(false);
      loadUrlSync(url);
      mShouldOverrideUrlLoadingHelper.waitForCallback(shouldOverrideUrlLoadingCallCount);
      assertNotSame(onReceivedErrorCallCount, onReceivedErrorHelper.getCallCount());
    } catch (Exception e) {
      assertTrue(false);
      e.printStackTrace();
    } catch (Throwable e) {
      assertTrue(false);
      e.printStackTrace();
    }
  }
 public void testShouldOverrideUrlLoading_OnPageStarted() {
   try {
     OnPageStartedHelper onPageStartedHelper = mTestHelperBridge.getOnPageStartedHelper();
     ShouldOverrideUrlLoadingHelper mShouldOverrideUrlLoadingHelper =
         mTestHelperBridge.getShouldOverrideUrlLoadingHelper();
     loadDataSync(
         null, CommonResources.makeHtmlPageWithSimpleLinkTo(DATA_URL), "text/html", false);
     final int shouldOverrideUrlLoadingCallCount = mShouldOverrideUrlLoadingHelper.getCallCount();
     final int onPageStartedCallCount = onPageStartedHelper.getCallCount();
     mShouldOverrideUrlLoadingHelper.setShouldOverrideUrlLoadingReturnValue(true);
     clickOnElementId("link", null);
     mShouldOverrideUrlLoadingHelper.waitForCallback(shouldOverrideUrlLoadingCallCount);
     assertEquals(onPageStartedCallCount, onPageStartedHelper.getCallCount());
   } catch (Exception e) {
     assertTrue(false);
     e.printStackTrace();
   } catch (Throwable e) {
     assertTrue(false);
     e.printStackTrace();
   }
 }