| OLD | NEW |
| 1 #! /usr/bin/env python | 1 #! /usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import unittest | 6 import unittest |
| 7 from xml.etree import ElementTree | 7 from xml.etree import ElementTree |
| 8 | 8 |
| 9 from pylib.utils import dexdump | 9 from pylib.utils import dexdump |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 '</api>') | 71 '</api>') |
| 72 | 72 |
| 73 actual = dexdump._ParseRootNode( | 73 actual = dexdump._ParseRootNode( |
| 74 ElementTree.fromstring(example_xml_string)) | 74 ElementTree.fromstring(example_xml_string)) |
| 75 | 75 |
| 76 expected = { | 76 expected = { |
| 77 'com.foo.bar1' : { | 77 'com.foo.bar1' : { |
| 78 'classes': { | 78 'classes': { |
| 79 'Class1': { | 79 'Class1': { |
| 80 'methods': ['class1Method1', 'class1Method2'], | 80 'methods': ['class1Method1', 'class1Method2'], |
| 81 'superclass': 'java.lang.Object', |
| 81 }, | 82 }, |
| 82 'Class2': { | 83 'Class2': { |
| 83 'methods': ['class2Method1'], | 84 'methods': ['class2Method1'], |
| 85 'superclass': 'java.lang.Object', |
| 84 } | 86 } |
| 85 }, | 87 }, |
| 86 }, | 88 }, |
| 87 'com.foo.bar2' : {'classes': {}}, | 89 'com.foo.bar2' : {'classes': {}}, |
| 88 'com.foo.bar3' : {'classes': {}}, | 90 'com.foo.bar3' : {'classes': {}}, |
| 89 } | 91 } |
| 90 self.assertEquals(expected, actual) | 92 self.assertEquals(expected, actual) |
| 91 | 93 |
| 92 def testParsePackageNode(self): | 94 def testParsePackageNode(self): |
| 93 example_xml_string = ( | 95 example_xml_string = ( |
| 94 '<package name="com.foo.bar">' | 96 '<package name="com.foo.bar">' |
| 95 '<class name="Class1">' | 97 '<class name="Class1" extends="java.lang.Object">' |
| 96 '</class>' | 98 '</class>' |
| 97 '<class name="Class2">' | 99 '<class name="Class2" extends="java.lang.Object">' |
| 98 '</class>' | 100 '</class>' |
| 99 '</package>') | 101 '</package>') |
| 100 | 102 |
| 101 | 103 |
| 102 actual = dexdump._ParsePackageNode( | 104 actual = dexdump._ParsePackageNode( |
| 103 ElementTree.fromstring(example_xml_string)) | 105 ElementTree.fromstring(example_xml_string)) |
| 104 | 106 |
| 105 expected = { | 107 expected = { |
| 106 'classes': { | 108 'classes': { |
| 107 'Class1': { | 109 'Class1': { |
| 108 'methods': [], | 110 'methods': [], |
| 111 'superclass': 'java.lang.Object', |
| 109 }, | 112 }, |
| 110 'Class2': { | 113 'Class2': { |
| 111 'methods': [], | 114 'methods': [], |
| 115 'superclass': 'java.lang.Object', |
| 112 }, | 116 }, |
| 113 }, | 117 }, |
| 114 } | 118 } |
| 115 self.assertEquals(expected, actual) | 119 self.assertEquals(expected, actual) |
| 116 | 120 |
| 117 def testParseClassNode(self): | 121 def testParseClassNode(self): |
| 118 example_xml_string = ( | 122 example_xml_string = ( |
| 119 '<class name="Class1">' | 123 '<class name="Class1" extends="java.lang.Object">' |
| 120 '<method name="method1">' | 124 '<method name="method1">' |
| 121 '</method>' | 125 '</method>' |
| 122 '<method name="method2">' | 126 '<method name="method2">' |
| 123 '</method>' | 127 '</method>' |
| 124 '</class>') | 128 '</class>') |
| 125 | 129 |
| 126 actual = dexdump._ParseClassNode( | 130 actual = dexdump._ParseClassNode( |
| 127 ElementTree.fromstring(example_xml_string)) | 131 ElementTree.fromstring(example_xml_string)) |
| 128 | 132 |
| 129 expected = { | 133 expected = { |
| 130 'methods': ['method1', 'method2'], | 134 'methods': ['method1', 'method2'], |
| 135 'superclass': 'java.lang.Object', |
| 131 } | 136 } |
| 132 self.assertEquals(expected, actual) | 137 self.assertEquals(expected, actual) |
| 133 | 138 |
| 134 | 139 |
| 135 if __name__ == '__main__': | 140 if __name__ == '__main__': |
| 136 unittest.main() | 141 unittest.main() |
| OLD | NEW |