Commit 2806d886 authored by Yoland Yan's avatar Yoland Yan Committed by Commit Bot

Remove deprecated test base classes

Bug: 711517
Change-Id: I041ffd60657022e98196246bdff14f0e4d802f20
Reviewed-on: https://chromium-review.googlesource.com/882447Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Yoland Yan <yolandyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531943}
parent d949ea71
......@@ -467,7 +467,6 @@ android_library("content_javatests") {
"javatests/src/org/chromium/content/browser/JavaBridgeCoercionTest.java",
"javatests/src/org/chromium/content/browser/JavaBridgeFieldsTest.java",
"javatests/src/org/chromium/content/browser/JavaBridgeReturnValuesTest.java",
"javatests/src/org/chromium/content/browser/JavaBridgeTestBase.java",
"javatests/src/org/chromium/content/browser/JavaBridgeTestCommon.java",
"javatests/src/org/chromium/content/browser/MediaResourceGetterTest.java",
"javatests/src/org/chromium/content/browser/MediaSessionTest.java",
......
// 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;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.content_shell_apk.ContentShellActivity;
import org.chromium.content_shell_apk.ContentShellTestBase;
import org.chromium.content_shell_apk.ContentShellTestCommon.TestCommonCallback;
import java.lang.annotation.Annotation;
/**
* Common functionality for testing the Java Bridge.
*/
public class JavaBridgeTestBase
extends ContentShellTestBase implements TestCommonCallback<ContentShellActivity> {
private final JavaBridgeTestCommon mTestCommon = new JavaBridgeTestCommon(this);
/**
* Sets up the ContentView. Intended to be called from setUp().
*/
private void setUpContentView() throws Exception {
mTestCommon.setUpContentView();
}
@Override
protected void setUp() throws Exception {
super.setUp();
mTestCommon.setUpContentView();
}
public TestCallbackHelperContainer getTestCallBackHelperContainer() {
return mTestCommon.getTestCallBackHelperContainer();
}
protected void executeJavaScript(final String script) throws Throwable {
mTestCommon.executeJavaScript(script);
}
protected void injectObjectAndReload(final Object object, final String name) throws Exception {
injectObjectAndReload(object, name, null);
}
protected void injectObjectAndReload(final Object object, final String name,
final Class<? extends Annotation> requiredAnnotation) throws Exception {
injectObjectsAndReload(object, name, null, null, requiredAnnotation);
}
protected void injectObjectsAndReload(final Object object1, final String name1,
final Object object2, final String name2,
final Class<? extends Annotation> requiredAnnotation) throws Exception {
mTestCommon.injectObjectsAndReload(object1, name1, object2, name2, requiredAnnotation);
}
protected void synchronousPageReload() throws Throwable {
mTestCommon.synchronousPageReload();
}
}
......@@ -34,7 +34,6 @@ android_library("content_java_test_support") {
"javatests/src/org/chromium/content/browser/test/ChildProcessAllocatorSettingsHook.java",
"javatests/src/org/chromium/content/browser/test/ContentInstrumentationTestRunner.java",
"javatests/src/org/chromium/content/browser/test/ContentJUnit4ClassRunner.java",
"javatests/src/org/chromium/content/browser/test/NativeLibraryTestBase.java",
"javatests/src/org/chromium/content/browser/test/NativeLibraryTestCommon.java",
"javatests/src/org/chromium/content/browser/test/NativeLibraryTestRule.java",
"javatests/src/org/chromium/content/browser/test/util/ClickUtils.java",
......
// Copyright 2014 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;
import android.test.InstrumentationTestCase;
/**
* Test extension that adds support for loading and dealing with native libraries.
*/
public class NativeLibraryTestBase extends InstrumentationTestCase {
private final NativeLibraryTestCommon mTestCommon = new NativeLibraryTestCommon();
/**
* Loads the native library on the activity UI thread (must not be called from the UI thread).
*/
@SuppressWarnings("deprecation")
public void loadNativeLibraryNoBrowserProcess() {
mTestCommon.handleNativeInitialization(false, getInstrumentation());
}
/**
* Loads the native library on the activity UI thread (must not be called from the UI thread).
* After loading the library, this will initialize the browser process.
*/
@SuppressWarnings("deprecation")
public void loadNativeLibraryAndInitBrowserProcess() {
mTestCommon.handleNativeInitialization(true, getInstrumentation());
}
}
......@@ -187,7 +187,6 @@ android_library("content_shell_test_java") {
java_files = [
"javatests/src/org/chromium/content_shell_apk/ContentShellPreconditionsTest.java",
"javatests/src/org/chromium/content_shell_apk/ContentShellShellManagementTest.java",
"javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java",
"javatests/src/org/chromium/content_shell_apk/ContentShellTestCommon.java",
"javatests/src/org/chromium/content_shell_apk/ContentShellActivityTestRule.java",
"javatests/src/org/chromium/content_shell_apk/ContentShellUrlTest.java",
......
// 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_shell_apk;
import android.app.Instrumentation;
import android.content.Intent;
import org.chromium.base.test.BaseActivityInstrumentationTestCase;
import org.chromium.base.test.util.CallbackHelper;
import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.content.common.ContentSwitches;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.content_public.browser.NavigationController;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_shell.Shell;
import org.chromium.content_shell_apk.ContentShellActivityTestRule.RerunWithUpdatedContainerView;
import org.chromium.content_shell_apk.ContentShellTestCommon.TestCommonCallback;
import java.lang.reflect.AnnotatedElement;
import java.util.concurrent.ExecutionException;
/**
* Base test class for all ContentShell based tests.
*/
@CommandLineFlags.Add(ContentSwitches.ENABLE_TEST_INTENTS)
public class ContentShellTestBase extends BaseActivityInstrumentationTestCase<ContentShellActivity>
implements TestCommonCallback<ContentShellActivity> {
protected static final long WAIT_PAGE_LOADING_TIMEOUT_SECONDS =
ContentShellTestCommon.WAIT_PAGE_LOADING_TIMEOUT_SECONDS;
private ContentShellTestCommon mDelegate;
public ContentShellTestBase() {
super(ContentShellActivity.class);
mDelegate = new ContentShellTestCommon(this);
}
@Override
@SuppressWarnings("deprecation")
protected void setUp() throws Exception {
super.setUp();
mDelegate.assertScreenIsOn();
}
/**
* Starts the ContentShell activity and loads the given URL.
* The URL can be null, in which case will default to ContentShellActivity.DEFAULT_SHELL_URL.
*/
public ContentShellActivity launchContentShellWithUrl(String url) {
return mDelegate.launchContentShellWithUrl(url);
}
// TODO(cjhopman): These functions are inconsistent with launchContentShell***. Should be
// startContentShell*** and should use the url exactly without the getTestFileUrl call. Possibly
// these two ways of starting the activity (launch* and start*) should be merged into one.
/**
* Starts the content shell activity with the provided test url.
* The url is synchronously loaded.
* @param url Test url to load.
*/
public void startActivityWithTestUrl(String url) {
mDelegate.launchContentShellWithUrlSync(url);
}
/**
* Returns the current ContentViewCore or null if there is no ContentView.
*/
public ContentViewCore getContentViewCore() {
return mDelegate.getContentViewCore();
}
/**
* Returns the WebContents of this Shell.
*/
public WebContents getWebContents() {
return mDelegate.getWebContents();
}
/**
* Waits for the Active shell to finish loading. This times out after
* WAIT_FOR_ACTIVE_SHELL_LOADING_TIMEOUT milliseconds and it shouldn't be used for long
* loading pages. Instead it should be used more for test initialization. The proper way
* to wait is to use a TestCallbackHelperContainer after the initial load is completed.
*/
public void waitForActiveShellToBeDoneLoading() {
mDelegate.waitForActiveShellToBeDoneLoading();
}
/**
* Creates a new {@link Shell} and waits for it to finish loading.
* @param url The URL to create the new {@link Shell} with.
* @return A new instance of a {@link Shell}.
* @throws ExecutionException
*/
public Shell loadNewShell(String url) throws ExecutionException {
return mDelegate.loadNewShell(url);
}
/**
* Loads a URL in the specified content view.
*
* @param navigationController The navigation controller to load the URL in.
* @param callbackHelperContainer The callback helper container used to monitor progress.
* @param params The URL params to use.
*/
public void loadUrl(NavigationController navigationController,
TestCallbackHelperContainer callbackHelperContainer, LoadUrlParams params)
throws Throwable {
mDelegate.loadUrl(navigationController, callbackHelperContainer, params);
}
/**
* Handles performing an action on the UI thread that will return when the specified callback
* is incremented.
*
* @param callbackHelper The callback helper that will be blocked on.
* @param action The action to be performed on the UI thread.
*/
public void handleBlockingCallbackAction(CallbackHelper callbackHelper, Runnable action)
throws Throwable {
mDelegate.handleBlockingCallbackAction(callbackHelper, action);
}
// TODO(aelias): This method needs to be removed once http://crbug.com/179511 is fixed.
// Meanwhile, we have to wait if the page has the <meta viewport> tag.
/**
* Waits till the ContentViewCore receives the expected page scale factor
* from the compositor and asserts that this happens.
*/
public void assertWaitForPageScaleFactorMatch(float expectedScale) {
mDelegate.assertWaitForPageScaleFactorMatch(expectedScale);
}
/**
* Replaces the {@link ContentViewCore#mContainerView} with a newly created
* {@link ContentView}.
*/
@SuppressWarnings("javadoc")
public void replaceContainerView() throws Throwable {
mDelegate.replaceContainerView();
}
@SuppressWarnings("deprecation")
@Override
protected void runTest() throws Throwable {
super.runTest();
try {
AnnotatedElement method = getClass().getMethod(getName(), (Class[]) null);
if (method.isAnnotationPresent(RerunWithUpdatedContainerView.class)) {
replaceContainerView();
super.runTest();
}
} catch (Throwable e) {
throw new Throwable("@RerunWithUpdatedContainerView failed."
+ " See ContentShellTestBase#runTest.", e);
}
}
@SuppressWarnings("deprecation")
@Override
public ContentShellActivity getActivityForTestCommon() {
return getActivity();
}
@Override
@SuppressWarnings("deprecation")
public Instrumentation getInstrumentationForTestCommon() {
return getInstrumentation();
}
@SuppressWarnings("deprecation")
@Override
public ContentShellActivity launchActivityWithIntentForTestCommon(Intent intent) {
setActivityIntent(intent);
return getActivity();
}
@SuppressWarnings("deprecation")
@Override
public void runOnUiThreadForTestCommon(Runnable runnable) throws Throwable {
runTestOnUiThread(runnable);
}
@Override
public ContentViewCore getContentViewCoreForTestCommon() {
return getContentViewCore();
}
@Override
public WebContents getWebContentsForTestCommon() {
return getWebContents();
}
@Override
public void waitForActiveShellToBeDoneLoadingForTestCommon() {
waitForActiveShellToBeDoneLoading();
}
@Override
public ContentShellActivity launchContentShellWithUrlForTestCommon(String url) {
return launchContentShellWithUrl(url);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment