# HG changeset patch # User Thinker K.F. Li # Date 1309169371 -28800 # Node ID f295d82646e035f35fe93797ad734796e2a9c30c # Parent 08c220217076d5048b6318bccff2bee368dee3c5 testcase for restore_dependencies() diff -r 08c220217076 -r f295d82646e0 paraspace/tests/dexfile_test.py --- 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 +