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 c85be679dcd1b661b5832ffd062f3bb9348c3b5d..5154a38293b64c9fc6a9d8c00aef0b5c6ef0b01e 100644 |
--- a/mojo/public/java/src/org/chromium/mojo/system/InvalidHandle.java |
+++ b/mojo/android/javatests/src/org/chromium/mojo/HandleMock.java |
@@ -2,21 +2,26 @@ |
// 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 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() |
@@ -30,8 +35,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; |
} |
/** |
@@ -39,7 +45,7 @@ public class InvalidHandle implements UntypedHandle, MessagePipeHandle, Consumer |
*/ |
@Override |
public boolean isValid() { |
- return false; |
+ return true; |
} |
/** |
@@ -51,135 +57,146 @@ public class InvalidHandle implements UntypedHandle, MessagePipeHandle, Consumer |
} |
/** |
- * @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. |
} |
} |