Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Unified Diff: mojo/android/javatests/src/org/chromium/mojo/HandleMock.java

Issue 306893010: Generate java bindings for structs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-upload after revert Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/get_landmines.py ('k') | mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/android/javatests/src/org/chromium/mojo/HandleMock.java
diff --git a/mojo/public/java/src/org/chromium/mojo/system/InvalidHandle.java b/mojo/android/javatests/src/org/chromium/mojo/HandleMock.java
similarity index 62%
copy from mojo/public/java/src/org/chromium/mojo/system/InvalidHandle.java
copy to mojo/android/javatests/src/org/chromium/mojo/HandleMock.java
index 36c516cfe259d79a348fe7d5258a901416ff1f39..82b0f45b6d5223df64737a64d45da2922a7b7077 100644
--- a/mojo/public/java/src/org/chromium/mojo/system/InvalidHandle.java
+++ b/mojo/android/javatests/src/org/chromium/mojo/HandleMock.java
@@ -2,20 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package org.chromium.mojo.system;
+package org.chromium.mojo;
-import org.chromium.mojo.system.Core.WaitFlags;
+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 handle that will always be invalid.
+ * A mock handle, that does nothing.
*/
-public class InvalidHandle implements UntypedHandle, MessagePipeHandle, ConsumerHandle,
- ProducerHandle, SharedBufferHandle {
+public class HandleMock implements UntypedHandle, MessagePipeHandle,
+ ProducerHandle, ConsumerHandle, SharedBufferHandle {
/**
* @see Handle#close()
@@ -29,8 +36,9 @@ public class InvalidHandle implements UntypedHandle, MessagePipeHandle, Consumer
* @see Handle#wait(Core.WaitFlags, long)
*/
@Override
- public int wait(WaitFlags flags, long deadline) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public int wait(Core.WaitFlags flags, long deadline) {
+ // Do nothing.
+ return MojoResult.OK;
}
/**
@@ -38,155 +46,166 @@ public class InvalidHandle implements UntypedHandle, MessagePipeHandle, Consumer
*/
@Override
public boolean isValid() {
- return false;
+ return true;
}
/**
- * @see Handle#getCore()
+ * @see Handle#toUntypedHandle()
*/
@Override
- public Core getCore() {
- return null;
+ public UntypedHandle toUntypedHandle() {
+ return this;
}
/**
- * @see Handle#toUntypedHandle()
+ * @see org.chromium.mojo.system.Handle#getCore()
*/
@Override
- public UntypedHandle toUntypedHandle() {
- return this;
+ public Core getCore() {
+ return CoreImpl.getInstance();
}
/**
- * @see UntypedHandle#toMessagePipeHandle()
+ * @see ConsumerHandle#discardData(int, DataPipe.ReadFlags)
*/
@Override
- public MessagePipeHandle toMessagePipeHandle() {
- return this;
+ public int discardData(int numBytes, DataPipe.ReadFlags flags) {
+ // Do nothing.
+ return 0;
}
/**
- * @see UntypedHandle#toDataPipeConsumerHandle()
+ * @see ConsumerHandle#readData(java.nio.ByteBuffer, DataPipe.ReadFlags)
*/
@Override
- public ConsumerHandle toDataPipeConsumerHandle() {
- return this;
+ public int readData(ByteBuffer elements,
+ DataPipe.ReadFlags flags) {
+ // Do nothing.
+ return 0;
}
/**
- * @see UntypedHandle#toDataPipeProducerHandle()
+ * @see ConsumerHandle#beginReadData(int, DataPipe.ReadFlags)
*/
@Override
- public ProducerHandle toDataPipeProducerHandle() {
- return this;
+ public ByteBuffer beginReadData(int numBytes,
+ DataPipe.ReadFlags flags) {
+ // Do nothing.
+ return null;
}
/**
- * @see UntypedHandle#toSharedBufferHandle()
+ * @see ConsumerHandle#endReadData(int)
*/
@Override
- public SharedBufferHandle toSharedBufferHandle() {
- return this;
+ public void endReadData(int numBytesRead) {
+ // Do nothing.
}
/**
- * @see SharedBufferHandle#duplicate(SharedBufferHandle.DuplicateOptions)
+ * @see ProducerHandle#writeData(java.nio.ByteBuffer, DataPipe.WriteFlags)
*/
@Override
- public SharedBufferHandle duplicate(DuplicateOptions options) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public int writeData(ByteBuffer elements,
+ DataPipe.WriteFlags flags) {
+ // Do nothing.
+ return 0;
}
/**
- * @see SharedBufferHandle#map(long, long, SharedBufferHandle.MapFlags)
+ * @see ProducerHandle#beginWriteData(int, DataPipe.WriteFlags)
*/
@Override
- public ByteBuffer map(long offset, long numBytes, MapFlags flags) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public ByteBuffer beginWriteData(int numBytes,
+ DataPipe.WriteFlags flags) {
+ // Do nothing.
+ return null;
}
/**
- * @see SharedBufferHandle#unmap(java.nio.ByteBuffer)
+ * @see ProducerHandle#endWriteData(int)
*/
@Override
- public void unmap(ByteBuffer buffer) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public void endWriteData(int numBytesWritten) {
+ // Do nothing.
}
/**
- * @see DataPipe.ProducerHandle#writeData(java.nio.ByteBuffer, DataPipe.WriteFlags)
+ * @see MessagePipeHandle#writeMessage(java.nio.ByteBuffer, java.util.List,
+ * MessagePipeHandle.WriteFlags)
*/
@Override
- public int writeData(ByteBuffer elements, DataPipe.WriteFlags flags) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public void writeMessage(ByteBuffer bytes, List<? extends Handle> handles,
+ WriteFlags flags) {
+ // Do nothing.
}
/**
- * @see DataPipe.ProducerHandle#beginWriteData(int, DataPipe.WriteFlags)
+ * @see MessagePipeHandle#readMessage(java.nio.ByteBuffer, int, MessagePipeHandle.ReadFlags)
*/
@Override
- public ByteBuffer beginWriteData(int numBytes,
- DataPipe.WriteFlags flags) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public ReadMessageResult readMessage(ByteBuffer bytes, int maxNumberOfHandles,
+ ReadFlags flags) {
+ // Do nothing.
+ return new ReadMessageResult();
}
/**
- * @see DataPipe.ProducerHandle#endWriteData(int)
+ * @see UntypedHandle#toMessagePipeHandle()
*/
@Override
- public void endWriteData(int numBytesWritten) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public MessagePipeHandle toMessagePipeHandle() {
+ return this;
}
/**
- * @see DataPipe.ConsumerHandle#discardData(int, DataPipe.ReadFlags)
+ * @see UntypedHandle#toDataPipeConsumerHandle()
*/
@Override
- public int discardData(int numBytes, DataPipe.ReadFlags flags) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public ConsumerHandle toDataPipeConsumerHandle() {
+ return this;
}
/**
- * @see DataPipe.ConsumerHandle#readData(java.nio.ByteBuffer, DataPipe.ReadFlags)
+ * @see UntypedHandle#toDataPipeProducerHandle()
*/
@Override
- public int readData(ByteBuffer elements, DataPipe.ReadFlags flags) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public ProducerHandle toDataPipeProducerHandle() {
+ return this;
}
/**
- * @see DataPipe.ConsumerHandle#beginReadData(int, DataPipe.ReadFlags)
+ * @see UntypedHandle#toSharedBufferHandle()
*/
@Override
- public ByteBuffer beginReadData(int numBytes,
- DataPipe.ReadFlags flags) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public SharedBufferHandle toSharedBufferHandle() {
+ return this;
}
/**
- * @see DataPipe.ConsumerHandle#endReadData(int)
+ * @see SharedBufferHandle#duplicate(SharedBufferHandle.DuplicateOptions)
*/
@Override
- public void endReadData(int numBytesRead) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public SharedBufferHandle duplicate(DuplicateOptions options) {
+ // Do nothing.
+ return null;
}
/**
- * @see MessagePipeHandle#writeMessage(java.nio.ByteBuffer, java.util.List,
- * MessagePipeHandle.WriteFlags)
+ * @see SharedBufferHandle#map(long, long, SharedBufferHandle.MapFlags)
*/
@Override
- public void writeMessage(ByteBuffer bytes, List<? extends Handle> handles, WriteFlags flags) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public ByteBuffer map(long offset, long numBytes, MapFlags flags) {
+ // Do nothing.
+ return null;
}
/**
- * @see MessagePipeHandle#readMessage(java.nio.ByteBuffer, int, MessagePipeHandle.ReadFlags)
+ * @see SharedBufferHandle#unmap(java.nio.ByteBuffer)
*/
@Override
- public ReadMessageResult readMessage(ByteBuffer bytes, int maxNumberOfHandles,
- ReadFlags flags) {
- throw new MojoException(MojoResult.INVALID_ARGUMENT);
+ public void unmap(ByteBuffer buffer) {
+ // Do nothing.
}
}
« no previous file with comments | « build/get_landmines.py ('k') | mojo/android/javatests/src/org/chromium/mojo/bindings/BindingsTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698