Index: mojo/python/tests/bindings_serialization_deserialization_unittest.py |
diff --git a/mojo/python/tests/bindings_serialization_deserialization_unittest.py b/mojo/python/tests/bindings_serialization_deserialization_unittest.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..da24645447bb119920370591b466d097e5e6ba2d |
--- /dev/null |
+++ b/mojo/python/tests/bindings_serialization_deserialization_unittest.py |
@@ -0,0 +1,52 @@ |
+# 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. |
+ |
+import unittest |
+ |
+# pylint: disable=F0401 |
+import mojo.system |
+ |
+# Generated files |
+# pylint: disable=F0401 |
+import sample_service_mojom |
+ |
+ |
+def _NewHandle(): |
+ return mojo.system.MessagePipe().handle0 |
+ |
+def _NewFoo(): |
+ foo_instance = sample_service_mojom.Foo() |
+ foo_instance.name = "Foo.name" |
+ foo_instance.x = 23 |
+ foo_instance.y = -23 |
+ foo_instance.a = False |
+ foo_instance.b = True |
+ foo_instance.c = True |
+ foo_instance.bar = sample_service_mojom.Bar() |
+ foo_instance.extra_bars = [ |
+ sample_service_mojom.Bar(), |
+ sample_service_mojom.Bar() |
+ ] |
+ foo_instance.data = 'Hello world' |
+ foo_instance.source = _NewHandle() |
+ foo_instance.input_streams = [ _NewHandle() ] |
+ foo_instance.output_streams = [ _NewHandle(), _NewHandle() ] |
+ foo_instance.array_of_array_of_bools = [ [ True, False ], [] ] |
+ foo_instance.multi_array_of_strings = [ |
+ [ |
+ [ "1", "2" ], |
+ [], |
+ [ "3", "4" ], |
+ ], |
+ [], |
+ ] |
+ foo_instance.array_of_bools = [ True, 0, 1, 2, 0 ] |
+ return foo_instance |
+ |
+class SerializationDeserializationTest(unittest.TestCase): |
+ |
+ def testFooSerialization(self): |
+ (data, _) = _NewFoo().Serialize() |
+ self.assertTrue(len(data)) |
+ self.assertEquals(len(data) % 8, 0) |