diff options
author | pastarmovj@google.com <pastarmovj@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 12:36:59 +0000 |
---|---|---|
committer | pastarmovj@google.com <pastarmovj@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-25 12:36:59 +0000 |
commit | 8723cf789893fba470c4edc5bf75bbcafad6f92e (patch) | |
tree | 7e53a9e939740ec86d159e43d7e4157fbb80c93b /mojo/android/javatests | |
parent | 326b0b93235ae1c9591c717a4ae0e7b4b2609d41 (diff) | |
download | chromium_src-8723cf789893fba470c4edc5bf75bbcafad6f92e.zip chromium_src-8723cf789893fba470c4edc5bf75bbcafad6f92e.tar.gz chromium_src-8723cf789893fba470c4edc5bf75bbcafad6f92e.tar.bz2 |
Revert 279677 "Generate java bindings for structs."
Broke the Linux x64 build http://build.chromium.org/p/chromium/builders/Linux%20x64/builds/66839/steps/compile/logs/stdio
> Generate java bindings for structs.
>
> This CL introduces bindings for struct. It only generates fields and not
> serialization/deserialization methods.
>
> R=rmcilroy@chromium.org, viettrungluu@chromium.org
>
> Review URL: https://codereview.chromium.org/306893010
TBR=qsr@chromium.org
Review URL: https://codereview.chromium.org/354833003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279688 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'mojo/android/javatests')
3 files changed, 29 insertions, 305 deletions
diff --git a/mojo/android/javatests/src/org/chromium/mojo/HandleMock.java b/mojo/android/javatests/src/org/chromium/mojo/HandleMock.java deleted file mode 100644 index 82b0f45..0000000 --- a/mojo/android/javatests/src/org/chromium/mojo/HandleMock.java +++ /dev/null @@ -1,211 +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; - -import org.chromium.mojo.system.Core; -import org.chromium.mojo.system.DataPipe; -import org.chromium.mojo.system.DataPipe.ConsumerHandle; -import org.chromium.mojo.system.DataPipe.ProducerHandle; -import org.chromium.mojo.system.Handle; -import org.chromium.mojo.system.MessagePipeHandle; -import org.chromium.mojo.system.MojoResult; -import org.chromium.mojo.system.SharedBufferHandle; -import org.chromium.mojo.system.UntypedHandle; -import org.chromium.mojo.system.impl.CoreImpl; - -import java.nio.ByteBuffer; -import java.util.List; - -/** - * A mock handle, that does nothing. - */ -public class HandleMock implements UntypedHandle, MessagePipeHandle, - ProducerHandle, ConsumerHandle, SharedBufferHandle { - - /** - * @see Handle#close() - */ - @Override - public void close() { - // Do nothing. - } - - /** - * @see Handle#wait(Core.WaitFlags, long) - */ - @Override - public int wait(Core.WaitFlags flags, long deadline) { - // Do nothing. - return MojoResult.OK; - } - - /** - * @see Handle#isValid() - */ - @Override - public boolean isValid() { - return true; - } - - /** - * @see Handle#toUntypedHandle() - */ - @Override - public UntypedHandle toUntypedHandle() { - return this; - } - - /** - * @see org.chromium.mojo.system.Handle#getCore() - */ - @Override - public Core getCore() { - return CoreImpl.getInstance(); - } - - /** - * @see ConsumerHandle#discardData(int, DataPipe.ReadFlags) - */ - @Override - public int discardData(int numBytes, DataPipe.ReadFlags flags) { - // Do nothing. - return 0; - } - - /** - * @see ConsumerHandle#readData(java.nio.ByteBuffer, DataPipe.ReadFlags) - */ - @Override - public int readData(ByteBuffer elements, - DataPipe.ReadFlags flags) { - // Do nothing. - return 0; - } - - /** - * @see ConsumerHandle#beginReadData(int, DataPipe.ReadFlags) - */ - @Override - public ByteBuffer beginReadData(int numBytes, - DataPipe.ReadFlags flags) { - // Do nothing. - return null; - } - - /** - * @see ConsumerHandle#endReadData(int) - */ - @Override - public void endReadData(int numBytesRead) { - // Do nothing. - } - - /** - * @see ProducerHandle#writeData(java.nio.ByteBuffer, DataPipe.WriteFlags) - */ - @Override - public int writeData(ByteBuffer elements, - DataPipe.WriteFlags flags) { - // Do nothing. - return 0; - } - - /** - * @see ProducerHandle#beginWriteData(int, DataPipe.WriteFlags) - */ - @Override - public ByteBuffer beginWriteData(int numBytes, - DataPipe.WriteFlags flags) { - // Do nothing. - return null; - } - - /** - * @see ProducerHandle#endWriteData(int) - */ - @Override - public void endWriteData(int numBytesWritten) { - // Do nothing. - } - - /** - * @see MessagePipeHandle#writeMessage(java.nio.ByteBuffer, java.util.List, - * MessagePipeHandle.WriteFlags) - */ - @Override - public void writeMessage(ByteBuffer bytes, List<? extends Handle> handles, - WriteFlags flags) { - // Do nothing. - } - - /** - * @see MessagePipeHandle#readMessage(java.nio.ByteBuffer, int, MessagePipeHandle.ReadFlags) - */ - @Override - public ReadMessageResult readMessage(ByteBuffer bytes, int maxNumberOfHandles, - ReadFlags flags) { - // Do nothing. - return new ReadMessageResult(); - } - - /** - * @see UntypedHandle#toMessagePipeHandle() - */ - @Override - public MessagePipeHandle toMessagePipeHandle() { - return this; - } - - /** - * @see UntypedHandle#toDataPipeConsumerHandle() - */ - @Override - public ConsumerHandle toDataPipeConsumerHandle() { - return this; - } - - /** - * @see UntypedHandle#toDataPipeProducerHandle() - */ - @Override - public ProducerHandle toDataPipeProducerHandle() { - return this; - } - - /** - * @see UntypedHandle#toSharedBufferHandle() - */ - @Override - public SharedBufferHandle toSharedBufferHandle() { - return this; - } - - /** - * @see SharedBufferHandle#duplicate(SharedBufferHandle.DuplicateOptions) - */ - @Override - public SharedBufferHandle duplicate(DuplicateOptions options) { - // Do nothing. - return null; - } - - /** - * @see SharedBufferHandle#map(long, long, SharedBufferHandle.MapFlags) - */ - @Override - public ByteBuffer map(long offset, long numBytes, MapFlags flags) { - // Do nothing. - return null; - } - - /** - * @see SharedBufferHandle#unmap(java.nio.ByteBuffer) - */ - @Override - public void unmap(ByteBuffer buffer) { - // Do nothing. - } - -} diff --git a/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTest.java b/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTest.java index b084b7c..27fba62 100644 --- a/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTest.java +++ b/mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTest.java @@ -8,17 +8,11 @@ import android.test.suitebuilder.annotation.SmallTest; import junit.framework.TestCase; -import org.chromium.mojo.bindings.test.mojom.imported.Color; -import org.chromium.mojo.bindings.test.mojom.imported.Point; -import org.chromium.mojo.bindings.test.mojom.imported.Shape; -import org.chromium.mojo.bindings.test.mojom.imported.Thing; -import org.chromium.mojo.bindings.test.mojom.sample.Bar; -import org.chromium.mojo.bindings.test.mojom.sample.DefaultsTest; -import org.chromium.mojo.bindings.test.mojom.sample.Enum; -import org.chromium.mojo.bindings.test.mojom.sample.Foo; -import org.chromium.mojo.bindings.test.mojom.sample.InterfaceConstants; -import org.chromium.mojo.bindings.test.mojom.sample.SampleServiceConstants; -import org.chromium.mojo.system.MessagePipeHandle; +import org.chromium.mojo.bindings.test.imported.Color; +import org.chromium.mojo.bindings.test.imported.Shape; +import org.chromium.mojo.bindings.test.sample.Enum; +import org.chromium.mojo.bindings.test.sample.InterfaceConstants; +import org.chromium.mojo.bindings.test.sample.SampleServiceConstants; import java.lang.reflect.Field; import java.lang.reflect.Modifier; @@ -28,102 +22,43 @@ import java.lang.reflect.Modifier; */ public class BindingsTest extends TestCase { - private static <T> void checkConstantField( - Field field, Class<T> expectedClass, T value) throws IllegalAccessException { + private static void checkConstantField(Field field, Class<?> expectedClass) { assertEquals(expectedClass, field.getType()); assertEquals(Modifier.FINAL, field.getModifiers() & Modifier.FINAL); assertEquals(Modifier.STATIC, field.getModifiers() & Modifier.STATIC); - assertEquals(value, field.get(null)); - } - - private static <T> void checkField(Field field, Class<T> expectedClass, - Object object, T value) throws IllegalArgumentException, IllegalAccessException { - assertEquals(expectedClass, field.getType()); - assertEquals(0, field.getModifiers() & Modifier.FINAL); - assertEquals(0, field.getModifiers() & Modifier.STATIC); - assertEquals(value, field.get(object)); } /** * Testing constants are correctly generated. */ @SmallTest - public void testConstants() throws NoSuchFieldException, SecurityException, - IllegalAccessException { - checkConstantField(SampleServiceConstants.class.getField("TWELVE"), byte.class, (byte) 12); - checkConstantField(InterfaceConstants.class.getField("LONG"), long.class, 4405L); - } - - /** - * Testing enums are correctly generated. - */ - @SmallTest - public void testEnums() throws NoSuchFieldException, SecurityException, - IllegalAccessException { - checkConstantField(Color.class.getField("COLOR_RED"), int.class, 0); - checkConstantField(Color.class.getField("COLOR_BLACK"), int.class, 1); - - checkConstantField(Enum.class.getField("ENUM_VALUE"), int.class, 0); + public void testConstants() throws NoSuchFieldException, SecurityException { + assertEquals(12, SampleServiceConstants.TWELVE); + checkConstantField(SampleServiceConstants.class.getField("TWELVE"), byte.class); - checkConstantField(Shape.class.getField("SHAPE_RECTANGLE"), int.class, 1); - checkConstantField(Shape.class.getField("SHAPE_CIRCLE"), int.class, 2); - checkConstantField(Shape.class.getField("SHAPE_TRIANGLE"), int.class, 3); + assertEquals(4405, InterfaceConstants.LONG); + checkConstantField(InterfaceConstants.class.getField("LONG"), long.class); } /** - * Testing default values on structs. - * - * @throws IllegalAccessException - * @throws IllegalArgumentException + * Testing enums are correctly generated. */ @SmallTest - public void testStructDefaults() throws NoSuchFieldException, SecurityException, - IllegalArgumentException, IllegalAccessException { - // Check default values. - DefaultsTest test = new DefaultsTest(); - - checkField(DefaultsTest.class.getField("a0"), byte.class, test, (byte) -12); - checkField(DefaultsTest.class.getField("a1"), byte.class, test, (byte) 12); - checkField(DefaultsTest.class.getField("a2"), short.class, test, (short) 1234); - checkField(DefaultsTest.class.getField("a3"), short.class, test, (short) 34567); - checkField(DefaultsTest.class.getField("a4"), int.class, test, 123456); - checkField(DefaultsTest.class.getField("a6"), long.class, test, 111111111111L); - checkField(DefaultsTest.class.getField("a8"), int.class, test, 0x12345); - checkField(DefaultsTest.class.getField("a9"), int.class, test, -0x12345); - checkField(DefaultsTest.class.getField("a10"), int.class, test, 1234); - checkField(DefaultsTest.class.getField("a11"), boolean.class, test, true); - checkField(DefaultsTest.class.getField("a12"), boolean.class, test, false); - checkField(DefaultsTest.class.getField("a13"), float.class, test, (float) 123.25); - checkField(DefaultsTest.class.getField("a14"), double.class, test, 1234567890.123); - checkField(DefaultsTest.class.getField("a15"), double.class, test, 1E10); - checkField(DefaultsTest.class.getField("a16"), double.class, test, -1.2E+20); - checkField(DefaultsTest.class.getField("a17"), double.class, test, +1.23E-20); - checkField(DefaultsTest.class.getField("a18"), byte[].class, test, null); - checkField(DefaultsTest.class.getField("a19"), String.class, test, null); - checkField(DefaultsTest.class.getField("a20"), int.class, test, Bar.Type.TYPE_BOTH); - checkField(DefaultsTest.class.getField("a21"), Point.class, test, null); - - assertNotNull(test.a22); - checkField(DefaultsTest.class.getField("a22"), Thing.class, test, test.a22); + public void testEnums() throws NoSuchFieldException, SecurityException { + assertEquals(0, Color.COLOR_RED); + assertEquals(1, Color.COLOR_BLACK); + checkConstantField(Color.class.getField("COLOR_BLACK"), int.class); + checkConstantField(Color.class.getField("COLOR_RED"), int.class); + + assertEquals(0, Enum.ENUM_VALUE); + checkConstantField(Enum.class.getField("ENUM_VALUE"), int.class); + + assertEquals(1, Shape.SHAPE_RECTANGLE); + assertEquals(2, Shape.SHAPE_CIRCLE); + assertEquals(3, Shape.SHAPE_TRIANGLE); + checkConstantField(Shape.class.getField("SHAPE_RECTANGLE"), int.class); + checkConstantField(Shape.class.getField("SHAPE_CIRCLE"), int.class); + checkConstantField(Shape.class.getField("SHAPE_TRIANGLE"), int.class); } - /** - * Testing generation of the Foo class. - * - * @throws IllegalAccessException - */ - @SmallTest - public void testFooGeneration() throws NoSuchFieldException, SecurityException, - IllegalAccessException { - // Checking Foo constants. - checkConstantField(Foo.class.getField("FOOBY"), String.class, "Fooby"); - - // Checking Foo default values. - Foo foo = new Foo(); - checkField(Foo.class.getField("name"), String.class, foo, Foo.FOOBY); - - assertNotNull(foo.source); - assertFalse(foo.source.isValid()); - checkField(Foo.class.getField("source"), MessagePipeHandle.class, foo, foo.source); - } } diff --git a/mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java b/mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java index 928c4ef..0e4d4d7 100644 --- a/mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java +++ b/mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java @@ -493,7 +493,7 @@ public class CoreImplTest extends MojoTestCase { @SmallTest public void testInvalidHandle() { Core core = CoreImpl.getInstance(); - Handle handle = InvalidHandle.INSTANCE; + Handle handle = new InvalidHandle(); // Checking wait. boolean exception = false; @@ -713,7 +713,7 @@ public class CoreImplTest extends MojoTestCase { assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); assertEquals(null, asyncWaiterResult.getException()); - core.getDefaultAsyncWaiter().asyncWait(InvalidHandle.INSTANCE, Core.WaitFlags.READABLE, + core.getDefaultAsyncWaiter().asyncWait(new InvalidHandle(), Core.WaitFlags.READABLE, Core.DEADLINE_INFINITE, asyncWaiterResult); assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); assertEquals(null, asyncWaiterResult.getException()); |