Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(936)

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/ContentViewLocationTest.java

Issue 141533006: [Android] Move the java content/ package to content_public/ to start the split. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Small fixes and findbugs line update Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/javatests/src/org/chromium/content/browser/ContentViewLocationTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewLocationTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ContentViewLocationTest.java
deleted file mode 100644
index 3e6b3f7ac431abe36e1809242a5b907ffae3c162..0000000000000000000000000000000000000000
--- a/content/public/android/javatests/src/org/chromium/content/browser/ContentViewLocationTest.java
+++ /dev/null
@@ -1,173 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.content.browser;
-
-import android.test.suitebuilder.annotation.MediumTest;
-
-import org.chromium.base.test.util.Feature;
-import org.chromium.content.browser.test.util.Criteria;
-import org.chromium.content.browser.test.util.CriteriaHelper;
-import org.chromium.content.browser.test.util.MockLocationProvider;
-import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
-import org.chromium.content_shell_apk.ContentShellTestBase;
-
-/**
- * Test suite for ensureing that Geolocation interacts as expected
- * with ContentView APIs - e.g. that it's started and stopped as the
- * ContentView is hidden or shown.
- */
-public class ContentViewLocationTest extends ContentShellTestBase {
-
- private TestCallbackHelperContainer mTestCallbackHelperContainer;
- private TestCallbackHelperContainer.OnEvaluateJavaScriptResultHelper mJavascriptHelper;
- private MockLocationProvider mMockLocationProvider;
-
- private void hideContentViewOnUiThread() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getContentView().onHide();
- }
- });
- }
-
- private void showContentViewOnUiThread() {
- getInstrumentation().runOnMainSync(new Runnable() {
- @Override
- public void run() {
- getContentView().onShow();
- }
- });
- }
-
- private void pollForPositionCallback() throws Throwable {
- mJavascriptHelper.evaluateJavaScript(getContentViewCore(),
- "positionCount = 0");
- mJavascriptHelper.waitUntilHasValue();
- assertEquals(0, Integer.parseInt(mJavascriptHelper.getJsonResultAndClear()));
-
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
- @Override
- public boolean isSatisfied() {
- mJavascriptHelper.evaluateJavaScript(getContentViewCore(), "positionCount");
- try {
- mJavascriptHelper.waitUntilHasValue();
- } catch (Exception e) {
- fail();
- }
- return Integer.parseInt(mJavascriptHelper.getJsonResultAndClear()) > 0;
- }
- }));
- }
-
- private void startGeolocationWatchPosition() throws Throwable {
- mJavascriptHelper.evaluateJavaScript(getContentViewCore(),
- "initiate_watchPosition();");
- mJavascriptHelper.waitUntilHasValue();
- }
-
- private void ensureGeolocationRunning(final boolean running) throws Exception {
- assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
- @Override
- public boolean isSatisfied() {
- return mMockLocationProvider.isRunning() == running;
- }
- }));
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- mMockLocationProvider = new MockLocationProvider();
- LocationProviderFactory.setLocationProviderImpl(mMockLocationProvider);
-
- try {
- startActivityWithTestUrl("content/geolocation.html");
- } catch (Throwable t) {
- fail();
- }
-
- mTestCallbackHelperContainer = new TestCallbackHelperContainer(getContentView());
- mJavascriptHelper = mTestCallbackHelperContainer.getOnEvaluateJavaScriptResultHelper();
-
- ensureGeolocationRunning(false);
- }
-
- @Override
- protected void tearDown() throws Exception {
- mMockLocationProvider.stopUpdates();
- super.tearDown();
- }
-
- @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.evaluateJavaScript(getContentViewCore(),
- "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(getContentView(), mTestCallbackHelperContainer, new LoadUrlParams("about:blank"));
- ensureGeolocationRunning(false);
- }
-
- @MediumTest
- @Feature({"Location"})
- public void testHideWatchResume() throws Throwable {
- hideContentViewOnUiThread();
- startGeolocationWatchPosition();
- ensureGeolocationRunning(false);
-
- showContentViewOnUiThread();
- pollForPositionCallback();
- ensureGeolocationRunning(true);
- }
-
- @MediumTest
- @Feature({"Location"})
- public void testWatchHideNewWatchShow() throws Throwable {
- startGeolocationWatchPosition();
- pollForPositionCallback();
- ensureGeolocationRunning(true);
-
- hideContentViewOnUiThread();
-
- // Make sure that when starting a new watch while paused we still don't
- // start up geolocation until we show the content view again.
- startGeolocationWatchPosition();
- ensureGeolocationRunning(false);
-
- showContentViewOnUiThread();
- pollForPositionCallback();
- ensureGeolocationRunning(true);
- }
-
- @MediumTest
- @Feature({"Location"})
- public void testHideWatchStopShow() throws Throwable {
- hideContentViewOnUiThread();
- startGeolocationWatchPosition();
- ensureGeolocationRunning(false);
-
- loadUrl(getContentView(), mTestCallbackHelperContainer, new LoadUrlParams("about:blank"));
- showContentViewOnUiThread();
- ensureGeolocationRunning(false);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698