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

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

Issue 589113002: Rename java WebContentsObserverAndroid to WebContentsObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style issues fixed Created 6 years, 2 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 android.test.suitebuilder.annotation.LargeTest; 7 import android.test.suitebuilder.annotation.LargeTest;
8 8
9 import org.chromium.base.ThreadUtils; 9 import org.chromium.base.ThreadUtils;
10 import org.chromium.base.test.util.Feature; 10 import org.chromium.base.test.util.Feature;
11 import org.chromium.base.test.util.UrlUtils; 11 import org.chromium.base.test.util.UrlUtils;
12 import org.chromium.content.browser.test.util.Criteria; 12 import org.chromium.content.browser.test.util.Criteria;
13 import org.chromium.content.browser.test.util.CriteriaHelper; 13 import org.chromium.content.browser.test.util.CriteriaHelper;
14 import org.chromium.content.browser.test.util.TouchCommon; 14 import org.chromium.content.browser.test.util.TouchCommon;
15 import org.chromium.content_public.browser.WebContents; 15 import org.chromium.content_public.browser.WebContents;
16 import org.chromium.content_shell_apk.ContentShellActivity; 16 import org.chromium.content_shell_apk.ContentShellActivity;
17 import org.chromium.content_shell_apk.ContentShellTestBase; 17 import org.chromium.content_shell_apk.ContentShellTestBase;
18 18
19 import java.util.concurrent.Callable; 19 import java.util.concurrent.Callable;
20 import java.util.concurrent.ExecutionException; 20 import java.util.concurrent.ExecutionException;
21 21
22 /** 22 /**
23 * Tests for interstitial pages. 23 * Tests for interstitial pages.
24 */ 24 */
25 public class InterstitialPageTest extends ContentShellTestBase { 25 public class InterstitialPageTest extends ContentShellTestBase {
26 26
27 private static final String URL = UrlUtils.encodeHtmlDataUri( 27 private static final String URL = UrlUtils.encodeHtmlDataUri(
28 "<html><head></head><body>test</body></html>"); 28 "<html><head></head><body>test</body></html>");
29 29
30 private static class TestWebContentsObserverAndroid extends WebContentsObser verAndroid { 30 private static class TestWebContentsObserver extends WebContentsObserver {
31 private boolean mInterstitialShowing; 31 private boolean mInterstitialShowing;
32 32
33 public TestWebContentsObserverAndroid(WebContents webContents) { 33 public TestWebContentsObserver(WebContents webContents) {
34 super(webContents); 34 super(webContents);
35 } 35 }
36 36
37 public boolean isInterstitialShowing() throws ExecutionException { 37 public boolean isInterstitialShowing() throws ExecutionException {
38 return ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() { 38 return ThreadUtils.runOnUiThreadBlocking(new Callable<Boolean>() {
39 @Override 39 @Override
40 public Boolean call() throws Exception { 40 public Boolean call() throws Exception {
41 return mInterstitialShowing; 41 return mInterstitialShowing;
42 } 42 }
43 }).booleanValue(); 43 }).booleanValue();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 "</body>" + 104 "</body>" +
105 "</html>"; 105 "</html>";
106 final InterstitialPageDelegateAndroid delegate = 106 final InterstitialPageDelegateAndroid delegate =
107 new InterstitialPageDelegateAndroid(htmlContent) { 107 new InterstitialPageDelegateAndroid(htmlContent) {
108 @Override 108 @Override
109 protected void commandReceived(String command) { 109 protected void commandReceived(String command) {
110 assertEquals(command, proceedCommand); 110 assertEquals(command, proceedCommand);
111 proceed(); 111 proceed();
112 } 112 }
113 }; 113 };
114 TestWebContentsObserverAndroid observer = ThreadUtils.runOnUiThreadBlock ing( 114 TestWebContentsObserver observer = ThreadUtils.runOnUiThreadBlocking(
115 new Callable<TestWebContentsObserverAndroid>() { 115 new Callable<TestWebContentsObserver>() {
116 @Override 116 @Override
117 public TestWebContentsObserverAndroid call() throws Exceptio n { 117 public TestWebContentsObserver call() throws Exception {
118 getWebContents().showInterstitialPage(URL, delegate.getN ative()); 118 getWebContents().showInterstitialPage(URL, delegate.getN ative());
119 return new TestWebContentsObserverAndroid(getWebContents ()); 119 return new TestWebContentsObserver(getWebContents());
120 } 120 }
121 }); 121 });
122 122
123 assertTrue("Interstitial never shown.", waitForInterstitial(true)); 123 assertTrue("Interstitial never shown.", waitForInterstitial(true));
124 assertTrue("WebContentsObserver not notified of interstitial showing", 124 assertTrue("WebContentsObserver not notified of interstitial showing",
125 observer.isInterstitialShowing()); 125 observer.isInterstitialShowing());
126 TouchCommon touchCommon = new TouchCommon(this); 126 TouchCommon touchCommon = new TouchCommon(this);
127 touchCommon.singleClickViewRelative(getContentViewCore().getContainerVie w(), 10, 10); 127 touchCommon.singleClickViewRelative(getContentViewCore().getContainerVie w(), 10, 10);
128 assertTrue("Interstitial never hidden.", waitForInterstitial(false)); 128 assertTrue("Interstitial never hidden.", waitForInterstitial(false));
129 assertTrue("WebContentsObserver not notified of interstitial hiding", 129 assertTrue("WebContentsObserver not notified of interstitial hiding",
130 !observer.isInterstitialShowing()); 130 !observer.isInterstitialShowing());
131 } 131 }
132 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698