This source file includes following definitions.
- setUpContentView
- loadDataSync
package org.chromium.content.browser;
import android.util.Log;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.content_shell_apk.ContentShellActivity;
import org.chromium.content_shell_apk.ContentShellTestBase;
public class ContentViewTestBase extends ContentShellTestBase {
protected TestCallbackHelperContainer mTestCallbackHelperContainer;
protected void setUpContentView(final Object object, final String name) throws Exception {
final ContentShellActivity activity = launchContentShellWithUrl(
UrlUtils.encodeHtmlDataUri("<html><head></head><body>test</body></html>"));
waitForActiveShellToBeDoneLoading();
try {
runTestOnUiThread(new Runnable() {
@Override
public void run() {
ContentView contentView = activity.getActiveContentView();
contentView.getContentViewCore().addPossiblyUnsafeJavascriptInterface(object,
name, null);
mTestCallbackHelperContainer =
new TestCallbackHelperContainer(contentView);
}
});
loadDataSync(activity.getActiveContentView(),
"<!DOCTYPE html><title></title>", "text/html", false);
} catch (Throwable e) {
throw new RuntimeException(
"Failed to set up ContentView: " + Log.getStackTraceString(e));
}
}
protected void loadDataSync(final ContentView contentView, final String data,
final String mimeType, final boolean isBase64Encoded) throws Throwable {
loadUrl(contentView, mTestCallbackHelperContainer, LoadUrlParams.createLoadDataParams(
data, mimeType, isBase64Encoded));
}
}