OLD | NEW |
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.junit.Assert; | 13 import org.junit.Assert; |
14 import org.junit.Rule; | 14 import org.junit.Rule; |
15 import org.junit.Test; | 15 import org.junit.Test; |
16 import org.junit.runner.RunWith; | 16 import org.junit.runner.RunWith; |
17 | 17 |
18 import org.chromium.base.ThreadUtils; | 18 import org.chromium.base.ThreadUtils; |
19 import org.chromium.base.test.BaseJUnit4ClassRunner; | 19 import org.chromium.base.test.BaseJUnit4ClassRunner; |
20 import org.chromium.base.test.util.UrlUtils; | 20 import org.chromium.base.test.util.UrlUtils; |
21 import org.chromium.content_public.browser.RenderFrameHost; | 21 import org.chromium.content_public.browser.RenderFrameHost; |
22 import org.chromium.content_public.browser.WebContents; | 22 import org.chromium.content_public.browser.WebContents; |
| 23 import org.chromium.content_public.browser.WebContentsStatics; |
23 import org.chromium.content_shell.Shell; | 24 import org.chromium.content_shell.Shell; |
24 import org.chromium.content_shell_apk.ContentShellActivity; | 25 import org.chromium.content_shell_apk.ContentShellActivity; |
25 import org.chromium.content_shell_apk.ContentShellActivityTestRule; | 26 import org.chromium.content_shell_apk.ContentShellActivityTestRule; |
26 | 27 |
27 import java.util.concurrent.Callable; | 28 import java.util.concurrent.Callable; |
28 import java.util.concurrent.ExecutionException; | 29 import java.util.concurrent.ExecutionException; |
29 | 30 |
30 /** | 31 /** |
31 * Test various Java WebContents specific features. | 32 * Test various Java WebContents specific features. |
32 * TODO(dtrainor): Add more testing for the WebContents methods. | 33 * TODO(dtrainor): Add more testing for the WebContents methods. |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 ThreadUtils.postOnUiThread(new Runnable() { | 349 ThreadUtils.postOnUiThread(new Runnable() { |
349 @Override | 350 @Override |
350 public void run() { | 351 public void run() { |
351 RenderFrameHost frameHost = webContents.getMainFrame(); | 352 RenderFrameHost frameHost = webContents.getMainFrame(); |
352 | 353 |
353 Assert.assertNotNull(frameHost); | 354 Assert.assertNotNull(frameHost); |
354 | 355 |
355 Assert.assertEquals("RenderFrameHost has incorrect last committe
d URL", TEST_URL_2, | 356 Assert.assertEquals("RenderFrameHost has incorrect last committe
d URL", TEST_URL_2, |
356 frameHost.getLastCommittedURL()); | 357 frameHost.getLastCommittedURL()); |
357 | 358 |
358 WebContents associatedWebContents = WebContentsImpl.fromRenderFr
ameHost(frameHost); | 359 WebContents associatedWebContents = |
| 360 WebContentsStatics.fromRenderFrameHost(frameHost); |
359 Assert.assertEquals("RenderFrameHost associated with different W
ebContents", | 361 Assert.assertEquals("RenderFrameHost associated with different W
ebContents", |
360 webContents, associatedWebContents); | 362 webContents, associatedWebContents); |
361 } | 363 } |
362 }); | 364 }); |
363 } | 365 } |
364 | 366 |
365 private boolean isWebContentsDestroyed(final WebContents webContents) { | 367 private boolean isWebContentsDestroyed(final WebContents webContents) { |
366 return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean
>() { | 368 return ThreadUtils.runOnUiThreadBlockingNoException(new Callable<Boolean
>() { |
367 @Override | 369 @Override |
368 public Boolean call() throws Exception { | 370 public Boolean call() throws Exception { |
369 return webContents.isDestroyed(); | 371 return webContents.isDestroyed(); |
370 } | 372 } |
371 }); | 373 }); |
372 } | 374 } |
373 } | 375 } |
OLD | NEW |