Index: mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java |
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 4744508c6d40a38dabc90c93439d2ac44c922288..3b332e11456571fd97fe75cfcb7960ab8e9c0134 100644 |
--- a/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java |
+++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java |
@@ -10,7 +10,6 @@ import org.chromium.mojo.MojoTestCase; |
import org.chromium.mojo.bindings.BindingsTestUtils.CapturingErrorHandler; |
import org.chromium.mojo.bindings.test.mojom.imported.ImportedInterface; |
import org.chromium.mojo.bindings.test.mojom.sample.Factory; |
-import org.chromium.mojo.bindings.test.mojom.sample.FactoryClient; |
import org.chromium.mojo.bindings.test.mojom.sample.NamedObject; |
import org.chromium.mojo.bindings.test.mojom.sample.NamedObject.GetNameResponse; |
import org.chromium.mojo.bindings.test.mojom.sample.Request; |
@@ -101,18 +100,11 @@ public class InterfacesTest extends MojoTestCase { |
public class MockFactoryImpl extends CapturingErrorHandler implements Factory { |
private boolean mClosed = false; |
- private FactoryClient mFactoryClient; |
public boolean isClosed() { |
return mClosed; |
} |
- @Override |
- public void setClient(FactoryClient client) { |
- mFactoryClient = client; |
- mCloseablesToClose.add(client); |
- } |
- |
/** |
* @see org.chromium.mojo.bindings.Interface#close() |
*/ |
@@ -122,17 +114,18 @@ public class InterfacesTest extends MojoTestCase { |
} |
@Override |
- public void doStuff(Request request, MessagePipeHandle pipe) { |
+ public void doStuff(Request request, MessagePipeHandle pipe, DoStuffResponse callback) { |
if (pipe != null) { |
pipe.close(); |
} |
Response response = new Response(); |
response.x = 42; |
- mFactoryClient.didStuff(response, "Hello"); |
+ |
+ callback.call(response, "Hello"); |
} |
@Override |
- public void doStuff2(ConsumerHandle pipe) { |
+ public void doStuff2(ConsumerHandle pipe, DoStuff2Response callback) { |
} |
@Override |
@@ -154,54 +147,6 @@ public class InterfacesTest extends MojoTestCase { |
} |
/** |
- * Basic implementation of {@link FactoryClient}. |
- */ |
- public static class MockFactoryClientImpl implements FactoryClient { |
- |
- private boolean mClosed = false; |
- private boolean mDidStuffCalled = false; |
- |
- public boolean isClosed() { |
- return mClosed; |
- } |
- |
- public boolean wasDidStuffCalled() { |
- return mDidStuffCalled; |
- } |
- |
- /** |
- * @see org.chromium.mojo.bindings.Interface#close() |
- */ |
- @Override |
- public void close() { |
- mClosed = true; |
- } |
- |
- /** |
- * @see ConnectionErrorHandler#onConnectionError(MojoException) |
- */ |
- @Override |
- public void onConnectionError(MojoException e) { |
- } |
- |
- /** |
- * @see FactoryClient#didStuff(Response, java.lang.String) |
- */ |
- @Override |
- public void didStuff(Response response, String text) { |
- mDidStuffCalled = true; |
- } |
- |
- /** |
- * @see FactoryClient#didStuff2(String) |
- */ |
- @Override |
- public void didStuff2(String text) { |
- } |
- |
- } |
- |
- /** |
* @see MojoTestCase#tearDown() |
*/ |
@Override |
@@ -225,17 +170,6 @@ public class InterfacesTest extends MojoTestCase { |
return proxy; |
} |
- private <I extends InterfaceWithClient<C>, P extends InterfaceWithClient.Proxy<C>, |
- C extends Interface> P newProxyOverPipeWithClient( |
- InterfaceWithClient.Manager<I, P, C> manager, I impl, C client) { |
- Pair<MessagePipeHandle, MessagePipeHandle> handles = |
- CoreImpl.getInstance().createMessagePipe(null); |
- P proxy = manager.attachProxy(handles.first, client); |
- 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|. |
@@ -311,34 +245,13 @@ public class InterfacesTest extends MojoTestCase { |
@SmallTest |
public void testInterfaceClosing() { |
MockFactoryImpl impl = new MockFactoryImpl(); |
- MockFactoryClientImpl client = new MockFactoryClientImpl(); |
- Factory.Proxy proxy = newProxyOverPipeWithClient( |
- Factory.MANAGER, impl, client); |
+ Factory.Proxy proxy = newProxyOverPipe(Factory.MANAGER, impl); |
assertFalse(impl.isClosed()); |
- assertFalse(client.isClosed()); |
proxy.close(); |
runLoopUntilIdle(); |
assertTrue(impl.isClosed()); |
- assertTrue(client.isClosed()); |
- } |
- |
- @SmallTest |
- public void testClient() { |
- MockFactoryImpl impl = new MockFactoryImpl(); |
- MockFactoryClientImpl client = new MockFactoryClientImpl(); |
- Factory.Proxy proxy = newProxyOverPipeWithClient( |
- Factory.MANAGER, impl, client); |
- Request request = new Request(); |
- request.x = 42; |
- proxy.doStuff(request, null); |
- |
- assertFalse(client.wasDidStuffCalled()); |
- |
- runLoopUntilIdle(); |
- |
- assertTrue(client.wasDidStuffCalled()); |
} |
} |