Skip to content

Commit

Permalink
update access flags test to use Analysis' underlying ClassDefItem's g…
Browse files Browse the repository at this point in the history
…et_methods() and get_fields() for getting fields and methods, as opposed to the Analysis get_methods() and get_fields() which are supposed to only return xrefs of methods and fields.
  • Loading branch information
ehrenb committed Feb 3, 2024
1 parent 2724ccc commit f47720a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/test_dex.py
Expand Up @@ -103,26 +103,26 @@ def testAccessflags(self):
self.assertEqual(class_access_flags, class_data['access_flag'])

# test access flags for methods
method_analyses = class_analysis.get_methods()
encoded_methods = class_analysis.get_vm_class().get_methods()
for expected_method_name, expected_access_flags in class_data['methods'].items():
# ensure this method is in the class
self.assertIn(expected_method_name, [method.name for method in method_analyses])
self.assertIn(expected_method_name, [method.name for method in encoded_methods])

# ensure access flags match
for method in method_analyses:
for method in encoded_methods:
if method.name == expected_method_name:
self.assertEqual(method.method.get_access_flags(), expected_access_flags)
self.assertEqual(method.get_access_flags(), expected_access_flags)

# test access flags for fields
field_analyses = class_analysis.get_fields()
encoded_fields = class_analysis.get_vm_class().get_fields()
for expected_field_name, expected_access_flags in class_data['fields'].items():
# ensure this field is in the class
self.assertIn(expected_field_name, [field.name for field in field_analyses])
self.assertIn(expected_field_name, [field.name for field in encoded_fields])

# ensure access flags match
for field in field_analyses:
for field in encoded_fields:
if field.name == expected_field_name:
self.assertEqual(field.field.get_access_flags(), expected_access_flags)
self.assertEqual(field.get_access_flags(), expected_access_flags)

class InstructionTest(unittest.TestCase):
def testInstructions(self):
Expand Down

0 comments on commit f47720a

Please sign in to comment.