diff options
author | qsr <qsr@chromium.org> | 2014-09-02 11:26:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-02 18:36:43 +0000 |
commit | bf2cd357fc230d28ccb9708097cc8a16aebe3e71 (patch) | |
tree | 94d2a498b133d82d1a536c5594e79961d9053591 /mojo | |
parent | 08735d6ab39e788d287dc538f268f3c65d9c97c8 (diff) | |
download | chromium_src-bf2cd357fc230d28ccb9708097cc8a16aebe3e71.zip chromium_src-bf2cd357fc230d28ccb9708097cc8a16aebe3e71.tar.gz chromium_src-bf2cd357fc230d28ccb9708097cc8a16aebe3e71.tar.bz2 |
mojo: Update python API
Update python API to use mixed case identifier for method to conform to
the chromium python style guide.
R=pkl@chromium.org
Review URL: https://codereview.chromium.org/522483006
Cr-Commit-Position: refs/heads/master@{#292961}
Diffstat (limited to 'mojo')
-rw-r--r-- | mojo/public/python/mojo/system.pyx | 66 | ||||
-rw-r--r-- | mojo/python/system/mojo/embedder.pyx | 4 | ||||
-rw-r--r-- | mojo/python/tests/system_unittest.py | 212 |
3 files changed, 141 insertions, 141 deletions
diff --git a/mojo/public/python/mojo/system.pyx b/mojo/public/python/mojo/system.pyx index 80b8dd3..bd03550 100644 --- a/mojo/public/python/mojo/system.pyx +++ b/mojo/public/python/mojo/system.pyx @@ -15,7 +15,7 @@ from cpython.buffer cimport PyObject_GetBuffer from cpython.mem cimport PyMem_Malloc, PyMem_Free from libc.stdint cimport int32_t, int64_t, uint32_t, uint64_t, uintptr_t -def set_system_thunks(system_thunks_as_object): +def SetSystemThunks(system_thunks_as_object): """Bind the basic Mojo Core functions. This should only be used by the embedder. @@ -58,7 +58,7 @@ READ_DATA_FLAG_DISCARD = c_core.MOJO_READ_DATA_FLAG_DISCARD READ_DATA_FLAG_QUERY = c_core.MOJO_READ_DATA_FLAG_QUERY MAP_BUFFER_FLAG_NONE = c_core.MOJO_MAP_BUFFER_FLAG_NONE -def get_time_ticks_now(): +def GetTimeTicksNow(): """Monotonically increasing tick count representing "right now." See mojo/public/c/system/functions.h @@ -95,7 +95,7 @@ cdef class _ScopedBuffer: if self.buf: PyBuffer_Release(&self._buf) -def _slice_buffer(buffer, size): +def _SliceBuffer(buffer, size): """Slice the given buffer, reducing it to the given size. Return None if None is passed in. @@ -124,7 +124,7 @@ cdef class _NativeMemoryView(object): self._read_only = True self._wrapped = False - cdef wrap(self, + cdef Wrap(self, const void* memory, uint32_t size, read_only=True): @@ -183,7 +183,7 @@ class MojoException(Exception): def __init__(self, mojo_result): self.mojo_result = mojo_result -def wait_many(handles_and_signals, deadline): +def WaitMany(handles_and_signals, deadline): """Waits on a list of handles. Args: @@ -227,7 +227,7 @@ cdef class DataPipeTwoPhaseBuffer(object): self._handle = handle self._read = read - def end(self, num_bytes): + def End(self, num_bytes): self._buffer = None cdef c_core.MojoResult result if self._read: @@ -260,7 +260,7 @@ cdef class MappedBuffer(object): self._handle = handle self._cleanup = cleanup - def unmap(self): + def UnMap(self): self._buffer = None cdef c_core.MojoResult result = self._cleanup() self._cleanup = None @@ -273,7 +273,7 @@ cdef class MappedBuffer(object): def __dealloc__(self): if self._buffer: - self.unmap() + self.UnMap() cdef class Handle(object): """A mojo object.""" @@ -283,7 +283,7 @@ cdef class Handle(object): def __init__(self, mojo_handle=c_core.MOJO_HANDLE_INVALID): self._mojo_handle = mojo_handle - def _invalidate(self): + def _Invalidate(self): """Invalidate the current handle. The close operation is not called. It is the responsability of the caller to @@ -291,25 +291,25 @@ cdef class Handle(object): """ self._mojo_handle = c_core.MOJO_HANDLE_INVALID - def is_valid(self): + def IsValid(self): """Returns whether this handle is valid.""" return self._mojo_handle != c_core.MOJO_HANDLE_INVALID - def close(self): + def Close(self): """Closes this handle. See mojo/public/c/system/functions.h """ cdef c_core.MojoResult result = c_core.MOJO_RESULT_OK - if self.is_valid(): + if self.IsValid(): result = c_core.MojoClose(self._mojo_handle) - self._invalidate() + self._Invalidate() return result def __dealloc__(self): - self.close() + self.Close() - def wait(self, signals, deadline): + def Wait(self, signals, deadline): """Waits on the given handle. See mojo/public/c/system/functions.h @@ -322,7 +322,7 @@ cdef class Handle(object): result = c_core.MojoWait(handle, csignals, cdeadline) return result - def write_message(self, + def WriteMessage(self, buffer=None, handles=None, flags=WRITE_MESSAGE_FLAG_NONE): @@ -353,10 +353,10 @@ cdef class Handle(object): if res == c_core.MOJO_RESULT_OK and handles: # Handles have been transferred. Let's invalidate those. for handle in handles: - handle._invalidate() + handle._Invalidate() return res - def read_message(self, + def ReadMessage(self, buffer=None, max_number_of_handles=0, flags=READ_MESSAGE_FLAG_NONE): @@ -398,11 +398,11 @@ cdef class Handle(object): returned_handles = [Handle(input_handles[i]) for i in xrange(input_handles_length)] return (res, - (_slice_buffer(buffer, input_buffer_length), returned_handles), + (_SliceBuffer(buffer, input_buffer_length), returned_handles), None) return (res, None, None) - def write_data(self, buffer=None, flags=WRITE_DATA_FLAG_NONE): + def WriteData(self, buffer=None, flags=WRITE_DATA_FLAG_NONE): """ Writes the given data to the data pipe producer. @@ -425,7 +425,7 @@ cdef class Handle(object): return (res, input_buffer_length) return (res, None) - def begin_write_data(self, + def BeginWriteData(self, min_size=None, flags=WRITE_DATA_FLAG_NONE): """ @@ -453,10 +453,10 @@ cdef class Handle(object): if res != c_core.MOJO_RESULT_OK: return (res, None) cdef _NativeMemoryView view_buffer = _NativeMemoryView(self) - view_buffer.wrap(out_buffer, out_size, read_only=False) + view_buffer.Wrap(out_buffer, out_size, read_only=False) return (res, DataPipeTwoPhaseBuffer(self, memoryview(view_buffer), False)) - def read_data(self, buffer=None, flags=READ_DATA_FLAG_NONE): + def ReadData(self, buffer=None, flags=READ_DATA_FLAG_NONE): """Reads data from the data pipe consumer. This method can only be used on a consumer handle obtained from @@ -476,10 +476,10 @@ cdef class Handle(object): &input_buffer_length, flags) if res == c_core.MOJO_RESULT_OK: - return (res, _slice_buffer(buffer, input_buffer_length)) + return (res, _SliceBuffer(buffer, input_buffer_length)) return (res, None) - def query_data(self, flags=READ_DATA_FLAG_NONE): + def QueryData(self, flags=READ_DATA_FLAG_NONE): """Queries the amount of data available on the data pipe consumer. This method can only be used on a consumer handle obtained from @@ -500,7 +500,7 @@ cdef class Handle(object): flags|c_core.MOJO_READ_DATA_FLAG_QUERY) return (res, num_bytes) - def begin_read_data(self, min_size=None, flags=READ_DATA_FLAG_NONE): + def BeginReadData(self, min_size=None, flags=READ_DATA_FLAG_NONE): """ Begins a two-phase read to the data pipe consumer. @@ -526,14 +526,14 @@ cdef class Handle(object): if res != c_core.MOJO_RESULT_OK: return (res, None) cdef _NativeMemoryView view_buffer = _NativeMemoryView(self) - view_buffer.wrap(out_buffer, out_size, read_only=True) + view_buffer.Wrap(out_buffer, out_size, read_only=True) return (res, DataPipeTwoPhaseBuffer(self, memoryview(view_buffer), True)) - def duplicate(self, options=None): + def Duplicate(self, options=None): """Duplicate the shared buffer handle. This method can only be used on a handle obtained from - |create_shared_buffer()| or |duplicate()|. + |CreateSharedBuffer()| or |Duplicate()|. See mojo/public/c/system/buffer.h """ @@ -551,11 +551,11 @@ cdef class Handle(object): raise MojoException(result) return new_handle - def map(self, offset, num_bytes, flags=MAP_BUFFER_FLAG_NONE): + def Map(self, offset, num_bytes, flags=MAP_BUFFER_FLAG_NONE): """Maps the part (at offset |offset| of length |num_bytes|) of the buffer. This method can only be used on a handle obtained from - |create_shared_buffer()| or |duplicate()|. + |CreateSharedBuffer()| or |Duplicate()|. This method returns a tuple (code, mapped_buffer). - If code is RESULT_OK, mapped_buffer is a readable/writable @@ -573,7 +573,7 @@ cdef class Handle(object): if res != c_core.MOJO_RESULT_OK: return (res, None) cdef _NativeMemoryView view_buffer = _NativeMemoryView(self) - view_buffer.wrap(buffer, num_bytes, read_only=False) + view_buffer.Wrap(buffer, num_bytes, read_only=False) return (res, MappedBuffer(self, memoryview(view_buffer), lambda: c_core.MojoUnmapBuffer(buffer))) @@ -665,7 +665,7 @@ class CreateSharedBufferOptions(object): def __init__(self): self.flags = CreateSharedBufferOptions.FLAG_NONE -def create_shared_buffer(num_bytes, options=None): +def CreateSharedBuffer(num_bytes, options=None): """Creates a buffer of size |num_bytes| bytes that can be shared. See mojo/public/c/system/buffer.h diff --git a/mojo/python/system/mojo/embedder.pyx b/mojo/python/system/mojo/embedder.pyx index c7021f0..06ac22f 100644 --- a/mojo/python/system/mojo/embedder.pyx +++ b/mojo/python/system/mojo/embedder.pyx @@ -34,8 +34,8 @@ cdef extern from "mojo/public/platform/native/system_thunks.h" nogil: pass cdef MojoSystemThunks MojoMakeSystemThunks() -def init(): +def Init(): InitCEmbedder(scoped_ptr[PlatformSupport]( new SimplePlatformSupport())) cdef MojoSystemThunks thunks = MojoMakeSystemThunks() - system.set_system_thunks(<uintptr_t>(&thunks)) + system.SetSystemThunks(<uintptr_t>(&thunks)) diff --git a/mojo/python/tests/system_unittest.py b/mojo/python/tests/system_unittest.py index 46dde47..2f0e36a 100644 --- a/mojo/python/tests/system_unittest.py +++ b/mojo/python/tests/system_unittest.py @@ -8,13 +8,13 @@ import time import unittest # pylint: disable=F0401 -from mojo.embedder import init as init_embedder +import mojo.embedder from mojo import system DATA_SIZE = 1024 -def get_random_buffer(size): +def _GetRandomBuffer(size): random.seed(size) return bytearray(''.join(chr(random.randint(0, 255)) for i in xrange(size))) @@ -22,12 +22,12 @@ def get_random_buffer(size): class BaseMojoTest(unittest.TestCase): def setUp(self): - init_embedder() + mojo.embedder.Init() class CoreTest(BaseMojoTest): - def test_results(self): + def testResults(self): self.assertEquals(system.RESULT_OK, 0) self.assertLess(system.RESULT_CANCELLED, 0) self.assertLess(system.RESULT_UNKNOWN, 0) @@ -47,7 +47,7 @@ class CoreTest(BaseMojoTest): self.assertLess(system.RESULT_BUSY, 0) self.assertLess(system.RESULT_SHOULD_WAIT, 0) - def test_constants(self): + def testConstants(self): self.assertGreaterEqual(system.DEADLINE_INDEFINITE, 0) self.assertGreaterEqual(system.HANDLE_SIGNAL_NONE, 0) self.assertGreaterEqual(system.HANDLE_SIGNAL_READABLE, 0) @@ -63,111 +63,111 @@ class CoreTest(BaseMojoTest): self.assertGreaterEqual(system.READ_DATA_FLAG_QUERY, 0) self.assertGreaterEqual(system.MAP_BUFFER_FLAG_NONE, 0) - def test_get_time_ticks_now(self): + def testGetTimeTicksNow(self): pt1 = time.time() - v1 = system.get_time_ticks_now() + v1 = system.GetTimeTicksNow() time.sleep(1e-3) - v2 = system.get_time_ticks_now() + v2 = system.GetTimeTicksNow() pt2 = time.time() self.assertGreater(v1, 0) self.assertGreater(v2, v1 + 1000) self.assertGreater(1e6 * (pt2 - pt1), v2 - v1) - def _test_handles_creation(self, *args): + def _testHandlesCreation(self, *args): for handle in args: - self.assertTrue(handle.is_valid()) - handle.close() - self.assertFalse(handle.is_valid()) + self.assertTrue(handle.IsValid()) + handle.Close() + self.assertFalse(handle.IsValid()) - def _test_message_handle_creation(self, handles): - self._test_handles_creation(handles.handle0, handles.handle1) + def _TestMessageHandleCreation(self, handles): + self._testHandlesCreation(handles.handle0, handles.handle1) - def test_create_message_pipe(self): - self._test_message_handle_creation(system.MessagePipe()) + def testCreateMessagePipe(self): + self._TestMessageHandleCreation(system.MessagePipe()) - def test_create_message_pipe_with_none_options(self): - self._test_message_handle_creation(system.MessagePipe(None)) + def testCreateMessagePipeWithNoneOptions(self): + self._TestMessageHandleCreation(system.MessagePipe(None)) - def test_create_message_pipe_with_options(self): - self._test_message_handle_creation( + def testCreateMessagePipeWithOptions(self): + self._TestMessageHandleCreation( system.MessagePipe(system.CreateMessagePipeOptions())) - def test_wait_over_message_pipe(self): + def testWaitOverMessagePipe(self): handles = system.MessagePipe() handle = handles.handle0 - self.assertEquals(system.RESULT_OK, handle.wait( + self.assertEquals(system.RESULT_OK, handle.Wait( system.HANDLE_SIGNAL_WRITABLE, system.DEADLINE_INDEFINITE)) self.assertEquals(system.RESULT_DEADLINE_EXCEEDED, - handle.wait(system.HANDLE_SIGNAL_READABLE, 0)) + handle.Wait(system.HANDLE_SIGNAL_READABLE, 0)) - handles.handle1.write_message() + handles.handle1.WriteMessage() self.assertEquals( system.RESULT_OK, - handle.wait( + handle.Wait( system.HANDLE_SIGNAL_READABLE, system.DEADLINE_INDEFINITE)) - def test_wait_over_many_message_pipe(self): + def testWaitOverManyMessagePipe(self): handles = system.MessagePipe() handle0 = handles.handle0 handle1 = handles.handle1 self.assertEquals( 0, - system.wait_many( + system.WaitMany( [(handle0, system.HANDLE_SIGNAL_WRITABLE), (handle1, system.HANDLE_SIGNAL_WRITABLE)], system.DEADLINE_INDEFINITE)) self.assertEquals( system.RESULT_DEADLINE_EXCEEDED, - system.wait_many( + system.WaitMany( [(handle0, system.HANDLE_SIGNAL_READABLE), (handle1, system.HANDLE_SIGNAL_READABLE)], 0)) - handle0.write_message() + handle0.WriteMessage() self.assertEquals( 1, - system.wait_many( + system.WaitMany( [(handle0, system.HANDLE_SIGNAL_READABLE), (handle1, system.HANDLE_SIGNAL_READABLE)], system.DEADLINE_INDEFINITE)) - def test_send_bytes_over_message_pipe(self): + def testSendBytesOverMessagePipe(self): handles = system.MessagePipe() - data = get_random_buffer(DATA_SIZE) - handles.handle0.write_message(data) - (res, buffers, next_message) = handles.handle1.read_message() + data = _GetRandomBuffer(DATA_SIZE) + handles.handle0.WriteMessage(data) + (res, buffers, next_message) = handles.handle1.ReadMessage() self.assertEquals(system.RESULT_RESOURCE_EXHAUSTED, res) self.assertEquals(None, buffers) self.assertEquals((DATA_SIZE, 0), next_message) result = bytearray(DATA_SIZE) - (res, buffers, next_message) = handles.handle1.read_message(result) + (res, buffers, next_message) = handles.handle1.ReadMessage(result) self.assertEquals(system.RESULT_OK, res) self.assertEquals(None, next_message) self.assertEquals((data, []), buffers) - def test_send_empty_data_over_message_pipe(self): + def testSendEmptyDataOverMessagePipe(self): handles = system.MessagePipe() - handles.handle0.write_message(None) - (res, buffers, next_message) = handles.handle1.read_message() + handles.handle0.WriteMessage(None) + (res, buffers, next_message) = handles.handle1.ReadMessage() self.assertEquals(system.RESULT_OK, res) self.assertEquals(None, next_message) self.assertEquals((None, []), buffers) - def test_send_handle_over_message_pipe(self): + def testSendHandleOverMessagePipe(self): handles = system.MessagePipe() handles_to_send = system.MessagePipe() - handles.handle0.write_message(handles=[handles_to_send.handle0, + handles.handle0.WriteMessage(handles=[handles_to_send.handle0, handles_to_send.handle1]) - (res, buffers, next_message) = handles.handle1.read_message( + (res, buffers, next_message) = handles.handle1.ReadMessage( max_number_of_handles=2) - self.assertFalse(handles_to_send.handle0.is_valid()) - self.assertFalse(handles_to_send.handle1.is_valid()) + self.assertFalse(handles_to_send.handle0.IsValid()) + self.assertFalse(handles_to_send.handle1.IsValid()) self.assertEquals(system.RESULT_OK, res) self.assertEquals(None, next_message) self.assertEquals(None, buffers[0]) @@ -175,121 +175,121 @@ class CoreTest(BaseMojoTest): handles = buffers[1] for handle in handles: - self.assertTrue(handle.is_valid()) - (res, buffers, next_message) = handle.read_message() + self.assertTrue(handle.IsValid()) + (res, buffers, next_message) = handle.ReadMessage() self.assertEquals(system.RESULT_SHOULD_WAIT, res) for handle in handles: - handle.write_message() + handle.WriteMessage() for handle in handles: - (res, buffers, next_message) = handle.read_message() + (res, buffers, next_message) = handle.ReadMessage() self.assertEquals(system.RESULT_OK, res) - def _test_data_handle_creation(self, handles): - self._test_handles_creation( + def _TestDataHandleCreation(self, handles): + self._testHandlesCreation( handles.producer_handle, handles.consumer_handle) - def test_create_data_pipe(self): - self._test_data_handle_creation(system.DataPipe()) + def testCreateDataPipe(self): + self._TestDataHandleCreation(system.DataPipe()) - def test_create_data_pipe_with_none_options(self): - self._test_data_handle_creation(system.DataPipe(None)) + def testCreateDataPipeWithNoneOptions(self): + self._TestDataHandleCreation(system.DataPipe(None)) - def test_create_data_pipe_with_default_options(self): - self._test_data_handle_creation( + def testCreateDataPipeWithDefaultOptions(self): + self._TestDataHandleCreation( system.DataPipe(system.CreateDataPipeOptions())) - def test_create_data_pipe_with_discard_flag(self): + def testCreateDataPipeWithDiscardFlag(self): options = system.CreateDataPipeOptions() options.flags = system.CreateDataPipeOptions.FLAG_MAY_DISCARD - self._test_data_handle_creation(system.DataPipe(options)) + self._TestDataHandleCreation(system.DataPipe(options)) - def test_create_data_pipe_with_element_size(self): + def testCreateDataPipeWithElementSize(self): options = system.CreateDataPipeOptions() options.element_num_bytes = 5 - self._test_data_handle_creation(system.DataPipe(options)) + self._TestDataHandleCreation(system.DataPipe(options)) - def test_create_data_pipe_with_capacity(self): + def testCreateDataPipeWithCapacity(self): options = system.CreateDataPipeOptions() options.element_capacity_num_bytes = DATA_SIZE - self._test_data_handle_creation(system.DataPipe(options)) + self._TestDataHandleCreation(system.DataPipe(options)) - def test_create_data_pipe_with_incorrect_parameters(self): + def testCreateDataPipeWithIncorrectParameters(self): options = system.CreateDataPipeOptions() options.element_num_bytes = 5 options.capacity_num_bytes = DATA_SIZE with self.assertRaises(system.MojoException) as cm: - self._test_data_handle_creation(system.DataPipe(options)) + self._TestDataHandleCreation(system.DataPipe(options)) self.assertEquals(system.RESULT_INVALID_ARGUMENT, cm.exception.mojo_result) - def test_send_empty_data_over_data_pipe(self): + def testSendEmptyDataOverDataPipe(self): pipes = system.DataPipe() - self.assertEquals((system.RESULT_OK, 0), pipes.producer_handle.write_data()) + self.assertEquals((system.RESULT_OK, 0), pipes.producer_handle.WriteData()) self.assertEquals( - (system.RESULT_OK, None), pipes.consumer_handle.read_data()) + (system.RESULT_OK, None), pipes.consumer_handle.ReadData()) - def test_send_data_over_data_pipe(self): + def testSendDataOverDataPipe(self): pipes = system.DataPipe() - data = get_random_buffer(DATA_SIZE) + data = _GetRandomBuffer(DATA_SIZE) self.assertEquals((system.RESULT_OK, DATA_SIZE), - pipes.producer_handle.write_data(data)) + pipes.producer_handle.WriteData(data)) self.assertEquals((system.RESULT_OK, data), - pipes.consumer_handle.read_data(bytearray(DATA_SIZE))) + pipes.consumer_handle.ReadData(bytearray(DATA_SIZE))) - def test_two_phase_write_on_data_pipe(self): + def testTwoPhaseWriteOnDataPipe(self): pipes = system.DataPipe() - (res, buf) = pipes.producer_handle.begin_write_data(DATA_SIZE) + (res, buf) = pipes.producer_handle.BeginWriteData(DATA_SIZE) self.assertEquals(system.RESULT_OK, res) self.assertGreaterEqual(len(buf.buffer), DATA_SIZE) - data = get_random_buffer(DATA_SIZE) + data = _GetRandomBuffer(DATA_SIZE) buf.buffer[0:DATA_SIZE] = data - self.assertEquals(system.RESULT_OK, buf.end(DATA_SIZE)) + self.assertEquals(system.RESULT_OK, buf.End(DATA_SIZE)) self.assertEquals((system.RESULT_OK, data), - pipes.consumer_handle.read_data(bytearray(DATA_SIZE))) + pipes.consumer_handle.ReadData(bytearray(DATA_SIZE))) - def test_two_phase_read_on_data_pipe(self): + def testTwoPhaseReadOnDataPipe(self): pipes = system.DataPipe() - data = get_random_buffer(DATA_SIZE) + data = _GetRandomBuffer(DATA_SIZE) self.assertEquals((system.RESULT_OK, DATA_SIZE), - pipes.producer_handle.write_data(data)) - (res, buf) = pipes.consumer_handle.begin_read_data() + pipes.producer_handle.WriteData(data)) + (res, buf) = pipes.consumer_handle.BeginReadData() self.assertEquals(system.RESULT_OK, res) self.assertEquals(DATA_SIZE, len(buf.buffer)) self.assertEquals(data, buf.buffer) - self.assertEquals(system.RESULT_OK, buf.end(DATA_SIZE)) + self.assertEquals(system.RESULT_OK, buf.End(DATA_SIZE)) - def test_create_shared_buffer(self): - self._test_handles_creation(system.create_shared_buffer(DATA_SIZE)) + def testCreateSharedBuffer(self): + self._testHandlesCreation(system.CreateSharedBuffer(DATA_SIZE)) - def test_create_shared_buffer_with_none_options(self): - self._test_handles_creation(system.create_shared_buffer(DATA_SIZE, None)) + def testCreateSharedBufferWithNoneOptions(self): + self._testHandlesCreation(system.CreateSharedBuffer(DATA_SIZE, None)) - def test_create_shared_buffer_with_default_options(self): - self._test_handles_creation( - system.create_shared_buffer( + def testCreateSharedBufferWithDefaultOptions(self): + self._testHandlesCreation( + system.CreateSharedBuffer( DATA_SIZE, system.CreateSharedBufferOptions())) - def test_duplicate_shared_buffer(self): - handle = system.create_shared_buffer(DATA_SIZE) - self._test_handles_creation(handle.duplicate()) - - def test_duplicate_shared_buffer_with_none_options(self): - handle = system.create_shared_buffer(DATA_SIZE) - self._test_handles_creation(handle.duplicate(None)) - - def test_duplicate_shared_buffer_with_default_options(self): - handle = system.create_shared_buffer(DATA_SIZE) - self._test_handles_creation( - handle.duplicate(system.DuplicateSharedBufferOptions())) - - def test_send_bytes_over_shared_buffer(self): - handle = system.create_shared_buffer(DATA_SIZE) - duplicated = handle.duplicate() - data = get_random_buffer(DATA_SIZE) - (res1, buf1) = handle.map(0, DATA_SIZE) - (res2, buf2) = duplicated.map(0, DATA_SIZE) + def testDuplicateSharedBuffer(self): + handle = system.CreateSharedBuffer(DATA_SIZE) + self._testHandlesCreation(handle.Duplicate()) + + def testDuplicateSharedBufferWithNoneOptions(self): + handle = system.CreateSharedBuffer(DATA_SIZE) + self._testHandlesCreation(handle.Duplicate(None)) + + def testDuplicateSharedBufferWithDefaultOptions(self): + handle = system.CreateSharedBuffer(DATA_SIZE) + self._testHandlesCreation( + handle.Duplicate(system.DuplicateSharedBufferOptions())) + + def testSendBytesOverSharedBuffer(self): + handle = system.CreateSharedBuffer(DATA_SIZE) + duplicated = handle.Duplicate() + data = _GetRandomBuffer(DATA_SIZE) + (res1, buf1) = handle.Map(0, DATA_SIZE) + (res2, buf2) = duplicated.Map(0, DATA_SIZE) self.assertEquals(system.RESULT_OK, res1) self.assertEquals(system.RESULT_OK, res2) self.assertEquals(DATA_SIZE, len(buf1.buffer)) |