| Index: build/android/gyp/java_cpp_enum_tests.py
|
| diff --git a/build/android/gyp/java_cpp_enum_tests.py b/build/android/gyp/java_cpp_enum_tests.py
|
| index 44f9766c82c98d6c6bab67764d89ee4bc6640282..70008d11c42fb0b29ed3e01f59432effdf3751cc 100755
|
| --- a/build/android/gyp/java_cpp_enum_tests.py
|
| +++ b/build/android/gyp/java_cpp_enum_tests.py
|
| @@ -28,7 +28,7 @@ class TestPreprocess(unittest.TestCase):
|
| entries=[('E1', 1), ('E2', '2 << 2')])
|
| output = GenerateOutput('path/to/file', definition)
|
| expected = """
|
| -// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2015 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.
|
|
|
| @@ -63,6 +63,34 @@ public class ClassName {
|
| ('VALUE_ONE', 1)]),
|
| definition.entries)
|
|
|
| + def testParseSimpleEnumWithComments(self):
|
| + test_data = """
|
| + // GENERATED_JAVA_ENUM_PACKAGE: test.namespace
|
| + enum EnumName {
|
| + // zero
|
| + VALUE_ZERO,
|
| +
|
| + VALUE_ONE,
|
| +
|
| + // two
|
| + // too
|
| + VALUE_TWO,
|
| + };
|
| + """.split('\n')
|
| + definitions = HeaderParser(test_data).ParseDefinitions()
|
| + self.assertEqual(1, len(definitions))
|
| + definition = definitions[0]
|
| + self.assertEqual('EnumName', definition.class_name)
|
| + self.assertEqual('test.namespace', definition.enum_package)
|
| + self.assertEqual(collections.OrderedDict([('VALUE_ZERO', 0),
|
| + ('VALUE_ONE', 1),
|
| + ('VALUE_TWO', 2)]),
|
| + definition.entries)
|
| + self.assertEqual(collections.OrderedDict([('VALUE_ZERO', [' zero']),
|
| + ('VALUE_ONE', []),
|
| + ('VALUE_TWO', [' two',' too'])]),
|
| + definition.comments)
|
| +
|
| def testParseBitShifts(self):
|
| test_data = """
|
| // GENERATED_JAVA_ENUM_PACKAGE: test.namespace
|
| @@ -310,20 +338,24 @@ public class ClassName {
|
|
|
| def testEnumValueAssignmentNoneDefined(self):
|
| definition = EnumDefinition(original_enum_name='c', enum_package='p')
|
| - definition.AppendEntry('A', None)
|
| - definition.AppendEntry('B', None)
|
| - definition.AppendEntry('C', None)
|
| + definition.AppendEntry('A', None, [' foo'])
|
| + definition.AppendEntry('B', None, [])
|
| + definition.AppendEntry('C', None, [' bar', ' goo'])
|
| definition.Finalize()
|
| self.assertEqual(collections.OrderedDict([('A', 0),
|
| ('B', 1),
|
| ('C', 2)]),
|
| definition.entries)
|
| + self.assertEqual(collections.OrderedDict([('A', [' foo']),
|
| + ('B', []),
|
| + ('C', [' bar', ' goo'])]),
|
| + definition.comments)
|
|
|
| def testEnumValueAssignmentAllDefined(self):
|
| definition = EnumDefinition(original_enum_name='c', enum_package='p')
|
| - definition.AppendEntry('A', '1')
|
| - definition.AppendEntry('B', '2')
|
| - definition.AppendEntry('C', '3')
|
| + definition.AppendEntry('A', '1', [])
|
| + definition.AppendEntry('B', '2', [])
|
| + definition.AppendEntry('C', '3', [])
|
| definition.Finalize()
|
| self.assertEqual(collections.OrderedDict([('A', '1'),
|
| ('B', '2'),
|
| @@ -332,10 +364,10 @@ public class ClassName {
|
|
|
| def testEnumValueAssignmentReferences(self):
|
| definition = EnumDefinition(original_enum_name='c', enum_package='p')
|
| - definition.AppendEntry('A', None)
|
| - definition.AppendEntry('B', 'A')
|
| - definition.AppendEntry('C', None)
|
| - definition.AppendEntry('D', 'C')
|
| + definition.AppendEntry('A', None, [])
|
| + definition.AppendEntry('B', 'A', [])
|
| + definition.AppendEntry('C', None, [])
|
| + definition.AppendEntry('D', 'C', [])
|
| definition.Finalize()
|
| self.assertEqual(collections.OrderedDict([('A', 0),
|
| ('B', 0),
|
| @@ -345,9 +377,9 @@ public class ClassName {
|
|
|
| def testEnumValueAssignmentSet(self):
|
| definition = EnumDefinition(original_enum_name='c', enum_package='p')
|
| - definition.AppendEntry('A', None)
|
| - definition.AppendEntry('B', '2')
|
| - definition.AppendEntry('C', None)
|
| + definition.AppendEntry('A', None, [])
|
| + definition.AppendEntry('B', '2', [])
|
| + definition.AppendEntry('C', None, [])
|
| definition.Finalize()
|
| self.assertEqual(collections.OrderedDict([('A', 0),
|
| ('B', 2),
|
| @@ -356,10 +388,10 @@ public class ClassName {
|
|
|
| def testEnumValueAssignmentSetReferences(self):
|
| definition = EnumDefinition(original_enum_name='c', enum_package='p')
|
| - definition.AppendEntry('A', None)
|
| - definition.AppendEntry('B', 'A')
|
| - definition.AppendEntry('C', 'B')
|
| - definition.AppendEntry('D', None)
|
| + definition.AppendEntry('A', None, [])
|
| + definition.AppendEntry('B', 'A', [])
|
| + definition.AppendEntry('C', 'B', [])
|
| + definition.AppendEntry('D', None, [])
|
| definition.Finalize()
|
| self.assertEqual(collections.OrderedDict([('A', 0),
|
| ('B', 0),
|
| @@ -369,18 +401,18 @@ public class ClassName {
|
|
|
| def testEnumValueAssignmentRaises(self):
|
| definition = EnumDefinition(original_enum_name='c', enum_package='p')
|
| - definition.AppendEntry('A', None)
|
| - definition.AppendEntry('B', 'foo')
|
| - definition.AppendEntry('C', None)
|
| + definition.AppendEntry('A', None, [])
|
| + definition.AppendEntry('B', 'foo', [])
|
| + definition.AppendEntry('C', None, [])
|
| with self.assertRaises(Exception):
|
| definition.Finalize()
|
|
|
| def testExplicitPrefixStripping(self):
|
| definition = EnumDefinition(original_enum_name='c', enum_package='p')
|
| - definition.AppendEntry('P_A', None)
|
| - definition.AppendEntry('B', None)
|
| - definition.AppendEntry('P_C', None)
|
| - definition.AppendEntry('P_LAST', 'P_C')
|
| + definition.AppendEntry('P_A', None, [])
|
| + definition.AppendEntry('B', None, [])
|
| + definition.AppendEntry('P_C', None, [])
|
| + definition.AppendEntry('P_LAST', 'P_C', [])
|
| definition.prefix_to_strip = 'P_'
|
| definition.Finalize()
|
| self.assertEqual(collections.OrderedDict([('A', 0),
|
| @@ -392,10 +424,10 @@ public class ClassName {
|
| def testImplicitPrefixStripping(self):
|
| definition = EnumDefinition(original_enum_name='ClassName',
|
| enum_package='p')
|
| - definition.AppendEntry('CLASS_NAME_A', None)
|
| - definition.AppendEntry('CLASS_NAME_B', None)
|
| - definition.AppendEntry('CLASS_NAME_C', None)
|
| - definition.AppendEntry('CLASS_NAME_LAST', 'CLASS_NAME_C')
|
| + definition.AppendEntry('CLASS_NAME_A', None, [])
|
| + definition.AppendEntry('CLASS_NAME_B', None, [])
|
| + definition.AppendEntry('CLASS_NAME_C', None, [])
|
| + definition.AppendEntry('CLASS_NAME_LAST', 'CLASS_NAME_C', [])
|
| definition.Finalize()
|
| self.assertEqual(collections.OrderedDict([('A', 0),
|
| ('B', 1),
|
| @@ -406,9 +438,9 @@ public class ClassName {
|
| def testImplicitPrefixStrippingRequiresAllConstantsToBePrefixed(self):
|
| definition = EnumDefinition(original_enum_name='Name',
|
| enum_package='p')
|
| - definition.AppendEntry('A', None)
|
| - definition.AppendEntry('B', None)
|
| - definition.AppendEntry('NAME_LAST', None)
|
| + definition.AppendEntry('A', None, [])
|
| + definition.AppendEntry('B', None, [])
|
| + definition.AppendEntry('NAME_LAST', None, [])
|
| definition.Finalize()
|
| self.assertEqual(['A', 'B', 'NAME_LAST'], definition.entries.keys())
|
|
|
|
|