changeset 60:f295d82646e0

testcase for restore_dependencies()
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 27 Jun 2011 18:09:31 +0800
parents 08c220217076
children 3e34c7d33182
files paraspace/tests/dexfile_test.py
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/paraspace/tests/dexfile_test.py	Mon Jun 27 13:17:42 2011 +0800
+++ b/paraspace/tests/dexfile_test.py	Mon Jun 27 18:09:31 2011 +0800
@@ -300,3 +300,31 @@
     assert dex.typeLists.items[0].value.data_offset == offset0
     assert dex.typeLists.items[1].value.data_offset == offset1
     pass
+
+
+def restore_dependencies_test():
+    from paraspace.dex_deptracker import collect_all_dep_decls
+    from paraspace.dex_deptracker import build_dependencies
+    from paraspace.dex_deptracker import _install_markers
+    from paraspace.dex_deptracker import _patch_dex_type_markers
+    from paraspace.dex_deptracker import restore_dependencies
+
+    _install_dexfile_4_deptracker()
+
+    all_dep_decls = collect_all_dep_decls()
+    _install_markers(all_dep_decls)
+    _patch_dex_type_markers(all_dep_decls)
+
+    srcdir = os.path.dirname(__file__)
+    srcroot = os.path.join(srcdir, '..', '..')
+    testdatapath = os.path.join(srcroot, 'data', 'testdata1.dex')
+    dex = dexfile.DEXFile.open(testdatapath)
+
+    build_dependencies(dex, all_dep_decls)
+
+    restore_dependencies(dex, all_dep_decls)
+
+    stringid = dex.stringIds.items[0]
+    assert isinstance(stringid.stringDataOff, int)
+    pass
+