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

Unified Diff: third_party/WebKit/Source/bindings/scripts/idl_types_test.py

Issue 2749253002: bindings: Expand typedefs before generating union files. (Closed)
Patch Set: Created 3 years, 9 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
Index: third_party/WebKit/Source/bindings/scripts/idl_types_test.py
diff --git a/third_party/WebKit/Source/bindings/scripts/idl_types_test.py b/third_party/WebKit/Source/bindings/scripts/idl_types_test.py
index c92fb42fd915363358571764fa516f780afddaee..e360d5a89e39784df9d55b609c123bfc059f693f 100644
--- a/third_party/WebKit/Source/bindings/scripts/idl_types_test.py
+++ b/third_party/WebKit/Source/bindings/scripts/idl_types_test.py
@@ -136,3 +136,39 @@ class IdlUnionTypeTest(unittest.TestCase):
set([IdlType('Node'), IdlSequenceType(IdlType('long')), IdlType('Event'),
IdlType('XMLHttpRequest'), IdlType('DOMString'),
IdlSequenceType(IdlUnionType([IdlSequenceType(IdlType('double')), IdlType('NodeList')]))]))
+
+ def test_resolve_typedefs(self):
+ # This is a simplification of the typedef mechanism to avoid having to
+ # use idl_definitions and use actual nodes from //tools/idl_parser.
+ typedefs = {
+ 'Foo': IdlType('unsigned short'),
+ 'MyBooleanType': IdlType('boolean'),
+ 'SomeInterfaceT': IdlType('MyInterface'),
+ }
+
+ # (long long or MyBooleanType)
+ union = IdlUnionType([IdlType('long long'), IdlType('MyBooleanType')]).resolve_typedefs(typedefs)
+ self.assertEqual(union.name, 'LongLongOrBoolean')
+ self.assertEqual(union.member_types[0].name, 'LongLong')
+ self.assertEqual(union.member_types[1].name, 'Boolean')
+
+ # (Foo or SomeInterfaceT)
+ union = IdlUnionType([IdlType('Foo'), IdlType('SomeInterfaceT')]).resolve_typedefs(typedefs)
+ self.assertEqual(union.name, 'UnsignedShortOrMyInterface')
+ self.assertEqual(union.member_types[0].name, 'UnsignedShort')
+ self.assertEqual(union.member_types[1].name, 'MyInterface')
+
+ # (Foo or sequence<(MyBooleanType or double)>)
+ union = IdlUnionType([
+ IdlType('Foo'),
+ IdlSequenceType(IdlUnionType([IdlType('MyBooleanType'),
+ IdlType('double')]))]).resolve_typedefs(typedefs)
+ self.assertEqual(union.name, 'UnsignedShortOrBooleanOrDoubleSequence')
+ self.assertEqual(union.member_types[0].name, 'UnsignedShort')
+ self.assertEqual(union.member_types[1].name, 'BooleanOrDoubleSequence')
+ self.assertEqual(union.member_types[1].element_type.name, 'BooleanOrDouble')
+ self.assertEqual(union.member_types[1].element_type.member_types[0].name,
+ 'Boolean')
+ self.assertEqual(union.member_types[1].element_type.member_types[1].name,
+ 'Double')
+ self.assertEqual(2, len(union.flattened_member_types))

Powered by Google App Engine
This is Rietveld 408576698