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

Unified Diff: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.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/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java
diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java
deleted file mode 100644
index 0760b6459509997cbcd55eea0e271176b31a0553..0000000000000000000000000000000000000000
--- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/HistoryUtils.java
+++ /dev/null
@@ -1,194 +0,0 @@
-// Copyright 2012 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.test.util;
-
-import android.app.Instrumentation;
-
-import static org.chromium.base.test.util.ScalableTimeout.ScaleTimeout;
-
-import org.chromium.base.test.util.InstrumentationUtils;
-import org.chromium.content.browser.ContentView;
-import org.chromium.content.browser.ContentViewCore;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Collection of utilities related to the UiThread for navigating
- * through and working with browser forward and back history.
- */
-public class HistoryUtils {
-
- protected static final long WAIT_TIMEOUT_SECONDS = ScaleTimeout(15);
-
- /**
- * Calls {@link ContentView#canGoBack()} on UI thread.
- *
- * @param instrumentation an Instrumentation instance.
- * @param contentViewCore a ContentViewCore instance.
- * @return result of {@link ContentView#canGoBack()}
- * @throws Throwable
- */
- public static boolean canGoBackOnUiThread(Instrumentation instrumentation,
- final ContentViewCore contentViewCore) throws Throwable {
- return InstrumentationUtils.runOnMainSyncAndGetResult(
- instrumentation, new Callable<Boolean>() {
- @Override
- public Boolean call() {
- return contentViewCore.canGoBack();
- }
- });
- }
-
- /**
- * Calls {@link ContentView#canGoToOffset(int)} on UI thread.
- *
- * @param instrumentation an Instrumentation instance.
- * @param contentViewCore a ContentViewCore instance.
- * @param offset The number of steps to go on the UI thread, with negative
- * representing going back.
- * @return result of {@link ContentView#canGoToOffset(int)}
- * @throws Throwable
- */
- public static boolean canGoToOffsetOnUiThread(Instrumentation instrumentation,
- final ContentViewCore contentViewCore, final int offset) throws Throwable {
- return InstrumentationUtils.runOnMainSyncAndGetResult(
- instrumentation, new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- return contentViewCore.canGoToOffset(offset);
- }
- });
- }
-
- /**
- * Calls {@link ContentView#canGoForward()} on UI thread.
- *
- * @param instrumentation an Instrumentation instance.
- * @param contentViewCore a ContentViewCore instance.
- * @return result of {@link ContentView#canGoForward()}
- * @throws Throwable
- */
- public static boolean canGoForwardOnUiThread(Instrumentation instrumentation,
- final ContentViewCore contentViewCore) throws Throwable {
- return InstrumentationUtils.runOnMainSyncAndGetResult(
- instrumentation, new Callable<Boolean>() {
- @Override
- public Boolean call() {
- return contentViewCore.canGoForward();
- }
- });
- }
-
- /**
- * Calls {@link ContentView#clearHistory()} on UI thread.
- *
- * @param instrumentation an Instrumentation instance.
- * @param contentViewCore a ContentViewCore instance.
- * @throws Throwable
- */
- public static void clearHistoryOnUiThread(Instrumentation instrumentation,
- final ContentViewCore contentViewCore) throws Throwable {
- instrumentation.runOnMainSync(new Runnable() {
- @Override
- public void run() {
- contentViewCore.clearHistory();
- }
- });
- }
-
- /**
- * Calls {@link ContentView#getUrl()} on UI Thread to get the current URL.
- *
- * @param instrumentation an Instrumentation instance.
- * @param contentViewCore a ContentViewCore instance.
- * @return the URL of the current page
- * @throws Throwable
- */
- public static String getUrlOnUiThread(Instrumentation instrumentation,
- final ContentViewCore contentViewCore) throws Throwable {
- return InstrumentationUtils.runOnMainSyncAndGetResult(
- instrumentation, new Callable<String>() {
- @Override
- public String call() throws Exception {
- return contentViewCore.getUrl();
- }
- });
- }
-
- /**
- * Performs navigation in the history on UI thread and waits until
- * onPageFinished is called.
- *
- * @param instrumentation an Instrumentation instance.
- * @param contentViewCore a ContentViewCore instance.
- * @param onPageFinishedHelper the CallbackHelper instance associated with the onPageFinished
- * callback of contentViewCore.
- * @param offset
- * @throws Throwable
- */
- public static void goToOffsetSync(Instrumentation instrumentation,
- final ContentViewCore contentViewCore, CallbackHelper onPageFinishedHelper,
- final int offset) throws Throwable {
- int currentCallCount = onPageFinishedHelper.getCallCount();
- instrumentation.runOnMainSync(new Runnable() {
- @Override
- public void run() {
- contentViewCore.goToOffset(offset);
- }
- });
-
- // Wait for onPageFinished event or timeout after 30s
- onPageFinishedHelper.waitForCallback(currentCallCount, 1, 30, TimeUnit.SECONDS);
- }
-
- /**
- * Goes back on UI thread and waits until onPageFinished is called or until
- * it times out.
- *
- * @param instrumentation an Instrumentation instance.
- * @param contentViewCore a ContentViewCore instance.
- * @param onPageFinishedHelper the CallbackHelper instance associated with the onPageFinished
- * callback of contentViewCore.
- * @throws Throwable
- */
- public static void goBackSync(Instrumentation instrumentation,
- final ContentViewCore contentViewCore,
- CallbackHelper onPageFinishedHelper) throws Throwable {
- int currentCallCount = onPageFinishedHelper.getCallCount();
- instrumentation.runOnMainSync(new Runnable() {
- @Override
- public void run() {
- contentViewCore.goBack();
- }
- });
-
- onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_SECONDS,
- TimeUnit.SECONDS);
- }
-
- /**
- * Goes forward on UI thread and waits until onPageFinished is called or until
- * it times out.
- *
- * @param instrumentation an Instrumentation instance.
- * @param contentViewCore a ContentViewCore instance.
- * @throws Throwable
- */
- public static void goForwardSync(Instrumentation instrumentation,
- final ContentViewCore contentViewCore,
- CallbackHelper onPageFinishedHelper) throws Throwable {
- int currentCallCount = onPageFinishedHelper.getCallCount();
- instrumentation.runOnMainSync(new Runnable() {
- @Override
- public void run() {
- contentViewCore.goForward();
- }
- });
-
- onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_SECONDS,
- TimeUnit.SECONDS);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698