diff paraspace/tests/injection_test.py @ 116:c5f59bdbc916

Fix issue of proto matching. - DEXFile_linked._proto_is_compatible() compares return type of prototypes in _DEX_TypeId objects. - It should match them with type name.
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 04 Aug 2011 18:30:11 +0800
parents d112c27f657a
children 7b537e0d8e7a
line wrap: on
line diff
--- a/paraspace/tests/injection_test.py	Thu Aug 04 15:55:01 2011 +0800
+++ b/paraspace/tests/injection_test.py	Thu Aug 04 18:30:11 2011 +0800
@@ -299,6 +299,7 @@
     from paraspace.dex_deptracker import prepare_dep_decls
     from paraspace.injection import inject_classdefs
     from paraspace import dalvik_opcodes
+    from paraspace.dexfile import DEXFile_linked
     
     _install_dexfile_4_deptracker()
     
@@ -333,4 +334,26 @@
                                 [fakefile_def])
     assert clonings
     assert len(clonings) == 1
+
+    fakefile_cloning = clonings[0]
+    method = helloworld_linked.find_method_name('<init>', fakefile_cloning)
+    assert isinstance(method, dexfile._DEX_Method)
+
+    V_typeid = helloworld_linked.find_typeid_name('V')
+    file_typeid = helloworld_linked.find_typeid_name('Ljava/io/File;')
+    file_typeidx = helloworld_linked.get_idx_typeid(file_typeid)
+    str_typeid = helloworld_linked.find_typeid_name('Ljava/lang/String;')
+    protoid = DEXFile_linked.make_protoid(V_typeid,
+                                          (file_typeid, str_typeid))
+    initid = helloworld_linked.find_methodid_name_proto('<init>',
+                                                        protoid,
+                                                        file_typeid)
+    initidx = helloworld_linked.get_idx_methodid(initid)
+
+    insns_block = DEXFile_linked.get_code_block_method(method)
+    opvectors = dalvik_opcodes.decode_insn_blk(insns_block)
+    assert len(opvectors) == 2
+    opvector = opvectors[0]
+    args = opvector[1]
+    assert args[2] == initidx
     pass