Ejemplo n.º 1
0
  @MediumTest
  @Feature({"Location"})
  public void testWatchHideShowStop() throws Throwable {

    startGeolocationWatchPosition();
    pollForPositionCallback();
    ensureGeolocationRunning(true);

    // Now hide the ContentView and ensure that geolocation stops.
    hideContentViewOnUiThread();
    ensureGeolocationRunning(false);

    mJavascriptHelper.evaluateJavaScriptForTests(getWebContents(), "positionCount = 0");
    mJavascriptHelper.waitUntilHasValue();

    // Show the ContentView again and ensure that geolocation starts again.
    showContentViewOnUiThread();
    pollForPositionCallback();
    ensureGeolocationRunning(true);

    // Navigate away and ensure that geolocation stops.
    loadUrl(
        getContentViewCore().getWebContents().getNavigationController(),
        mTestCallbackHelperContainer,
        new LoadUrlParams("about:blank"));
    ensureGeolocationRunning(false);
  }
Ejemplo n.º 2
0
  private void pollForPositionCallback() throws Throwable {
    mJavascriptHelper.evaluateJavaScriptForTests(getWebContents(), "positionCount = 0");
    mJavascriptHelper.waitUntilHasValue();
    assertEquals(0, Integer.parseInt(mJavascriptHelper.getJsonResultAndClear()));

    CriteriaHelper.pollForCriteria(
        new Criteria() {
          @Override
          public boolean isSatisfied() {
            mJavascriptHelper.evaluateJavaScriptForTests(getWebContents(), "positionCount");
            try {
              mJavascriptHelper.waitUntilHasValue();
            } catch (Exception e) {
              fail();
            }
            return Integer.parseInt(mJavascriptHelper.getJsonResultAndClear()) > 0;
          }
        });
  }
Ejemplo n.º 3
0
 private void startGeolocationWatchPosition() throws Throwable {
   mJavascriptHelper.evaluateJavaScriptForTests(getWebContents(), "initiate_watchPosition();");
   mJavascriptHelper.waitUntilHasValue();
 }