package Ġsa ar land . cis pa . frontmatter ĊĊ Ċ import Ġorg . assertj . core . api . Assertions . assertThat Ċ import Ġorg . junit . jupiter . api . BeforeEach Ċ import Ġorg . junit . jupiter . api . Test Ċ import Ġsa ar land . cis pa . frontmatter . analy ses . App Platform Ċ import Ġsa ar land . cis pa . frontmatter . analy ses . Front matter Metadata Ċ import Ġsa ar land . cis pa . frontmatter . cg . Call graph Assembler Ċ import Ġsa ar land . cis pa . frontmatter . cg . Inter pro ced ural CFG Wrapper Ċ import Ġsa ar land . cis pa . frontmatter . data . Activity Origin Ċ import Ġsa ar land . cis pa . frontmatter . resolvers . Transition Resolver Ċ import Ġsa ar land . cis pa . frontmatter . resolvers . UI View Ċ import Ġsa ar land . cis pa . frontmatter . resolvers . Value Resolver Ċ import Ġsa ar land . cis pa . frontmatter . results . Results Handler Ċ import Ġso ot . Scene Ċ import Ġso ot . j imple . info flow . android . manifest . Process Manifest Ċ import Ġjava . nio . file . Path Ċ import Ġjava . nio . file . Paths ĊĊ Ċ class ĠLayout Parser Test Ġ{ ĊĠĠĠ Ġ// ĠĠĠ Ġprivate Ġvar Ġapk File : ĠString Ġ= Ġ"/ Users / ku z net so v / work / workspace / reactive - system - an omal ies / ap ks / train / com . new ny c way . apk " ĊĠĠĠ Ġprivate Ġvar Ġapk File : ĠPath Ġ= ĠPaths . get ( Layout Parser Test :: class . java . class Loader . getResource (" app - debug . apk "). file ) ĊĠĠĠ Ġprivate Ġval Ġandroid Jar : ĠPath Ġ= ĠPaths . get ("/ Users / ku z net so v / work / android / sdk / platforms ") // System . getProperty (" android _ jar ") ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġscene V : ĠScene ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġapk Info : ĠA pk Info ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġpkg : ĠString ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġres Parser : ĠResource Parser ĊĠĠĠ Ġprivate Ġval Ġmeta Ġ= ĠFront matter Metadata ("", Ġ"", Ġ 0 , Ġ 0 , Ġ"", ĠApp Platform . NORMAL , Ġ"") ĊĠĠĠ Ġ// ĠString Ġtarget AP K Ġ= Ġ" test Apps / fr agement app . apk "; ĊĠĠĠ Ġ// Ġapk File Ġ= Ġ"/ Volumes / Internal / workspace / reactive - system - an omal ies / ap ks / train / au . gov . vic . pt v . apk "; ĊĠĠĠ Ġ// Ġapk File Ġ= Ġ"/ Volumes / Internal / workspace / reactive - system - an omal ies / ap ks / train / com . th ales . android . east co ast . apk "; ĊĠĠĠ Ġ// Ġapk File Ġ= Ġ"/ Volumes / Internal / workspace / reactive - system - an omal ies / ap ks / train / com . new ny c way . apk " ĊĠĠĠ Ġ// Ġapk File Ġ= Ġ"/ Volumes / Internal / workspace / reactive - system - an omal ies / ap ks / train / com . w ander u . w ander u . apk "; ĊĠĠĠ Ġ// Ġapk File Ġ= ĠLayout Parser Test . class . getClassLoader (). getResource (" app - debug . apk "). getFile (); ĊĠĠĠ Ġ// Ġapk File Ġ= Ġ"/ Users / ku z net so v / LAB / workspace / apk _ samples / uni - app - android / android - app / android - app - release . apk "; ĊĊĠĠĠ Ġ@ BeforeEach ĊĠĠĠ Ġfun Ġinit () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmanifest Ġ= ĠProcess Manifest ( apk File . to File ()) ĊĠĠĠĠĠĠĠ Ġscene V Ġ= ĠUtils . initialize S oot ( android Jar , Ġapk File , Ġmanifest . packageName ) ĊĠĠĠĠĠĠĠ Ġapk Info Ġ= ĠA pk Info ( scene V , Ġapk File , Ġmanifest ) ĊĠĠĠĠĠĠĠ Ġpkg Ġ= Ġapk File . fileName . toString () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġcall Graph Size Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlayout Analysis Ġ= ĠXml Layout Analysis ( scene V , Ġapk Info ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback Analysis Ġ= ĠCallback Analysis ( scene V , Ġlayout Analysis ) ĊĠĠĠĠĠĠĠ Ġval Ġcall graph Assembler Ġ= ĠCall graph Assembler ( scene V , Ġcallback Analysis . possible Callbacks , Ġapk Info ) ĊĠĠĠĠĠĠĠ Ġval Ġcall Graph Ġ= Ġcall graph Assembler . call graph ĊĠĠĠĠĠĠĠ ĠassertThat ( call Graph ). has Size ( 1 4 6 5 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠsetContentView Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Activities Ġ= Ġmap Of ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" com . example . av di i enko . button _ xml . Activity Class Implements Listener Interface " Ġto Ġ 2 1 3 0 9 6 8 6 0 1 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" com . example . av di i enko . button _ xml . Anonymous OnClick Handler " Ġto Ġ 2 1 3 0 9 6 8 6 0 2 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" com . example . av di i enko . button _ xml . Base Activity " Ġto Ġ 2 1 3 0 9 6 8 6 0 3 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" com . example . av di i enko . button _ xml . Button With Listener In Method " Ġto Ġ 2 1 3 0 9 6 8 6 0 4 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" com . example . av di i enko . button _ xml . Id In Array " Ġto Ġ 2 1 3 0 9 6 8 6 0 5 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" com . example . av di i enko . button _ xml . Interface Type " Ġto Ġ 2 1 3 0 9 6 8 6 0 6 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" com . example . av di i enko . button _ xml . MainActivity " Ġto Ġ 2 1 3 0 9 6 8 6 0 7 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" com . example . av di i enko . button _ xml . Member Class " Ġto Ġ 2 1 3 0 9 6 8 6 0 8 , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" com . example . av di i enko . button _ xml . One Listener Multiple Buttons " Ġto Ġ 2 1 3 0 9 6 8 6 0 9 ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġlayout Analysis Ġ= ĠXml Layout Analysis ( scene V , Ġapk Info ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback Analysis Ġ= ĠCallback Analysis ( scene V , Ġlayout Analysis ) ĊĠĠĠĠĠĠĠ Ġval Ġcall graph Assembler Ġ= ĠCall graph Assembler ( scene V , Ġcallback Analysis . possible Callbacks , Ġapk Info ) ĊĠĠĠĠĠĠĠ Ġval Ġic fg Ġ= ĠInter pro ced ural CFG Wrapper ( scene V , Ġcall graph Assembler . call graph ) ĊĠĠĠĠĠĠĠ Ġval Ġvalue Resolver Ġ= ĠValue Resolver ( scene V , Ġic fg ) Ċ // ĠĠĠĠĠĠĠ Ġval Ġinf late Resolver Ġ= ĠInf late Resolver ( scene V , Ġic fg , Ġvalue Resolver , Ġview Resolver ) ĊĠĠĠĠĠĠĠ Ġval Ġapp Model Ġ= ĠApp Model ( apk Info . declared Activities , Ġmeta ) ĊĠĠĠĠĠĠĠ Ġval Ġlm Ġ= ĠActivity Layout Resolver ( scene V , Ġapp Model , Ġvalue Resolver , Ġapk Info . resource Parser , Ġlayout Analysis ) ĊĠĠĠĠĠĠĠ Ġval Ġlayout Mapping Ġ= Ġlm . resolve () ĊĠĠĠĠĠĠĠ Ġval Ġexpected Activity Names Ġ= Ġexpected Activities . keys ĊĠĠĠĠĠĠĠ Ġval Ġactual Activity Names Ġ= Ġlayout Mapping . activity Layouts . keySet (). map Ġ{ Ġit . name Ġ}. toSet () ĊĠĠĠĠĠĠĠ ĠassertThat < String >( actual Activity Names ). contains Exactly In Any Order (* expected Activity Names . to Typed Array ()) ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( pair Ġin Ġlayout Mapping . activity Layouts ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġactivity Id Ġ= Ġpair . o 2 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġactual Activity Ġ= Ġpair . o 1 ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġactual Activity Name Ġ= Ġactual Activity . name ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġexpected Activity Id Ġ= Ġexpected Activities . get ( actual Activity Name ). toString () ĊĠĠĠĠĠĠĠĠĠĠĠ ĠassertThat ( activity Id . toString ()). isEqualTo ( expected Activity Id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġresults Handler Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlayout Analysis Ġ= ĠXml Layout Analysis ( scene V , Ġapk Info ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback Analysis Ġ= ĠCallback Analysis ( scene V , Ġlayout Analysis ) ĊĠĠĠĠĠĠĠ Ġval Ġcall graph Assembler Ġ= ĠCall graph Assembler ( scene V , Ġcallback Analysis . possible Callbacks , Ġapk Info ) ĊĠĠĠĠĠĠĠ Ġval Ġic fg Ġ= ĠInter pro ced ural CFG Wrapper ( scene V , Ġcall graph Assembler . call graph ) ĊĠĠĠĠĠĠĠ Ġval Ġvalue Resolver Ġ= ĠValue Resolver ( scene V , Ġic fg ) ĊĠĠĠĠĠĠĠ Ġval Ġapp Model Ġ= ĠApp Model ( apk Info . declared Activities , Ġmeta ) ĊĠĠĠĠĠĠĠ Ġval Ġlm Ġ= ĠActivity Layout Resolver ( scene V , Ġapp Model , Ġvalue Resolver , Ġapk Info . resource Parser , Ġlayout Analysis ) ĊĠĠĠĠĠĠĠ Ġval Ġah Ġ= Ġlm . resolve () ĊĠĠĠĠĠĠĠ Ġval Ġres FilePath Ġ= Ġ" layouts _$ pkg . json " ĊĠĠĠĠĠĠĠ Ġval Ġlayout Mapping Ġ= Ġah . activity Layouts . map Ġ{ Ġ( k , Ġv ) Ġ-> Ġk Ġto Ġ( v Ġas ĠUIView ). ui View Element . id Ġ}. to Multi Map () ĊĠĠĠĠĠĠĠ ĠResults Handler . save Activities Content ( layout Analysis . layout sWith Id , Ġlayout Mapping , ĠPaths . get ( res FilePath )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġsimple Layouts Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlayout Analysis Ġ= ĠXml Layout Analysis ( scene V , Ġapk Info ) ĊĠĠĠĠĠĠĠ Ġval Ġuser Controls Ġ= Ġlayout Analysis . flat Layouts ĊĠĠĠĠĠĠĠ ĠassertThat ( user Controls . keySet ()). has Size ( 4 5 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠstartActivity Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlayout Analysis Ġ= ĠXml Layout Analysis ( scene V , Ġapk Info ) ĊĠĠĠĠĠĠĠ Ġval Ġcallback Analysis Ġ= ĠCallback Analysis ( scene V , Ġlayout Analysis ) ĊĠĠĠĠĠĠĠ Ġval Ġcall graph Assembler Ġ= ĠCall graph Assembler ( scene V , Ġcallback Analysis . possible Callbacks , Ġapk Info ) ĊĠĠĠĠĠĠĠ Ġval Ġic fg Ġ= ĠInter pro ced ural CFG Wrapper ( scene V , Ġcall graph Assembler . call graph ) ĊĠĠĠĠĠĠĠ Ġval Ġvalue Resolver Ġ= ĠValue Resolver ( scene V , Ġic fg ) ĊĠĠĠĠĠĠĠ Ġval Ġapp Model Ġ= ĠApp Model ( apk Info . declared Activities , Ġmeta ) ĊĠĠĠĠĠĠĠ Ġval Ġat f Ġ= ĠTransition Resolver ( scene V , Ġapp Model , Ġic fg , Ġvalue Resolver , Ġapk Info . resource Parser , Ġapk Info . intent Filters ) ĊĠĠĠĠĠĠĠ Ġat f . resolve () ĊĠĠĠĠĠĠĠ Ġval Ġactivity Transitions Ġ= Ġapp Model . transitions ĊĠĠĠĠĠĠĠ Ġval Ġres FilePath Ġ= Ġ" transitions _$ pkg . json " ĊĠĠĠĠĠĠĠ Ġ// ĠResults Handler . save Transitions ( activity Transitions , ĠPaths . get ( res FilePath )); ĊĠĠĠĠĠĠĠ Ġfor Ġ( activity Transition Ġin Ġactivity Transitions ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprintln ( activity Transition ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠassertThat ( scene V . call Graph ). has Size ( 1 4 8 2 ) ĊĠĠĠ Ġ} Ċ Ċ } Ċ