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

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

Issue 2681933002: Add Java wrapper for RenderFrameHost (Closed)
Patch Set: Make test work with PlzNavigate Created 3 years, 9 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
« no previous file with comments | « content/public/android/java/src/org/chromium/content_public/browser/WebContents.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java b/content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java
index fa52a8a74a4d752255c60147f1a1ff1c8a3dbc14..f6b99ed26a4c554acfa82e080b7c647b16c0ff44 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/webcontents/WebContentsTest.java
@@ -11,6 +11,8 @@ import android.os.Parcel;
import android.support.test.filters.SmallTest;
import org.chromium.base.ThreadUtils;
+import org.chromium.base.test.util.UrlUtils;
+import org.chromium.content_public.browser.RenderFrameHost;
import org.chromium.content_public.browser.WebContents;
import org.chromium.content_shell.Shell;
import org.chromium.content_shell_apk.ContentShellActivity;
@@ -25,6 +27,7 @@ import java.util.concurrent.ExecutionException;
*/
public class WebContentsTest extends ContentShellTestBase {
private static final String TEST_URL_1 = "about://blank";
+ private static final String TEST_URL_2 = UrlUtils.encodeHtmlDataUri("<html>1</html>");
private static final String WEB_CONTENTS_KEY = "WEBCONTENTSKEY";
private static final String PARCEL_STRING_TEST_DATA = "abcdefghijklmnopqrstuvwxyz";
@@ -310,6 +313,35 @@ public class WebContentsTest extends ContentShellTestBase {
}
}
+ /**
+ * Check that the main frame associated with the WebContents is not null
+ * and corresponds with the test URL.
+ *
+ * @throws InterruptedException
+ */
+ @SmallTest
+ public void testWebContentsMainFrame() throws InterruptedException {
+ final ContentShellActivity activity = launchContentShellWithUrl(TEST_URL_2);
+ waitForActiveShellToBeDoneLoading();
+ final WebContents webContents = activity.getActiveWebContents();
+
+ ThreadUtils.postOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ RenderFrameHost frameHost = webContents.getMainFrame();
+
+ assertNotNull(frameHost);
+
+ assertEquals("RenderFrameHost has incorrect last committed URL", TEST_URL_2,
+ frameHost.getLastCommittedURL());
+
+ WebContents associatedWebContents = WebContentsImpl.fromRenderFrameHost(frameHost);
+ assertEquals("RenderFrameHost associated with different WebContents", webContents,
+ associatedWebContents);
+ }
+ });
+ }
+
private boolean isWebContentsDestroyed(final WebContents webContents) {
return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean>() {
@Override
« no previous file with comments | « content/public/android/java/src/org/chromium/content_public/browser/WebContents.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698