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

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

Issue 2681933002: Add Java wrapper for RenderFrameHost (Closed)
Patch Set: Fix potential dtor problem Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser.webcontents; 5 package org.chromium.content.browser.webcontents;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.content.Intent; 8 import android.content.Intent;
9 import android.os.Bundle; 9 import android.os.Bundle;
10 import android.os.Parcel; 10 import android.os.Parcel;
11 import android.support.test.filters.SmallTest; 11 import android.support.test.filters.SmallTest;
12 12
13 import org.chromium.base.ThreadUtils; 13 import org.chromium.base.ThreadUtils;
14 import org.chromium.content_public.browser.RenderFrameHost;
14 import org.chromium.content_public.browser.WebContents; 15 import org.chromium.content_public.browser.WebContents;
15 import org.chromium.content_shell.Shell; 16 import org.chromium.content_shell.Shell;
16 import org.chromium.content_shell_apk.ContentShellActivity; 17 import org.chromium.content_shell_apk.ContentShellActivity;
17 import org.chromium.content_shell_apk.ContentShellTestBase; 18 import org.chromium.content_shell_apk.ContentShellTestBase;
18 19
19 import java.util.concurrent.Callable; 20 import java.util.concurrent.Callable;
20 import java.util.concurrent.ExecutionException; 21 import java.util.concurrent.ExecutionException;
21 22
22 /** 23 /**
23 * Test various Java WebContents specific features. 24 * Test various Java WebContents specific features.
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 assertNull("Unexpectedly deserialized a WebContents", deserializedWe bContents); 304 assertNull("Unexpectedly deserialized a WebContents", deserializedWe bContents);
304 305
305 // Make sure we can properly deserialize the String after the WebCon tents. 306 // Make sure we can properly deserialize the String after the WebCon tents.
306 assertEquals("Failing to read the WebContents corrupted the parcel", 307 assertEquals("Failing to read the WebContents corrupted the parcel",
307 PARCEL_STRING_TEST_DATA, parcel.readString()); 308 PARCEL_STRING_TEST_DATA, parcel.readString());
308 } finally { 309 } finally {
309 parcel.recycle(); 310 parcel.recycle();
310 } 311 }
311 } 312 }
312 313
314 /**
315 * Check that the main frame associated with the WebContents is not null
316 * and corresponds with the test URL.
317 *
318 * @throws InterruptedException
319 */
320 @SmallTest
321 public void testWebContentsGetMainFrame() throws InterruptedException {
322 final ContentShellActivity activity = launchContentShellWithUrl(TEST_URL _1);
323 waitForActiveShellToBeDoneLoading();
324 final WebContents webContents = activity.getActiveWebContents();
325
326 ThreadUtils.postOnUiThread(new Runnable() {
327 @Override
328 public void run() {
329 RenderFrameHost frameHost = webContents.getMainFrame();
330
331 assertNotNull(frameHost);
332
333 assertEquals("RenderFrameHost has incorrect last committed URL", "about:blank",
334 frameHost.getLastCommittedURL());
335
336 assertEquals("RenderFrameHost associated with different WebConte nts", webContents,
337 RenderFrameHost.getWebContents(frameHost));
338 }
339 });
340 }
341
313 private boolean isWebContentsDestroyed(final WebContents webContents) { 342 private boolean isWebContentsDestroyed(final WebContents webContents) {
314 return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean >() { 343 return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean >() {
315 @Override 344 @Override
316 public Boolean call() throws Exception { 345 public Boolean call() throws Exception {
317 return webContents.isDestroyed(); 346 return webContents.isDestroyed();
318 } 347 }
319 }); 348 });
320 } 349 }
321 } 350 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698