OLD | NEW |
(Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import unittest |
| 6 |
| 7 # pylint: disable=F0401 |
| 8 import mojo.system |
| 9 |
| 10 # Generated files |
| 11 # pylint: disable=F0401 |
| 12 import sample_service_mojom |
| 13 |
| 14 |
| 15 def _NewHandle(): |
| 16 return mojo.system.MessagePipe().handle0 |
| 17 |
| 18 def _NewFoo(): |
| 19 foo_instance = sample_service_mojom.Foo() |
| 20 foo_instance.name = "Foo.name" |
| 21 foo_instance.x = 23 |
| 22 foo_instance.y = -23 |
| 23 foo_instance.a = False |
| 24 foo_instance.b = True |
| 25 foo_instance.c = True |
| 26 foo_instance.bar = sample_service_mojom.Bar() |
| 27 foo_instance.extra_bars = [ |
| 28 sample_service_mojom.Bar(), |
| 29 sample_service_mojom.Bar() |
| 30 ] |
| 31 foo_instance.data = 'Hello world' |
| 32 foo_instance.source = _NewHandle() |
| 33 foo_instance.input_streams = [ _NewHandle() ] |
| 34 foo_instance.output_streams = [ _NewHandle(), _NewHandle() ] |
| 35 foo_instance.array_of_array_of_bools = [ [ True, False ], [] ] |
| 36 foo_instance.multi_array_of_strings = [ |
| 37 [ |
| 38 [ "1", "2" ], |
| 39 [], |
| 40 [ "3", "4" ], |
| 41 ], |
| 42 [], |
| 43 ] |
| 44 foo_instance.array_of_bools = [ True, 0, 1, 2, 0 ] |
| 45 return foo_instance |
| 46 |
| 47 class SerializationDeserializationTest(unittest.TestCase): |
| 48 |
| 49 def testFooSerialization(self): |
| 50 (data, _) = _NewFoo().Serialize() |
| 51 self.assertTrue(len(data)) |
| 52 self.assertEquals(len(data) % 8, 0) |
OLD | NEW |