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

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

Issue 2719913002: bindings: Add idl_types.IdlRecordType. (Closed)
Patch Set: Add some tests to idl_types_test Created 3 years, 10 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 | « third_party/WebKit/Source/bindings/scripts/idl_types.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b21f00b77873eb6eca8828c5e1a878f4e1fe5283..931c465461a159b0a8571fa7abab0b4ec603f990 100644
--- a/third_party/WebKit/Source/bindings/scripts/idl_types_test.py
+++ b/third_party/WebKit/Source/bindings/scripts/idl_types_test.py
@@ -8,6 +8,8 @@
import unittest
+from idl_types import IdlRecordType
+from idl_types import IdlSequenceType
from idl_types import IdlType
@@ -18,3 +20,59 @@ class IdlTypeTest(unittest.TestCase):
self.assertTrue(idl_type.is_void)
idl_type = IdlType('somethingElse')
self.assertFalse(idl_type.is_void)
+
+
+class IdlRecordTypeTest(unittest.TestCase):
+
+ def test_idl_types(self):
+ idl_type = IdlRecordType(IdlType('USVString'), IdlType('long'))
+ idl_types = list(idl_type.idl_types())
+ self.assertEqual(len(idl_types), 3)
+ self.assertIs(idl_types[0], idl_type)
+ self.assertEqual(idl_types[1].name, 'USVString')
+ self.assertEqual(idl_types[2].name, 'Long')
+ self.assertListEqual(list(idl_type.idl_types()),
+ [idl_type, idl_type.key_type, idl_type.value_type])
+
+ idl_type = IdlRecordType(IdlType('DOMString'), IdlSequenceType(IdlType('unrestricted float')))
+ idl_types = list(idl_type.idl_types())
+ self.assertEqual(len(idl_types), 4)
+ self.assertIs(idl_types[0], idl_type)
+ self.assertEqual(idl_types[1].name, 'String')
+ self.assertEqual(idl_types[2].name, 'UnrestrictedFloatSequence')
+ self.assertEqual(idl_types[3].name, 'UnrestrictedFloat')
+ self.assertListEqual(list(idl_type.idl_types()),
+ [idl_type, idl_type.key_type, idl_type.value_type, idl_type.value_type.element_type])
+
+ idl_type = IdlRecordType(IdlType('ByteString'),
+ IdlRecordType(IdlType('DOMString'), IdlType('octet')))
+ idl_types = list(idl_type.idl_types())
+ self.assertEqual(len(idl_types), 5)
+ self.assertIs(idl_types[0], idl_type)
+ self.assertEqual(idl_types[1].name, 'ByteString')
+ self.assertEqual(idl_types[2].name, 'StringOctetRecord')
+ self.assertEqual(idl_types[3].name, 'String')
+ self.assertEqual(idl_types[4].name, 'Octet')
+ self.assertListEqual(list(idl_type.idl_types()),
+ [idl_type, idl_type.key_type, idl_type.value_type, idl_type.value_type.key_type,
+ idl_type.value_type.value_type])
+
+ def test_is_record(self):
+ idl_type = IdlType('USVString')
+ self.assertFalse(idl_type.is_record_type)
+ idl_type = IdlSequenceType(IdlRecordType(IdlType('DOMString'), IdlType('byte')))
+ self.assertFalse(idl_type.is_record_type)
+ idl_type = IdlRecordType(IdlType('USVString'), IdlType('long'))
+ self.assertTrue(idl_type.is_record_type)
+ idl_type = IdlRecordType(IdlType('USVString'), IdlSequenceType(IdlType('boolean')))
+ self.assertTrue(idl_type.is_record_type)
+
+ def test_name(self):
+ idl_type = IdlRecordType(IdlType('ByteString'), IdlType('octet'))
+ self.assertEqual(idl_type.name, 'ByteStringOctetRecord')
+ idl_type = IdlRecordType(IdlType('USVString'), IdlSequenceType(IdlType('double')))
+ self.assertEqual(idl_type.name, 'USVStringDoubleSequenceRecord')
+ idl_type = IdlRecordType(IdlType('DOMString'),
+ IdlRecordType(IdlType('ByteString'),
+ IdlSequenceType(IdlType('unsigned short'))))
+ self.assertEqual(idl_type.name, 'StringByteStringUnsignedShortSequenceRecordRecord')
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/idl_types.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698