OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import org.chromium.base.ThreadUtils; | 7 import org.chromium.base.ThreadUtils; |
8 import org.chromium.base.test.util.DisabledTest; | 8 import org.chromium.base.test.util.DisabledTest; |
9 import org.chromium.base.test.util.UrlUtils; | 9 import org.chromium.base.test.util.UrlUtils; |
10 import org.chromium.content.browser.test.util.CallbackHelper; | 10 import org.chromium.content.browser.test.util.CallbackHelper; |
11 import org.chromium.content_public.browser.LoadUrlParams; | 11 import org.chromium.content_public.browser.LoadUrlParams; |
12 import org.chromium.content_public.browser.WebContents; | 12 import org.chromium.content_public.browser.WebContents; |
13 import org.chromium.content_shell_apk.ContentShellActivity; | 13 import org.chromium.content_shell_apk.ContentShellActivity; |
14 import org.chromium.content_shell_apk.ContentShellTestBase; | 14 import org.chromium.content_shell_apk.ContentShellTestBase; |
15 | 15 |
16 import java.util.concurrent.Callable; | 16 import java.util.concurrent.Callable; |
17 | 17 |
18 /** | 18 /** |
19 * Tests for the WebContentsObserverAndroid APIs. | 19 * Tests for the WebContentsObserver APIs. |
20 */ | 20 */ |
21 public class WebContentsObserverAndroidTest extends ContentShellTestBase { | 21 public class WebContentsObserverTest extends ContentShellTestBase { |
22 private static final String URL = UrlUtils.encodeHtmlDataUri( | 22 private static final String URL = UrlUtils.encodeHtmlDataUri( |
23 "<html><head></head><body>didFirstVisuallyNonEmptyPaint test</body><
/html>"); | 23 "<html><head></head><body>didFirstVisuallyNonEmptyPaint test</body><
/html>"); |
24 | 24 |
25 private static class TestWebContentsObserverAndroid extends WebContentsObser
verAndroid { | 25 private static class TestWebContentsObserver extends WebContentsObserver { |
26 private CallbackHelper mDidFirstVisuallyNonEmptyPaintCallbackHelper = ne
w CallbackHelper(); | 26 private CallbackHelper mDidFirstVisuallyNonEmptyPaintCallbackHelper = ne
w CallbackHelper(); |
27 | 27 |
28 public TestWebContentsObserverAndroid(WebContents webContents) { | 28 public TestWebContentsObserver(WebContents webContents) { |
29 super(webContents); | 29 super(webContents); |
30 } | 30 } |
31 | 31 |
32 public CallbackHelper getDidFirstVisuallyNonEmptyPaintCallbackHelper() { | 32 public CallbackHelper getDidFirstVisuallyNonEmptyPaintCallbackHelper() { |
33 return mDidFirstVisuallyNonEmptyPaintCallbackHelper; | 33 return mDidFirstVisuallyNonEmptyPaintCallbackHelper; |
34 } | 34 } |
35 | 35 |
36 @Override | 36 @Override |
37 public void didFirstVisuallyNonEmptyPaint() { | 37 public void didFirstVisuallyNonEmptyPaint() { |
38 mDidFirstVisuallyNonEmptyPaintCallbackHelper.notifyCalled(); | 38 mDidFirstVisuallyNonEmptyPaintCallbackHelper.notifyCalled(); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 @Override | 42 @Override |
43 protected void setUp() throws Exception { | 43 protected void setUp() throws Exception { |
44 super.setUp(); | 44 super.setUp(); |
45 ContentShellActivity activity = launchContentShellWithUrl(null); | 45 ContentShellActivity activity = launchContentShellWithUrl(null); |
46 assertNotNull(activity); | 46 assertNotNull(activity); |
47 waitForActiveShellToBeDoneLoading(); | 47 waitForActiveShellToBeDoneLoading(); |
48 } | 48 } |
49 | 49 |
50 /* | 50 /* |
51 @SmallTest | 51 @SmallTest |
52 @Feature({"Navigation"}) | 52 @Feature({"Navigation"}) |
53 http://crbug.com/411931 | 53 http://crbug.com/411931 |
54 */ | 54 */ |
55 @DisabledTest | 55 @DisabledTest |
56 public void testDidFirstVisuallyNonEmptyPaint() throws Throwable { | 56 public void testDidFirstVisuallyNonEmptyPaint() throws Throwable { |
57 TestWebContentsObserverAndroid observer = ThreadUtils.runOnUiThreadBlock
ing( | 57 TestWebContentsObserver observer = ThreadUtils.runOnUiThreadBlocking( |
58 new Callable<TestWebContentsObserverAndroid>() { | 58 new Callable<TestWebContentsObserver>() { |
59 @Override | 59 @Override |
60 public TestWebContentsObserverAndroid call() throws Exceptio
n { | 60 public TestWebContentsObserver call() throws Exception { |
61 return new TestWebContentsObserverAndroid( | 61 return new TestWebContentsObserver( |
62 getContentViewCore().getWebContents()); | 62 getContentViewCore().getWebContents()); |
63 } | 63 } |
64 }); | 64 }); |
65 | 65 |
66 int callCount = observer.getDidFirstVisuallyNonEmptyPaintCallbackHelper(
).getCallCount(); | 66 int callCount = observer.getDidFirstVisuallyNonEmptyPaintCallbackHelper(
).getCallCount(); |
67 getInstrumentation().runOnMainSync(new Runnable() { | 67 getInstrumentation().runOnMainSync(new Runnable() { |
68 @Override | 68 @Override |
69 public void run() { | 69 public void run() { |
70 getContentViewCore().getWebContents().getNavigationController() | 70 getContentViewCore().getWebContents().getNavigationController() |
71 .loadUrl(new LoadUrlParams(URL)); | 71 .loadUrl(new LoadUrlParams(URL)); |
72 } | 72 } |
73 }); | 73 }); |
74 observer.getDidFirstVisuallyNonEmptyPaintCallbackHelper().waitForCallbac
k(callCount); | 74 observer.getDidFirstVisuallyNonEmptyPaintCallbackHelper().waitForCallbac
k(callCount); |
75 } | 75 } |
76 } | 76 } |
OLD | NEW |