Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / android_webview / javatests / src / org / chromium / android_webview / test / AwTestBase.java
index 77613f4..421070d 100644 (file)
@@ -9,7 +9,7 @@ import android.content.Context;
 import android.test.ActivityInstrumentationTestCase2;
 import android.util.Log;
 
-import static org.chromium.base.test.util.ScalableTimeout.ScaleTimeout;
+import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
 
 import org.chromium.android_webview.AwBrowserContext;
 import org.chromium.android_webview.AwBrowserProcess;
@@ -35,7 +35,7 @@ import java.util.concurrent.atomic.AtomicReference;
  */
 public class AwTestBase
         extends ActivityInstrumentationTestCase2<AwTestRunnerActivity> {
-    protected static final long WAIT_TIMEOUT_MS = ScaleTimeout(15000);
+    protected static final long WAIT_TIMEOUT_MS = scaleTimeout(15000);
     protected static final int CHECK_INTERVAL = 100;
     private static final String TAG = "AwTestBase";
 
@@ -213,6 +213,28 @@ public class AwTestBase
         });
     }
 
+    protected void loadDataWithBaseUrlSync(final AwContents awContents,
+            CallbackHelper onPageFinishedHelper, final String data, final String mimeType,
+            final boolean isBase64Encoded, final String baseUrl,
+            final String historyUrl) throws Throwable {
+        int currentCallCount = onPageFinishedHelper.getCallCount();
+        loadDataWithBaseUrlAsync(awContents, data, mimeType, isBase64Encoded, baseUrl, historyUrl);
+        onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_MS,
+                TimeUnit.MILLISECONDS);
+    }
+
+    protected void loadDataWithBaseUrlAsync(final AwContents awContents,
+            final String data, final String mimeType, final boolean isBase64Encoded,
+            final String baseUrl, final String historyUrl) throws Throwable {
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                awContents.loadUrl(LoadUrlParams.createLoadDataParamsWithBaseUrl(
+                        data, mimeType, isBase64Encoded, baseUrl, historyUrl));
+            }
+        });
+    }
+
     /**
      * Reloads the current page synchronously.
      */
@@ -253,7 +275,7 @@ public class AwTestBase
 
     protected AwTestContainerView createAwTestContainerView(
             final AwContentsClient awContentsClient) {
-        return createAwTestContainerView(awContentsClient, true);
+        return createAwTestContainerView(awContentsClient, false);
     }
 
     protected AwTestContainerView createAwTestContainerView(
@@ -271,7 +293,7 @@ public class AwTestBase
 
     protected AwTestContainerView createDetachedAwTestContainerView(
             final AwContentsClient awContentsClient) {
-        return createDetachedAwTestContainerView(awContentsClient, true);
+        return createDetachedAwTestContainerView(awContentsClient, false);
     }
 
     protected AwTestContainerView createDetachedAwTestContainerView(
@@ -281,8 +303,6 @@ public class AwTestBase
             testDependencyFactory.createAwTestContainerView(getActivity());
         AwSettings awSettings = testDependencyFactory.createAwSettings(getActivity(),
                 supportsLegacyQuirks);
-        // TODO(mnaganov): Should also have tests for the "pure Chromium" mode.
-        // See http://crbug.com/278106
         testContainerView.initialize(new AwContents(
                 mBrowserContext, testContainerView, testContainerView.getInternalAccessDelegate(),
                 awContentsClient, awSettings, testDependencyFactory.createLayoutSizer()));
@@ -292,7 +312,7 @@ public class AwTestBase
 
     protected AwTestContainerView createAwTestContainerViewOnMainSync(
             final AwContentsClient client) throws Exception {
-        return createAwTestContainerViewOnMainSync(client, true);
+        return createAwTestContainerViewOnMainSync(client, false);
     }
 
     protected AwTestContainerView createAwTestContainerViewOnMainSync(