Commit 9385a899 authored by Yoland Yan's avatar Yoland Yan Committed by Commit Bot

Convert Android Overlay test to JUnit4

Bug: 640116
Change-Id: I74053b1b4bcb37553a72305ece82703453354586
Reviewed-on: https://chromium-review.googlesource.com/636171
Commit-Queue: Yoland Yan <yolandyan@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarFrank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501484}
parent 17fcfc1b
...@@ -465,7 +465,7 @@ android_library("content_javatests") { ...@@ -465,7 +465,7 @@ android_library("content_javatests") {
"javatests/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegateTest.java", "javatests/src/org/chromium/content/browser/accessibility/captioning/CaptioningChangeDelegateTest.java",
"javatests/src/org/chromium/content/browser/androidoverlay/DialogOverlayImplPixelTest.java", "javatests/src/org/chromium/content/browser/androidoverlay/DialogOverlayImplPixelTest.java",
"javatests/src/org/chromium/content/browser/androidoverlay/DialogOverlayImplTest.java", "javatests/src/org/chromium/content/browser/androidoverlay/DialogOverlayImplTest.java",
"javatests/src/org/chromium/content/browser/androidoverlay/DialogOverlayImplTestBase.java", "javatests/src/org/chromium/content/browser/androidoverlay/DialogOverlayImplTestRule.java",
"javatests/src/org/chromium/content/browser/crypto/CipherFactoryTest.java", "javatests/src/org/chromium/content/browser/crypto/CipherFactoryTest.java",
"javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java", "javatests/src/org/chromium/content/browser/input/CursorAnchorInfoControllerTest.java",
"javatests/src/org/chromium/content/browser/input/ImeLollipopTest.java", "javatests/src/org/chromium/content/browser/input/ImeLollipopTest.java",
......
...@@ -10,27 +10,39 @@ import android.graphics.Canvas; ...@@ -10,27 +10,39 @@ import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.Build; import android.os.Build;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.MediumTest; import android.support.test.filters.MediumTest;
import android.view.Surface; import android.view.Surface;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.MinAndroidSdkLevel; import org.chromium.base.test.util.MinAndroidSdkLevel;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.ContentViewCore; import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.androidoverlay.DialogOverlayImplTestRule.Client;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
/** /**
* Pixel tests for DialogOverlayImpl. These use UiAutomation, so they only run in JB or above. * Pixel tests for DialogOverlayImpl. These use UiAutomation, so they only run in JB or above.
* TODO(liberato): Convert to junit4.
*/ */
@RunWith(BaseJUnit4ClassRunner.class)
@MinAndroidSdkLevel(Build.VERSION_CODES.JELLY_BEAN_MR2) @MinAndroidSdkLevel(Build.VERSION_CODES.JELLY_BEAN_MR2)
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
public class DialogOverlayImplPixelTest extends DialogOverlayImplTestBase { public class DialogOverlayImplPixelTest {
// Color that we'll fill the overlay with. // Color that we'll fill the overlay with.
@Rule
public DialogOverlayImplTestRule mActivityTestRule =
new DialogOverlayImplTestRule(TEST_PAGE_DATA_URL);
private static final int OVERLAY_FILL_COLOR = Color.BLUE; private static final int OVERLAY_FILL_COLOR = Color.BLUE;
// CSS coordinates of a div that we'll try to cover with an overlay. // CSS coordinates of a div that we'll try to cover with an overlay.
...@@ -85,20 +97,14 @@ public class DialogOverlayImplPixelTest extends DialogOverlayImplTestBase { ...@@ -85,20 +97,14 @@ public class DialogOverlayImplPixelTest extends DialogOverlayImplTestBase {
// Screenshot of the test page, before we do anything. // Screenshot of the test page, before we do anything.
Bitmap mInitialScreenshot; Bitmap mInitialScreenshot;
@Override @Before
protected String getInitialUrl() {
return TEST_PAGE_DATA_URL;
}
@Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp();
takeScreenshotOfBackground(); takeScreenshotOfBackground();
} }
// Take a screenshot via UiAutomation, which captures all overlays. // Take a screenshot via UiAutomation, which captures all overlays.
Bitmap takeScreenshot() { Bitmap takeScreenshot() {
return getInstrumentation().getUiAutomation().takeScreenshot(); return InstrumentationRegistry.getInstrumentation().getUiAutomation().takeScreenshot();
} }
// Fill |surface| with OVERLAY_FILL_COLOR and return a screenshot. Note that we have no idea // Fill |surface| with OVERLAY_FILL_COLOR and return a screenshot. Note that we have no idea
...@@ -113,7 +119,7 @@ public class DialogOverlayImplPixelTest extends DialogOverlayImplTestBase { ...@@ -113,7 +119,7 @@ public class DialogOverlayImplPixelTest extends DialogOverlayImplTestBase {
} }
int convertCSSToScreenPixels(int css) { int convertCSSToScreenPixels(int css) {
ContentViewCore cvc = getContentViewCore(); ContentViewCore cvc = mActivityTestRule.getContentViewCore();
return (int) (css * cvc.getPageScaleFactor() * cvc.getDeviceScaleFactor()); return (int) (css * cvc.getPageScaleFactor() * cvc.getDeviceScaleFactor());
} }
...@@ -221,7 +227,7 @@ public class DialogOverlayImplPixelTest extends DialogOverlayImplTestBase { ...@@ -221,7 +227,7 @@ public class DialogOverlayImplPixelTest extends DialogOverlayImplTestBase {
// Wait for |overlay| to become ready, get its surface, and return it. // Wait for |overlay| to become ready, get its surface, and return it.
Surface waitForSurface(DialogOverlayImpl overlay) throws Exception { Surface waitForSurface(DialogOverlayImpl overlay) throws Exception {
Assert.assertNotNull(overlay); Assert.assertNotNull(overlay);
final Client.Event event = getClient().nextEvent(); final Client.Event event = mActivityTestRule.getClient().nextEvent();
Assert.assertTrue(event.surfaceKey > 0); Assert.assertTrue(event.surfaceKey > 0);
return ThreadUtils.runOnUiThreadBlocking(new Callable<Surface>() { return ThreadUtils.runOnUiThreadBlocking(new Callable<Surface>() {
@Override @Override
...@@ -231,22 +237,24 @@ public class DialogOverlayImplPixelTest extends DialogOverlayImplTestBase { ...@@ -231,22 +237,24 @@ public class DialogOverlayImplPixelTest extends DialogOverlayImplTestBase {
}); });
} }
@Test
@MediumTest @MediumTest
@Feature({"AndroidOverlay"}) @Feature({"AndroidOverlay"})
public void testInitialPosition() throws Exception { public void testInitialPosition() throws Exception {
// Test that the initial position supplied for the overlay covers the <div> we created. // Test that the initial position supplied for the overlay covers the <div> we created.
final DialogOverlayImpl overlay = final DialogOverlayImpl overlay =
createOverlay(mDivXPx, mDivYPx, mDivWidthPx, mDivHeightPx); mActivityTestRule.createOverlay(mDivXPx, mDivYPx, mDivWidthPx, mDivHeightPx);
Surface surface = waitForSurface(overlay); Surface surface = waitForSurface(overlay);
assertDivIsExactlyCovered(surface); assertDivIsExactlyCovered(surface);
} }
@Test
@MediumTest @MediumTest
@Feature({"AndroidOverlay"}) @Feature({"AndroidOverlay"})
public void testScheduleLayout() throws Exception { public void testScheduleLayout() throws Exception {
// Test that scheduleLayout() moves the overlay to cover the <div>. // Test that scheduleLayout() moves the overlay to cover the <div>.
final DialogOverlayImpl overlay = createOverlay(0, 0, 10, 10); final DialogOverlayImpl overlay = mActivityTestRule.createOverlay(0, 0, 10, 10);
Surface surface = waitForSurface(overlay); Surface surface = waitForSurface(overlay);
final org.chromium.gfx.mojom.Rect rect = new org.chromium.gfx.mojom.Rect(); final org.chromium.gfx.mojom.Rect rect = new org.chromium.gfx.mojom.Rect();
......
...@@ -7,37 +7,42 @@ package org.chromium.content.browser.androidoverlay; ...@@ -7,37 +7,42 @@ package org.chromium.content.browser.androidoverlay;
import android.support.test.filters.SmallTest; import android.support.test.filters.SmallTest;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.androidoverlay.DialogOverlayImplTestRule.Client;
/** /**
* Tests for DialogOverlayImpl. * Tests for DialogOverlayImpl.
* TODO(liberato): Convert to junit4.
*/ */
public class DialogOverlayImplTest extends DialogOverlayImplTestBase { @RunWith(BaseJUnit4ClassRunner.class)
public class DialogOverlayImplTest {
private static final String BLANK_URL = "about://blank"; private static final String BLANK_URL = "about://blank";
@Override @Rule
protected String getInitialUrl() { public DialogOverlayImplTestRule mActivityTestRule =
return BLANK_URL; new DialogOverlayImplTestRule(BLANK_URL);
}
@Test
@SmallTest @SmallTest
@Feature({"AndroidOverlay"}) @Feature({"AndroidOverlay"})
public void testCreateDestroyOverlay() { public void testCreateDestroyOverlay() {
Assert.assertFalse(getClient().hasReceivedOverlayModeChange()); Assert.assertFalse(mActivityTestRule.getClient().hasReceivedOverlayModeChange());
Assert.assertFalse(getClient().isUsingOverlayMode()); Assert.assertFalse(mActivityTestRule.getClient().isUsingOverlayMode());
final DialogOverlayImpl overlay = createOverlay(0, 0, 10, 10); final DialogOverlayImpl overlay = mActivityTestRule.createOverlay(0, 0, 10, 10);
// We should get a new overlay with a valid surface key. // We should get a new overlay with a valid surface key.
Client.Event event = getClient().nextEvent(); Client.Event event = mActivityTestRule.getClient().nextEvent();
Assert.assertEquals(Client.SURFACE_READY, event.which); Assert.assertEquals(Client.SURFACE_READY, event.which);
Assert.assertTrue(event.surfaceKey > 0); Assert.assertTrue(event.surfaceKey > 0);
Assert.assertTrue(getClient().hasReceivedOverlayModeChange()); Assert.assertTrue(mActivityTestRule.getClient().hasReceivedOverlayModeChange());
Assert.assertTrue(getClient().isUsingOverlayMode()); Assert.assertTrue(mActivityTestRule.getClient().isUsingOverlayMode());
// Close the overlay, and make sure that the provider is notified. // Close the overlay, and make sure that the provider is notified.
// Note that we should not get a 'destroyed' message when we close it. // Note that we should not get a 'destroyed' message when we close it.
...@@ -47,67 +52,71 @@ public class DialogOverlayImplTest extends DialogOverlayImplTestBase { ...@@ -47,67 +52,71 @@ public class DialogOverlayImplTest extends DialogOverlayImplTestBase {
overlay.close(); overlay.close();
} }
}); });
Assert.assertEquals(Client.RELEASED, getClient().nextEvent().which); Assert.assertEquals(Client.RELEASED, mActivityTestRule.getClient().nextEvent().which);
Assert.assertFalse(getClient().isUsingOverlayMode()); Assert.assertFalse(mActivityTestRule.getClient().isUsingOverlayMode());
} }
@Test
@SmallTest @SmallTest
@Feature({"AndroidOverlay"}) @Feature({"AndroidOverlay"})
public void testCreateOverlayFailsIfUnknownRoutingToken() { public void testCreateOverlayFailsIfUnknownRoutingToken() {
// Try to create an overlay with a bad routing token. // Try to create an overlay with a bad routing token.
mRoutingToken.high++; mActivityTestRule.incrementUnguessableTokenHigh();
DialogOverlayImpl overlay = createOverlay(0, 0, 10, 10); DialogOverlayImpl overlay = mActivityTestRule.createOverlay(0, 0, 10, 10);
Assert.assertNotNull(overlay); Assert.assertNotNull(overlay);
// We should be notified that the overlay is destroyed. // We should be notified that the overlay is destroyed.
Client.Event event = getClient().nextEvent(); Client.Event event = mActivityTestRule.getClient().nextEvent();
Assert.assertEquals(Client.DESTROYED, event.which); Assert.assertEquals(Client.DESTROYED, event.which);
} }
@Test
@SmallTest @SmallTest
@Feature({"AndroidOverlay"}) @Feature({"AndroidOverlay"})
public void testCreateOverlayFailsIfWebContentsHidden() { public void testCreateOverlayFailsIfWebContentsHidden() {
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override @Override
public void run() { public void run() {
getWebContents().onHide(); mActivityTestRule.getWebContents().onHide();
} }
}); });
DialogOverlayImpl overlay = createOverlay(0, 0, 10, 10); DialogOverlayImpl overlay = mActivityTestRule.createOverlay(0, 0, 10, 10);
Assert.assertNotNull(overlay); Assert.assertNotNull(overlay);
// We should be notified that the overlay is destroyed. // We should be notified that the overlay is destroyed.
Client.Event event = getClient().nextEvent(); Client.Event event = mActivityTestRule.getClient().nextEvent();
Assert.assertEquals(Client.DESTROYED, event.which); Assert.assertEquals(Client.DESTROYED, event.which);
} }
@Test
@SmallTest @SmallTest
@Feature({"AndroidOverlay"}) @Feature({"AndroidOverlay"})
public void testHiddingWebContentsDestroysOverlay() { public void testHiddingWebContentsDestroysOverlay() {
DialogOverlayImpl overlay = createOverlay(0, 0, 10, 10); DialogOverlayImpl overlay = mActivityTestRule.createOverlay(0, 0, 10, 10);
Assert.assertNotNull(overlay); Assert.assertNotNull(overlay);
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override @Override
public void run() { public void run() {
getWebContents().onHide(); mActivityTestRule.getWebContents().onHide();
} }
}); });
// We should be notified that the overlay is destroyed. // We should be notified that the overlay is destroyed.
Client.Event event = getClient().nextEvent(); Client.Event event = mActivityTestRule.getClient().nextEvent();
Assert.assertEquals(Client.DESTROYED, event.which); Assert.assertEquals(Client.DESTROYED, event.which);
} }
@Test
@SmallTest @SmallTest
@Feature({"AndroidOverlay"}) @Feature({"AndroidOverlay"})
public void testScheduleLayoutDoesntCrash() { public void testScheduleLayoutDoesntCrash() {
// Make sure that we don't get any messages due to scheduleLayout, and we don't crash. // Make sure that we don't get any messages due to scheduleLayout, and we don't crash.
final DialogOverlayImpl overlay = createOverlay(0, 0, 10, 10); final DialogOverlayImpl overlay = mActivityTestRule.createOverlay(0, 0, 10, 10);
// Wait for the surface. // Wait for the surface.
Assert.assertEquals(Client.SURFACE_READY, getClient().nextEvent().which); Assert.assertEquals(Client.SURFACE_READY, mActivityTestRule.getClient().nextEvent().which);
final org.chromium.gfx.mojom.Rect rect = new org.chromium.gfx.mojom.Rect(); final org.chromium.gfx.mojom.Rect rect = new org.chromium.gfx.mojom.Rect();
rect.x = 100; rect.x = 100;
rect.y = 200; rect.y = 200;
...@@ -121,29 +130,31 @@ public class DialogOverlayImplTest extends DialogOverlayImplTestBase { ...@@ -121,29 +130,31 @@ public class DialogOverlayImplTest extends DialogOverlayImplTestBase {
}); });
// No additional messages should have arrived. // No additional messages should have arrived.
Assert.assertTrue(getClient().isEmpty()); Assert.assertTrue(mActivityTestRule.getClient().isEmpty());
} }
@Test
@SmallTest @SmallTest
@Feature({"AndroidOverlay"}) @Feature({"AndroidOverlay"})
public void testCreateSecureSurface() { public void testCreateSecureSurface() {
// Test that creating a secure overlay creates an overlay. We can't really tell if it's // Test that creating a secure overlay creates an overlay. We can't really tell if it's
// secure or not, until we can do a screen shot test. // secure or not, until we can do a screen shot test.
mSecure = true; mActivityTestRule.setSecure(true);
final DialogOverlayImpl overlay = createOverlay(0, 0, 10, 10); final DialogOverlayImpl overlay = mActivityTestRule.createOverlay(0, 0, 10, 10);
Assert.assertNotNull(overlay); Assert.assertNotNull(overlay);
// We should get a new overlay with a valid surface key. // We should get a new overlay with a valid surface key.
Client.Event event = getClient().nextEvent(); Client.Event event = mActivityTestRule.getClient().nextEvent();
Assert.assertEquals(Client.SURFACE_READY, event.which); Assert.assertEquals(Client.SURFACE_READY, event.which);
Assert.assertTrue(event.surfaceKey > 0); Assert.assertTrue(event.surfaceKey > 0);
} }
@Test
@SmallTest @SmallTest
@Feature({"AndroidOverlay"}) @Feature({"AndroidOverlay"})
public void testCloseOnlyClosesOnce() { public void testCloseOnlyClosesOnce() {
// Test that trying to close an overlay more than once doesn't actually do anything. // Test that trying to close an overlay more than once doesn't actually do anything.
final DialogOverlayImpl overlay = createOverlay(0, 0, 10, 10); final DialogOverlayImpl overlay = mActivityTestRule.createOverlay(0, 0, 10, 10);
// The first should generate RELEASED // The first should generate RELEASED
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override @Override
...@@ -151,15 +162,15 @@ public class DialogOverlayImplTest extends DialogOverlayImplTestBase { ...@@ -151,15 +162,15 @@ public class DialogOverlayImplTest extends DialogOverlayImplTestBase {
overlay.close(); overlay.close();
} }
}); });
Assert.assertEquals(Client.RELEASED, getClient().nextEvent().which); Assert.assertEquals(Client.RELEASED, mActivityTestRule.getClient().nextEvent().which);
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override @Override
public void run() { public void run() {
overlay.close(); overlay.close();
getClient().injectMarkerEvent(); mActivityTestRule.getClient().injectMarkerEvent();
} }
}); });
Assert.assertEquals(Client.TEST_MARKER, getClient().nextEvent().which); Assert.assertEquals(Client.TEST_MARKER, mActivityTestRule.getClient().nextEvent().which);
} }
} }
...@@ -8,11 +8,13 @@ import android.os.Handler; ...@@ -8,11 +8,13 @@ import android.os.Handler;
import android.os.HandlerThread; import android.os.HandlerThread;
import org.junit.Assert; import org.junit.Assert;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.chromium.base.Callback; import org.chromium.base.Callback;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.content.browser.framehost.RenderFrameHostImpl; import org.chromium.content.browser.framehost.RenderFrameHostImpl;
import org.chromium.content_shell_apk.ContentShellTestBase; import org.chromium.content_shell_apk.ContentShellActivityTestRule;
import org.chromium.media.mojom.AndroidOverlayClient; import org.chromium.media.mojom.AndroidOverlayClient;
import org.chromium.media.mojom.AndroidOverlayConfig; import org.chromium.media.mojom.AndroidOverlayConfig;
import org.chromium.mojo.common.mojom.UnguessableToken; import org.chromium.mojo.common.mojom.UnguessableToken;
...@@ -23,9 +25,9 @@ import java.util.concurrent.Callable; ...@@ -23,9 +25,9 @@ import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
* Base class for tests for DialogOverlayImpl. * TestRule for tests for DialogOverlayImpl.
*/ */
public abstract class DialogOverlayImplTestBase extends ContentShellTestBase { public class DialogOverlayImplTestRule extends ContentShellActivityTestRule {
// overlay-ui thread. // overlay-ui thread.
private HandlerThread mOverlayUiThread; private HandlerThread mOverlayUiThread;
private Handler mOverlayUiHandler; private Handler mOverlayUiHandler;
...@@ -35,10 +37,12 @@ public abstract class DialogOverlayImplTestBase extends ContentShellTestBase { ...@@ -35,10 +37,12 @@ public abstract class DialogOverlayImplTestBase extends ContentShellTestBase {
// The routing token that we'll use to create overlays. This may be modified by the tests prior // The routing token that we'll use to create overlays. This may be modified by the tests prior
// to calling createOverlay(). // to calling createOverlay().
protected UnguessableToken mRoutingToken; private UnguessableToken mRoutingToken;
// True if we should create a secure overlay. // True if we should create a secure overlay.
protected boolean mSecure; private boolean mSecure;
private String mInitialUrl;
/** /**
* AndroidOverlay client that supports waiting operations for callbacks. One may call * AndroidOverlay client that supports waiting operations for callbacks. One may call
...@@ -152,57 +156,75 @@ public abstract class DialogOverlayImplTestBase extends ContentShellTestBase { ...@@ -152,57 +156,75 @@ public abstract class DialogOverlayImplTestBase extends ContentShellTestBase {
private Client mClient = new Client(); private Client mClient = new Client();
// Return the URL to start with. // Return the URL to start with.
protected abstract String getInitialUrl(); public DialogOverlayImplTestRule(String url) {
mInitialUrl = url;
}
protected Client getClient() { public String getInitialUrl() {
return mInitialUrl;
}
public Client getClient() {
return mClient; return mClient;
} }
@Override public void setSecure(boolean secure) {
public void setUp() throws Exception { mSecure = secure;
super.setUp(); }
public void incrementUnguessableTokenHigh() {
mRoutingToken.high++;
}
launchContentShellWithUrl(getInitialUrl());
waitForActiveShellToBeDoneLoading(); // Do we need this?
// Fetch the routing token. @Override
mRoutingToken = public Statement apply(final Statement base, Description desc) {
ThreadUtils.runOnUiThreadBlockingNoException(new Callable<UnguessableToken>() { return super.apply(new Statement() {
@Override
public void evaluate() throws Throwable {
launchContentShellWithUrl(getInitialUrl());
waitForActiveShellToBeDoneLoading(); // Do we need this?
// Fetch the routing token.
mRoutingToken = ThreadUtils.runOnUiThreadBlockingNoException(
new Callable<UnguessableToken>() {
@Override
public UnguessableToken call() {
RenderFrameHostImpl host =
(RenderFrameHostImpl) getWebContents().getMainFrame();
org.chromium.base.UnguessableToken routingToken =
host.getAndroidOverlayRoutingToken();
UnguessableToken mojoToken = new UnguessableToken();
mojoToken.high = routingToken.getHighForSerialization();
mojoToken.low = routingToken.getLowForSerialization();
return mojoToken;
}
});
// Set up the overlay UI thread
mOverlayUiThread = new HandlerThread("TestOverlayUI");
mOverlayUiThread.start();
mOverlayUiHandler = new Handler(mOverlayUiThread.getLooper());
// Just delegate to |mClient| when an overlay is released.
mReleasedRunnable = new Runnable() {
@Override @Override
public UnguessableToken call() { public void run() {
RenderFrameHostImpl host = mClient.notifyReleased();
(RenderFrameHostImpl) getWebContents().getMainFrame();
org.chromium.base.UnguessableToken routingToken =
host.getAndroidOverlayRoutingToken();
UnguessableToken mojoToken = new UnguessableToken();
mojoToken.high = routingToken.getHighForSerialization();
mojoToken.low = routingToken.getLowForSerialization();
return mojoToken;
} }
}); };
// Set up the overlay UI thread
mOverlayUiThread = new HandlerThread("TestOverlayUI");
mOverlayUiThread.start();
mOverlayUiHandler = new Handler(mOverlayUiThread.getLooper());
// Just delegate to |mClient| when an overlay is released. Callback<Boolean> overlayModeChanged = new Callback<Boolean>() {
mReleasedRunnable = new Runnable() { @Override
@Override public void onResult(Boolean useOverlayMode) {
public void run() { mClient.onOverlayModeChanged(useOverlayMode);
mClient.notifyReleased(); }
} };
};
Callback<Boolean> overlayModeChanged = new Callback<Boolean>() { getActivityForTestCommon().getActiveShell().setOverayModeChangedCallbackForTesting(
@Override overlayModeChanged);
public void onResult(Boolean useOverlayMode) {
mClient.onOverlayModeChanged(useOverlayMode);
} }
}; }, desc);
getActivityForTestCommon().getActiveShell().setOverayModeChangedCallbackForTesting(
overlayModeChanged);
} }
// Create an overlay with the given parameters and return it. // Create an overlay with the given parameters and return it.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment