Mercurial > paraspace
comparison 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 |
comparison
equal
deleted
inserted
replaced
115:d112c27f657a | 116:c5f59bdbc916 |
---|---|
297 | 297 |
298 def inject_classdefs_test(): | 298 def inject_classdefs_test(): |
299 from paraspace.dex_deptracker import prepare_dep_decls | 299 from paraspace.dex_deptracker import prepare_dep_decls |
300 from paraspace.injection import inject_classdefs | 300 from paraspace.injection import inject_classdefs |
301 from paraspace import dalvik_opcodes | 301 from paraspace import dalvik_opcodes |
302 from paraspace.dexfile import DEXFile_linked | |
302 | 303 |
303 _install_dexfile_4_deptracker() | 304 _install_dexfile_4_deptracker() |
304 | 305 |
305 all_dep_decls = prepare_dep_decls() | 306 all_dep_decls = prepare_dep_decls() |
306 | 307 |
331 fakefile_linked.find_class_name('Lcom/codemud/fakefile/fakefile;') | 332 fakefile_linked.find_class_name('Lcom/codemud/fakefile/fakefile;') |
332 clonings = inject_classdefs(helloworld_linked, fakefile_linked, | 333 clonings = inject_classdefs(helloworld_linked, fakefile_linked, |
333 [fakefile_def]) | 334 [fakefile_def]) |
334 assert clonings | 335 assert clonings |
335 assert len(clonings) == 1 | 336 assert len(clonings) == 1 |
336 pass | 337 |
338 fakefile_cloning = clonings[0] | |
339 method = helloworld_linked.find_method_name('<init>', fakefile_cloning) | |
340 assert isinstance(method, dexfile._DEX_Method) | |
341 | |
342 V_typeid = helloworld_linked.find_typeid_name('V') | |
343 file_typeid = helloworld_linked.find_typeid_name('Ljava/io/File;') | |
344 file_typeidx = helloworld_linked.get_idx_typeid(file_typeid) | |
345 str_typeid = helloworld_linked.find_typeid_name('Ljava/lang/String;') | |
346 protoid = DEXFile_linked.make_protoid(V_typeid, | |
347 (file_typeid, str_typeid)) | |
348 initid = helloworld_linked.find_methodid_name_proto('<init>', | |
349 protoid, | |
350 file_typeid) | |
351 initidx = helloworld_linked.get_idx_methodid(initid) | |
352 | |
353 insns_block = DEXFile_linked.get_code_block_method(method) | |
354 opvectors = dalvik_opcodes.decode_insn_blk(insns_block) | |
355 assert len(opvectors) == 2 | |
356 opvector = opvectors[0] | |
357 args = opvector[1] | |
358 assert args[2] == initidx | |
359 pass |