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

Unified Diff: mojo/python/tests/bindings_serialization_deserialization_unittest.py

Issue 570563002: mojo: Starting serialization for python bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Follow review Created 6 years, 3 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 | « mojo/public/tools/bindings/generators/python_templates/module.py.tmpl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « mojo/public/tools/bindings/generators/python_templates/module.py.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698