summaryrefslogtreecommitdiffstats
path: root/mojo/android/javatests/src
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2015-05-13 19:07:14 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-14 02:07:24 +0000
commitd24477996ef10584ced040a13f82e7c7dc0216b1 (patch)
tree909956d053475acad41999ee93e75241468ef90c /mojo/android/javatests/src
parent32bef8c15d2a2055cf7cee0b186c3350a97d7c91 (diff)
downloadchromium_src-d24477996ef10584ced040a13f82e7c7dc0216b1.zip
chromium_src-d24477996ef10584ced040a13f82e7c7dc0216b1.tar.gz
chromium_src-d24477996ef10584ced040a13f82e7c7dc0216b1.tar.bz2
Update mojo sdk to rev f84766d3b6420b7cf6a113d9d65d73cb5fe18d90
Noteworthy in this roll is that InterfacePtrs may no longer be bound-to or passed-as simple pipe handles, but instead as InterfacePtrInfos. This requires updating several call sites of InterfacePtr's Bind and PassMessagePipe. BUG= TBR=ben@chromium.org Review URL: https://codereview.chromium.org/1127293003 Cr-Commit-Position: refs/heads/master@{#329783}
Diffstat (limited to 'mojo/android/javatests/src')
-rw-r--r--mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTestUtils.java15
-rw-r--r--mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java30
-rw-r--r--mojo/android/javatests/src/org/chromium/mojo/bindings/InterfaceControlMessageTest.java129
-rw-r--r--mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java22
-rw-r--r--mojo/android/javatests/src/org/chromium/mojo/bindings/ReadAndDispatchMessageTest.java8
-rw-r--r--mojo/android/javatests/src/org/chromium/mojo/bindings/RouterTest.java133
6 files changed, 293 insertions, 44 deletions
diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTestUtils.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTestUtils.java
index 880577a..5554f80 100644
--- a/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTestUtils.java
+++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTestUtils.java
@@ -6,9 +6,12 @@ package org.chromium.mojo.bindings;
import org.chromium.mojo.TestUtils;
import org.chromium.mojo.system.Handle;
+import org.chromium.mojo.system.MessagePipeHandle;
import org.chromium.mojo.system.MojoException;
import org.chromium.mojo.system.Pair;
+import org.chromium.mojo.system.impl.CoreImpl;
+import java.io.Closeable;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
@@ -85,11 +88,21 @@ public class BindingsTestUtils {
public static Message newRandomMessage(int size) {
assert size > 16;
ByteBuffer message = TestUtils.newRandomBuffer(size);
- int[] headerAsInts = { 16, 2, 0, 0 };
+ int[] headerAsInts = {16, 2, 0, 0};
for (int i = 0; i < 4; ++i) {
message.putInt(4 * i, headerAsInts[i]);
}
message.position(0);
return new Message(message, new ArrayList<Handle>());
}
+
+ public static <I extends Interface, P extends Interface.Proxy> P newProxyOverPipe(
+ Interface.Manager<I, P> manager, I impl, List<Closeable> toClose) {
+ Pair<MessagePipeHandle, MessagePipeHandle> handles =
+ CoreImpl.getInstance().createMessagePipe(null);
+ P proxy = manager.attachProxy(handles.first, 0);
+ toClose.add(proxy);
+ manager.bind(impl, handles.second);
+ return proxy;
+ }
}
diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java
index c7c1126..d47223b 100644
--- a/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java
+++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsVersioningTest.java
@@ -56,6 +56,8 @@ public class BindingsVersioningTest extends TestCase {
MultiVersionStruct output = MultiVersionStruct.deserialize(v0.serialize(null));
assertEquals(expected, output);
+ assertEquals(0, v0.getVersion());
+ assertEquals(0, output.getVersion());
}
{
@@ -68,6 +70,8 @@ public class BindingsVersioningTest extends TestCase {
MultiVersionStruct output = MultiVersionStruct.deserialize(v1.serialize(null));
assertEquals(expected, output);
+ assertEquals(1, v1.getVersion());
+ assertEquals(1, output.getVersion());
}
{
@@ -82,6 +86,8 @@ public class BindingsVersioningTest extends TestCase {
MultiVersionStruct output = MultiVersionStruct.deserialize(v3.serialize(null));
assertEquals(expected, output);
+ assertEquals(3, v3.getVersion());
+ assertEquals(3, output.getVersion());
}
{
@@ -98,6 +104,8 @@ public class BindingsVersioningTest extends TestCase {
MultiVersionStruct output = MultiVersionStruct.deserialize(v5.serialize(null));
assertEquals(expected, output);
+ assertEquals(5, v5.getVersion());
+ assertEquals(5, output.getVersion());
}
{
@@ -125,6 +133,8 @@ public class BindingsVersioningTest extends TestCase {
output.fMessagePipe = expected.fMessagePipe;
assertEquals(expected, output);
+ assertEquals(7, v7.getVersion());
+ assertEquals(7, output.getVersion());
}
}
@@ -133,13 +143,14 @@ public class BindingsVersioningTest extends TestCase {
*/
@SmallTest
public void testNewToOld() {
+ MultiVersionStruct struct = newStruct();
{
MultiVersionStructV0 expected = new MultiVersionStructV0();
expected.fInt32 = 123;
- MultiVersionStructV0 output =
- MultiVersionStructV0.deserialize(newStruct().serialize(null));
+ MultiVersionStructV0 output = MultiVersionStructV0.deserialize(struct.serialize(null));
assertEquals(expected, output);
+ assertEquals(9, output.getVersion());
}
{
@@ -147,9 +158,9 @@ public class BindingsVersioningTest extends TestCase {
expected.fInt32 = 123;
expected.fRect = newRect(5);
- MultiVersionStructV1 output =
- MultiVersionStructV1.deserialize(newStruct().serialize(null));
+ MultiVersionStructV1 output = MultiVersionStructV1.deserialize(struct.serialize(null));
assertEquals(expected, output);
+ assertEquals(9, output.getVersion());
}
{
@@ -158,9 +169,9 @@ public class BindingsVersioningTest extends TestCase {
expected.fRect = newRect(5);
expected.fString = "hello";
- MultiVersionStructV3 output =
- MultiVersionStructV3.deserialize(newStruct().serialize(null));
+ MultiVersionStructV3 output = MultiVersionStructV3.deserialize(struct.serialize(null));
assertEquals(expected, output);
+ assertEquals(9, output.getVersion());
}
{
@@ -170,9 +181,9 @@ public class BindingsVersioningTest extends TestCase {
expected.fString = "hello";
expected.fArray = new byte[] {10, 9, 8};
- MultiVersionStructV5 output =
- MultiVersionStructV5.deserialize(newStruct().serialize(null));
+ MultiVersionStructV5 output = MultiVersionStructV5.deserialize(struct.serialize(null));
assertEquals(expected, output);
+ assertEquals(9, output.getVersion());
}
{
@@ -184,7 +195,7 @@ public class BindingsVersioningTest extends TestCase {
expected.fArray = new byte[] {10, 9, 8};
expected.fBool = true;
- MultiVersionStruct input = newStruct();
+ MultiVersionStruct input = struct;
input.fMessagePipe = CoreImpl.getInstance()
.acquireNativeHandle(expectedHandle)
.toMessagePipeHandle();
@@ -195,6 +206,7 @@ public class BindingsVersioningTest extends TestCase {
output.fMessagePipe = expected.fMessagePipe;
assertEquals(expected, output);
+ assertEquals(9, output.getVersion());
}
}
}
diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfaceControlMessageTest.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfaceControlMessageTest.java
new file mode 100644
index 0000000..c101675
--- /dev/null
+++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfaceControlMessageTest.java
@@ -0,0 +1,129 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.mojo.bindings;
+
+import android.test.suitebuilder.annotation.SmallTest;
+
+import org.chromium.mojo.MojoTestCase;
+import org.chromium.mojo.bindings.Callbacks.Callback1;
+import org.chromium.mojo.bindings.test.mojom.sample.Enum;
+import org.chromium.mojo.bindings.test.mojom.sample.IntegerAccessor;
+import org.chromium.mojo.system.MojoException;
+
+import java.io.Closeable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Tests for interface control messages.
+ */
+public class InterfaceControlMessageTest extends MojoTestCase {
+ private final List<Closeable> mCloseablesToClose = new ArrayList<Closeable>();
+
+ /**
+ * See mojo/public/interfaces/bindings/tests/sample_interfaces.mojom.
+ */
+ class IntegerAccessorImpl extends SideEffectFreeCloseable implements IntegerAccessor {
+ private long mValue = 0;
+ private int mEnum = 0;
+ private boolean mEncounteredError = false;
+
+ /**
+ * @see ConnectionErrorHandler#onConnectionError(MojoException)
+ */
+ @Override
+ public void onConnectionError(MojoException e) {
+ mEncounteredError = true;
+ }
+
+ /**
+ * @see IntegerAccessor#getInteger(IntegerAccessor.GetIntegerResponse)
+ */
+ @Override
+ public void getInteger(GetIntegerResponse response) {
+ response.call(mValue, mEnum);
+ }
+
+ /**
+ * @see IntegerAccessor#setInteger(long, int)
+ */
+ @Override
+ public void setInteger(long value, int enumValue) {
+ mValue = value;
+ mEnum = enumValue;
+ }
+
+ public long getValue() {
+ return mValue;
+ }
+
+ public boolean encounteredError() {
+ return mEncounteredError;
+ }
+ }
+
+ /**
+ * @see MojoTestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ // Close the elements in the reverse order they were added. This is needed because it is an
+ // error to close the handle of a proxy without closing the proxy first.
+ Collections.reverse(mCloseablesToClose);
+ for (Closeable c : mCloseablesToClose) {
+ c.close();
+ }
+ super.tearDown();
+ }
+
+ @SmallTest
+ public void testQueryVersion() {
+ IntegerAccessor.Proxy p = BindingsTestUtils.newProxyOverPipe(
+ IntegerAccessor.MANAGER, new IntegerAccessorImpl(), mCloseablesToClose);
+ assertEquals(0, p.getProxyHandler().getVersion());
+ p.getProxyHandler().queryVersion(new Callback1<Integer>() {
+ @Override
+ public void call(Integer version) {
+ assertEquals(3, version.intValue());
+ }
+ });
+ runLoopUntilIdle();
+ assertEquals(3, p.getProxyHandler().getVersion());
+ }
+
+ @SmallTest
+ public void testRequireVersion() {
+ IntegerAccessorImpl impl = new IntegerAccessorImpl();
+ IntegerAccessor.Proxy p = BindingsTestUtils.newProxyOverPipe(
+ IntegerAccessor.MANAGER, impl, mCloseablesToClose);
+
+ assertEquals(0, p.getProxyHandler().getVersion());
+
+ p.getProxyHandler().requireVersion(1);
+ assertEquals(1, p.getProxyHandler().getVersion());
+ p.setInteger(123, Enum.VALUE);
+ runLoopUntilIdle();
+ assertFalse(impl.encounteredError());
+ assertEquals(123, impl.getValue());
+
+ p.getProxyHandler().requireVersion(3);
+ assertEquals(3, p.getProxyHandler().getVersion());
+ p.setInteger(456, Enum.VALUE);
+ runLoopUntilIdle();
+ assertFalse(impl.encounteredError());
+ assertEquals(456, impl.getValue());
+
+ // Require a version that is not supported by the implementation side.
+ p.getProxyHandler().requireVersion(4);
+ // getVersion() is updated synchronously.
+ assertEquals(4, p.getProxyHandler().getVersion());
+ p.setInteger(789, Enum.VALUE);
+ runLoopUntilIdle();
+ assertTrue(impl.encounteredError());
+ // The call to setInteger() after requireVersion() is ignored.
+ assertEquals(456, impl.getValue());
+ }
+}
diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java
index 58e2351..cb4b8a2 100644
--- a/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java
+++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java
@@ -175,16 +175,6 @@ public class InterfacesTest extends MojoTestCase {
super.tearDown();
}
- private <I extends Interface, P extends Interface.Proxy> P newProxyOverPipe(
- Interface.Manager<I, P> manager, I impl) {
- Pair<MessagePipeHandle, MessagePipeHandle> handles =
- CoreImpl.getInstance().createMessagePipe(null);
- P proxy = manager.attachProxy(handles.first);
- mCloseablesToClose.add(proxy);
- manager.bind(impl, handles.second);
- return proxy;
- }
-
/**
* Check that the given proxy receives the calls. If |impl| is not null, also check that the
* calls are forwared to |impl|.
@@ -241,14 +231,16 @@ public class InterfacesTest extends MojoTestCase {
@SmallTest
public void testProxyAndStubOverPipe() {
MockNamedObjectImpl impl = new MockNamedObjectImpl();
- NamedObject.Proxy proxy = newProxyOverPipe(NamedObject.MANAGER, impl);
+ NamedObject.Proxy proxy =
+ BindingsTestUtils.newProxyOverPipe(NamedObject.MANAGER, impl, mCloseablesToClose);
checkProxy(proxy, impl);
}
@SmallTest
public void testFactoryOverPipe() {
- Factory.Proxy proxy = newProxyOverPipe(Factory.MANAGER, new MockFactoryImpl());
+ Factory.Proxy proxy = BindingsTestUtils.newProxyOverPipe(
+ Factory.MANAGER, new MockFactoryImpl(), mCloseablesToClose);
Pair<NamedObject.Proxy, InterfaceRequest<NamedObject>> request =
NamedObject.MANAGER.getInterfaceRequest(CoreImpl.getInstance());
mCloseablesToClose.add(request.first);
@@ -260,7 +252,8 @@ public class InterfacesTest extends MojoTestCase {
@SmallTest
public void testInterfaceClosing() {
MockFactoryImpl impl = new MockFactoryImpl();
- Factory.Proxy proxy = newProxyOverPipe(Factory.MANAGER, impl);
+ Factory.Proxy proxy =
+ BindingsTestUtils.newProxyOverPipe(Factory.MANAGER, impl, mCloseablesToClose);
assertFalse(impl.isClosed());
@@ -273,7 +266,8 @@ public class InterfacesTest extends MojoTestCase {
@SmallTest
public void testResponse() {
MockFactoryImpl impl = new MockFactoryImpl();
- Factory.Proxy proxy = newProxyOverPipe(Factory.MANAGER, impl);
+ Factory.Proxy proxy =
+ BindingsTestUtils.newProxyOverPipe(Factory.MANAGER, impl, mCloseablesToClose);
Request request = new Request();
request.x = 42;
Pair<MessagePipeHandle, MessagePipeHandle> handles =
diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/ReadAndDispatchMessageTest.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/ReadAndDispatchMessageTest.java
index 54f0155..f2edb01 100644
--- a/mojo/android/javatests/src/org/chromium/mojo/bindings/ReadAndDispatchMessageTest.java
+++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/ReadAndDispatchMessageTest.java
@@ -68,8 +68,8 @@ public class ReadAndDispatchMessageTest extends MojoTestCase {
@SmallTest
public void testReadAndDispatchMessage() {
mHandles.first.writeMessage(mData, mHandlesToSend, MessagePipeHandle.WriteFlags.NONE);
- assertEquals(MojoResult.OK,
- Connector.readAndDispatchMessage(mHandles.second, mMessageReceiver));
+ assertEquals(MojoResult.OK, Connector.readAndDispatchMessage(mHandles.second,
+ mMessageReceiver).getMojoResult());
assertEquals(1, mMessageReceiver.messages.size());
Message message = mMessageReceiver.messages.get(0);
mHandlesToClose.addAll(message.getHandles());
@@ -86,8 +86,8 @@ public class ReadAndDispatchMessageTest extends MojoTestCase {
*/
@SmallTest
public void testReadAndDispatchMessageOnEmptyHandle() {
- assertEquals(MojoResult.SHOULD_WAIT,
- Connector.readAndDispatchMessage(mHandles.second, mMessageReceiver));
+ assertEquals(MojoResult.SHOULD_WAIT, Connector.readAndDispatchMessage(mHandles.second,
+ mMessageReceiver).getMojoResult());
assertEquals(0, mMessageReceiver.messages.size());
}
diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/RouterTest.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/RouterTest.java
index f976e59..e614008 100644
--- a/mojo/android/javatests/src/org/chromium/mojo/bindings/RouterTest.java
+++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/RouterTest.java
@@ -10,6 +10,8 @@ import org.chromium.mojo.MojoTestCase;
import org.chromium.mojo.bindings.BindingsTestUtils.CapturingErrorHandler;
import org.chromium.mojo.bindings.BindingsTestUtils.RecordingMessageReceiverWithResponder;
import org.chromium.mojo.system.Core;
+import org.chromium.mojo.system.Core.HandleSignals;
+import org.chromium.mojo.system.Core.WaitResult;
import org.chromium.mojo.system.Handle;
import org.chromium.mojo.system.MessagePipeHandle;
import org.chromium.mojo.system.MojoResult;
@@ -91,17 +93,16 @@ public class RouterTest extends MojoTestCase {
}
/**
- * Testing receiving a message via the router that expected a response.
+ * Sends a message to the Router.
+ *
+ * @param messageIndex Used when sending multiple messages to indicate the index of this
+ * message.
+ * @param requestMessageType The message type to use in the header of the sent message.
+ * @param requestId The requestId to use in the header of the sent message.
*/
- @SmallTest
- public void testReceivingViaRouterWithResponse() {
- final int requestMessageType = 0xdead;
- final int responseMessageType = 0xbeef;
- final int requestId = 0xdeadbeaf;
-
- // Sending a message expecting a response.
- MessageHeader header = new MessageHeader(requestMessageType,
- MessageHeader.MESSAGE_EXPECTS_RESPONSE_FLAG, requestId);
+ private void sendMessageToRouter(int messageIndex, int requestMessageType, int requestId) {
+ MessageHeader header = new MessageHeader(
+ requestMessageType, MessageHeader.MESSAGE_EXPECTS_RESPONSE_FLAG, requestId);
Encoder encoder = new Encoder(CoreImpl.getInstance(), header.getSize());
header.encode(encoder);
Message headerMessage = encoder.getMessage();
@@ -109,18 +110,32 @@ public class RouterTest extends MojoTestCase {
MessagePipeHandle.WriteFlags.NONE);
runLoopUntilIdle();
- assertEquals(1, mReceiver.messagesWithReceivers.size());
+ assertEquals(messageIndex + 1, mReceiver.messagesWithReceivers.size());
Pair<Message, MessageReceiver> receivedMessage =
- mReceiver.messagesWithReceivers.get(0);
+ mReceiver.messagesWithReceivers.get(messageIndex);
assertEquals(headerMessage.getData(), receivedMessage.first.getData());
+ }
- // Sending the response.
- MessageHeader responseHeader = new MessageHeader(responseMessageType,
- MessageHeader.MESSAGE_EXPECTS_RESPONSE_FLAG, requestId);
- encoder = new Encoder(CoreImpl.getInstance(), header.getSize());
+ /**
+ * Sends a response message from the Router.
+ *
+ * @param messageIndex Used when sending responses to multiple messages to indicate the index
+ * of the message that this message is a response to.
+ * @param responseMessageType The message type to use in the header of the response message.
+ */
+ private void sendResponseFromRouter(int messageIndex, int responseMessageType) {
+ Pair<Message, MessageReceiver> receivedMessage =
+ mReceiver.messagesWithReceivers.get(messageIndex);
+
+ long requestId = receivedMessage.first.asServiceMessage().getHeader().getRequestId();
+
+ MessageHeader responseHeader = new MessageHeader(
+ responseMessageType, MessageHeader.MESSAGE_IS_RESPONSE_FLAG, requestId);
+ Encoder encoder = new Encoder(CoreImpl.getInstance(), responseHeader.getSize());
responseHeader.encode(encoder);
Message message = encoder.getMessage();
receivedMessage.second.accept(message);
+
ByteBuffer receivedResponseMessage = ByteBuffer.allocateDirect(responseHeader.getSize());
ResultAnd<MessagePipeHandle.ReadMessageResult> result =
mHandle.readMessage(receivedResponseMessage, 0, MessagePipeHandle.ReadFlags.NONE);
@@ -128,4 +143,90 @@ public class RouterTest extends MojoTestCase {
assertEquals(MojoResult.OK, result.getMojoResult());
assertEquals(message.getData(), receivedResponseMessage);
}
+
+ /**
+ * Clears {@code mReceiver.messagesWithReceivers} allowing all message receivers to be
+ * finalized.
+ * <p>
+ * Since there is no way to force the Garbage Collector to actually call finalize and we want to
+ * test the effects of the finalize() method, we explicitly call finalize() on all of the
+ * message receivers. We do this in a custom thread to better approximate what the JVM does.
+ */
+ private void clearAllMessageReceivers() {
+ Thread myFinalizerThread = new Thread() {
+ @Override
+ public void run() {
+ for (Pair<Message, MessageReceiver> receivedMessage :
+ mReceiver.messagesWithReceivers) {
+ RouterImpl.ResponderThunk thunk =
+ (RouterImpl.ResponderThunk) receivedMessage.second;
+ try {
+ thunk.finalize();
+ } catch (Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ };
+ myFinalizerThread.start();
+ try {
+ myFinalizerThread.join();
+ } catch (InterruptedException e) {
+ // ignore.
+ }
+ mReceiver.messagesWithReceivers.clear();
+ }
+
+ /**
+ * Testing receiving a message via the router that expected a response.
+ */
+ @SmallTest
+ public void testReceivingViaRouterWithResponse() {
+ final int requestMessageType = 0xdead;
+ final int responseMessageType = 0xbeef;
+ final int requestId = 0xdeadbeaf;
+
+ // Send a message expecting a response.
+ sendMessageToRouter(0, requestMessageType, requestId);
+
+ // Sending the response.
+ sendResponseFromRouter(0, responseMessageType);
+ }
+
+ /**
+ * Tests that if a callback is dropped (i.e. becomes unreachable and is finalized
+ * without being used), then the message pipe will be closed.
+ */
+ @SmallTest
+ public void testDroppingReceiverWithoutUsingIt() {
+ // Send 10 messages to the router without sending a response.
+ for (int i = 0; i < 10; i++) {
+ sendMessageToRouter(i, i, i);
+ }
+
+ // Now send the 10 responses. This should work fine.
+ for (int i = 0; i < 10; i++) {
+ sendResponseFromRouter(i, i);
+ }
+
+ // Clear all MessageRecievers so that the ResponderThunks will
+ // be finalized.
+ clearAllMessageReceivers();
+
+ // Send another message to the router without sending a response.
+ sendMessageToRouter(0, 0, 0);
+
+ // Clear the MessageReciever so that the ResponderThunk will
+ // be finalized. Since the RespondeThunk was never used, this
+ // should close the pipe.
+ clearAllMessageReceivers();
+ // The close() occurs asynchronously on this thread.
+ runLoopUntilIdle();
+
+ // Confirm that the pipe was closed on the Router side.
+ HandleSignals closedFlag = HandleSignals.none().setPeerClosed(true);
+ WaitResult result = mHandle.wait(closedFlag, 0);
+ assertEquals(MojoResult.OK, result.getMojoResult());
+ assertEquals(closedFlag, result.getHandleSignalsState().getSatisfiedSignals());
+ }
}