summaryrefslogtreecommitdiffstats
path: root/mojo/android/javatests/src
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2015-03-03 08:31:04 -0800
committerCommit bot <commit-bot@chromium.org>2015-03-03 16:31:38 +0000
commitcbca72f3c9e31309a28b98624e1e0147c5dca7a1 (patch)
tree1bde2f531bed308832135e8d66a784afb0e258b1 /mojo/android/javatests/src
parent633e315de496ed52f2aed727ab36b23ea2fa3e87 (diff)
downloadchromium_src-cbca72f3c9e31309a28b98624e1e0147c5dca7a1.zip
chromium_src-cbca72f3c9e31309a28b98624e1e0147c5dca7a1.tar.gz
chromium_src-cbca72f3c9e31309a28b98624e1e0147c5dca7a1.tar.bz2
Update mojo sdk to rev 3d23dae011859a2aae49f1d1adde705c8e85d819
Highlights: - mojo::ChannelInit has been replaced with content::ChannelInit. - ScopedIPCSupport has been added so Mojo consumers can ensure the EDK is initialized. - single process mode now uses some evil tricks to get child threads to create their mojo client channels on the browser I/O thread. - several Android bits adapted to new interfaces - a number of tests have been adapted to work properly in spite of unconventional process arrangements BUG=None Review URL: https://codereview.chromium.org/954643002 Cr-Commit-Position: refs/heads/master@{#318883}
Diffstat (limited to 'mojo/android/javatests/src')
-rw-r--r--mojo/android/javatests/src/org/chromium/mojo/bindings/InterfacesTest.java97
-rw-r--r--mojo/android/javatests/src/org/chromium/mojo/bindings/ValidationTest.java46
-rw-r--r--mojo/android/javatests/src/org/chromium/mojo/bindings/test/mojom/mojo/IntegrationTestInterface2TestHelper.java31
3 files changed, 8 insertions, 166 deletions
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 4744508..3b332e1 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());
}
}
diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/ValidationTest.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/ValidationTest.java
index 076c94b..7942be6 100644
--- a/mojo/android/javatests/src/org/chromium/mojo/bindings/ValidationTest.java
+++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/ValidationTest.java
@@ -11,8 +11,7 @@ import org.chromium.base.test.util.UrlUtils;
import org.chromium.mojo.HandleMock;
import org.chromium.mojo.MojoTestCase;
import org.chromium.mojo.bindings.test.mojom.mojo.ConformanceTestInterface;
-import org.chromium.mojo.bindings.test.mojom.mojo.IntegrationTestInterface1;
-import org.chromium.mojo.bindings.test.mojom.mojo.IntegrationTestInterface2TestHelper;
+import org.chromium.mojo.bindings.test.mojom.mojo.IntegrationTestInterface;
import org.chromium.mojo.system.Handle;
import java.io.File;
@@ -119,41 +118,6 @@ public class ValidationTest extends MojoTestCase {
}
}
- private static class RoutingMessageReceiver implements MessageReceiver {
- private final MessageReceiver mRequest;
- private final MessageReceiver mResponse;
-
- private RoutingMessageReceiver(MessageReceiver request, MessageReceiver response) {
- this.mRequest = request;
- this.mResponse = response;
- }
-
- /**
- * @see MessageReceiver#accept(Message)
- */
- @Override
- public boolean accept(Message message) {
- try {
- MessageHeader header = message.asServiceMessage().getHeader();
- if (header.hasFlag(MessageHeader.MESSAGE_IS_RESPONSE_FLAG)) {
- return mResponse.accept(message);
- } else {
- return mRequest.accept(message);
- }
- } catch (DeserializationException e) {
- return false;
- }
- }
-
- /**
- * @see MessageReceiver#close()
- */
- @Override
- public void close() {
- }
-
- }
-
/**
* A trivial message receiver that refuses all messages it receives.
*/
@@ -188,11 +152,7 @@ public class ValidationTest extends MojoTestCase {
*/
@SmallTest
public void testIntegration() throws FileNotFoundException {
- runTest("integration_",
- new RoutingMessageReceiver(IntegrationTestInterface1.MANAGER.buildStub(null,
- IntegrationTestInterface1.MANAGER.buildProxy(null,
- new SinkMessageReceiver())),
- IntegrationTestInterface2TestHelper
- .newIntegrationTestInterface2MethodCallback()));
+ runTest("integration_", IntegrationTestInterface.MANAGER.buildStub(null,
+ IntegrationTestInterface.MANAGER.buildProxy(null, new SinkMessageReceiver())));
}
}
diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/test/mojom/mojo/IntegrationTestInterface2TestHelper.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/test/mojom/mojo/IntegrationTestInterface2TestHelper.java
deleted file mode 100644
index 2a2b6b8..0000000
--- a/mojo/android/javatests/src/org/chromium/mojo/bindings/test/mojom/mojo/IntegrationTestInterface2TestHelper.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2014 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.test.mojom.mojo;
-
-import org.chromium.mojo.bindings.MessageReceiver;
-import org.chromium.mojo.bindings.test.mojom.mojo.IntegrationTestInterface2.Method0Response;
-import org.chromium.mojo.bindings.test.mojom.mojo.IntegrationTestInterface2_Internal.IntegrationTestInterface2Method0ResponseParamsForwardToCallback;
-
-/**
- * Helper class to access {@link IntegrationTestInterface2_Internal} package protected method for
- * tests.
- */
-public class IntegrationTestInterface2TestHelper {
-
- private static final class SinkMethod0Response implements Method0Response {
- @Override
- public void call(byte[] arg1) {
- }
- }
-
- /**
- * Creates a new {@link MessageReceiver} to use for the callback of
- * |IntegrationTestInterface2#method0(Method0Response)|.
- */
- public static MessageReceiver newIntegrationTestInterface2MethodCallback() {
- return new IntegrationTestInterface2Method0ResponseParamsForwardToCallback(
- new SinkMethod0Response());
- }
-}