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

Side by Side Diff: mojo/python/tests/bindings_unions_unittest.py

Issue 1413033011: Fix bug whereby booleans in unions could not be serialized in python. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_python_generator.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import struct 5 import struct
6 import unittest 6 import unittest
7 7
8 # Generated files 8 # Generated files
9 # pylint: disable=F0401 9 # pylint: disable=F0401
10 import test_unions_mojom 10 import test_unions_mojom
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 context = serialization.RootDeserializationContext(data, handles) 94 context = serialization.RootDeserializationContext(data, handles)
95 decoded = test_unions_mojom.ObjectUnion.Deserialize(context) 95 decoded = test_unions_mojom.ObjectUnion.Deserialize(context)
96 96
97 self.assertEquals(u, decoded) 97 self.assertEquals(u, decoded)
98 98
99 def testNonNullableNullObjectInUnionSerialization(self): 99 def testNonNullableNullObjectInUnionSerialization(self):
100 u = test_unions_mojom.ObjectUnion(f_dummy=None) 100 u = test_unions_mojom.ObjectUnion(f_dummy=None)
101 with self.assertRaises(serialization.SerializationException): 101 with self.assertRaises(serialization.SerializationException):
102 u.Serialize() 102 u.Serialize()
103 103
104 def testBoolInUnionSerialization(self):
105 u = test_unions_mojom.PodUnion(f_bool=True)
106 data, handles = u.Serialize()
107
108 context = serialization.RootDeserializationContext(data, handles)
109 decoded = test_unions_mojom.PodUnion.Deserialize(context)
110
111 self.assertEquals(u, decoded)
112
104 def testArrayInUnionSerialization(self): 113 def testArrayInUnionSerialization(self):
105 u = test_unions_mojom.ObjectUnion( 114 u = test_unions_mojom.ObjectUnion(
106 f_array_int8=[1, 2, 3, 4, 5]) 115 f_array_int8=[1, 2, 3, 4, 5])
107 (data, handles) = u.Serialize() 116 (data, handles) = u.Serialize()
108 context = serialization.RootDeserializationContext(data, handles) 117 context = serialization.RootDeserializationContext(data, handles)
109 decoded = test_unions_mojom.ObjectUnion.Deserialize(context) 118 decoded = test_unions_mojom.ObjectUnion.Deserialize(context)
110 119
111 self.assertEquals(u, decoded) 120 self.assertEquals(u, decoded)
112 121
113 def testMapInUnionSerialization(self): 122 def testMapInUnionSerialization(self):
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 'f_uint32': test_unions_mojom.PodUnion(f_uint32=32), 188 'f_uint32': test_unions_mojom.PodUnion(f_uint32=32),
180 'f_uint16': test_unions_mojom.PodUnion(f_uint16=16), 189 'f_uint16': test_unions_mojom.PodUnion(f_uint16=16),
181 'f_uint64': test_unions_mojom.PodUnion(f_uint64=64), 190 'f_uint64': test_unions_mojom.PodUnion(f_uint64=64),
182 } 191 }
183 (data, handles) = s.Serialize() 192 (data, handles) = s.Serialize()
184 193
185 context = serialization.RootDeserializationContext(data, handles) 194 context = serialization.RootDeserializationContext(data, handles)
186 decoded = test_unions_mojom.SmallStruct.Deserialize(context) 195 decoded = test_unions_mojom.SmallStruct.Deserialize(context)
187 196
188 self.assertEquals(s, decoded) 197 self.assertEquals(s, decoded)
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generators/mojom_python_generator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698