/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 1 7 ĠThe ĠAndroid ĠOpen ĠSource ĠProject Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġandroidx . lifecycle Ċ Ċ import Ġandroidx . lifecycle . utils . load Ċ import Ġandroidx . lifecycle . utils . process Class Ċ import Ġcom . google . testing . compile . Compile Tester Ċ import Ġcom . google . testing . compile . Java Sources Subject Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ import Ġjava . io . File Ċ import Ġjavax . tools . Standard Location Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠValid Cases Test Ġ{ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class (" foo . Bar "). comp iles Without Error () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest On Any () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class (" foo . On Any Method "). comp iles Without Error (). and (). gener ates Sources ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . On Any Method _ Lifecycle Adapter ", Ġ" expected ") ĊĠĠĠĠĠĠĠ Ġ). and (). gener ates Pro Guard Rule (" foo . On Any Method . pro ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Inheritance () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class (" foo . Inheritance Ok 1 "). comp iles Without Error () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Inheritance 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class (" foo . Inheritance Ok 2 "). comp iles Without Error (). and (). gener ates Sources ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . Inheritance Ok 2 Base _ Lifecycle Adapter ", Ġ" expected "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . Inheritance Ok 2 Derived _ Lifecycle Adapter ", Ġ" expected ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Inheritance Ok 2 Base . pro ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Inheritance Ok 2 Derived . pro ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Inheritance 3 () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class (" foo . Inheritance Ok 3 "). comp iles Without Error (). and (). gener ates Sources ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . Inheritance Ok 3 Base _ Lifecycle Adapter ", Ġ" expected "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . Inheritance Ok 3 Derived _ Lifecycle Adapter ", Ġ" expected ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Inheritance Ok 3 Base . pro ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Inheritance Ok 3 Derived . pro ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest No Package Class () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class (" No Package Ok "). comp iles Without Error () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Interface 1 () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class (" foo . Interface Ok 1 "). comp iles Without Error () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Interface 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class (" foo . Interface Ok 2 "). comp iles Without Error (). and (). gener ates Sources ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . Interface Ok 2 Base _ Lifecycle Adapter ", Ġ" expected "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . Interface Ok 2 Derived _ Lifecycle Adapter ", Ġ" expected "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . Interface Ok 2 Interface _ Lifecycle Adapter ", Ġ" expected ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Interface Ok 2 Base . pro ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Interface Ok 2 Derived . pro ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Interface Ok 2 Interface . pro ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Inheritance Different Packages 1 () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" foo . Different Packages Base 1 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" bar . Different Packages Derived 1 " ĊĠĠĠĠĠĠĠ Ġ). comp iles Without Error (). and (). gener ates Sources ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . Different Packages Base 1 _ Lifecycle Adapter ", Ġ" expected "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" bar . Different Packages Derived 1 _ Lifecycle Adapter ", Ġ" expected ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Different Packages Base 1 . pro ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" bar . Different Packages Derived 1 . pro ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Inheritance Different Packages 2 () Ġ{ ĊĠĠĠĠĠĠĠ Ġprocess Class ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" foo . Different Packages Base 2 ", ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ" bar . Different Packages Derived 2 " ĊĠĠĠĠĠĠĠ Ġ). comp iles Without Error (). and (). gener ates Sources ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" foo . Different Packages Base 2 _ Lifecycle Adapter ", Ġ" expected "), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġload (" bar . Different Packages Derived 2 _ Lifecycle Adapter ", Ġ" expected ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Different Packages Pre Base 2 . pro ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" foo . Different Packages Base 2 . pro ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. and (). gener ates Pro Guard Rule (" bar . Different Packages Derived 2 . pro ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġ< T > ĠCompile Tester . Generated Predicate Clause < T >. gener ates Pro Guard Rule ( name : ĠString ): ĊĠĠĠĠĠĠĠ ĠCompile Tester . Successful File Clause < T > Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġgenerates FileName d ( Standard Location . CLASS _ OUTPUT , Ġ"", Ġ" META - INF / pro guard /$ name ") ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Jar () Ġ{ ĊĠĠĠĠĠĠĠ ĠJava Sources Subject . assertThat ( load (" foo . Derived From Jar ", Ġ"")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Classpath ( library Classpath Files ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. processed With ( Lifecycle Processor ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. comp iles Without Error (). and () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. gener ates Sources ( load (" foo . Derived From Jar _ Lifecycle Adapter ", Ġ" expected ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Extend From Jar Fail To Generate Adapter () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcompile Tester Ġ= ĠJava Sources Subject . assertThat ( load (" foo . Derived From Jar 1 ", Ġ"")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. with Classpath ( library Classpath Files ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. processed With ( Lifecycle Processor ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. comp iles Without Error () ĊĠĠĠĠĠĠĠ Ġcompile Tester . with Warning Containing (" Failed Ġto Ġgenerate Ġan ĠAdapter Ġfor ") ĊĠĠĠĠĠĠĠ Ġdoesnt Generate Class ( compile Tester , Ġ" test . library ", Ġ" Observer No Adapter _ Lifecycle Adapter ") ĊĠĠĠĠĠĠĠ Ġdoesnt Generate Class ( compile Tester , Ġ" foo ", Ġ" Derived From Jar 1 _ Lifecycle Adapter ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// Ġcompile - testing Ġhas Ġfancy , Ġbut Ġnot Ġalways Ġconvenient ĠAPI ĊĠĠĠ Ġprivate Ġfun Ġdoesnt Generate Class ( ĊĠĠĠĠĠĠĠ Ġcompile : ĠCompile Tester . Successful Compilation Clause , ĊĠĠĠĠĠĠĠ ĠpackageName : ĠString , ĊĠĠĠĠĠĠĠ ĠclassName : ĠString ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcompile . and (). gener ates FileName d ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠStandard Location . CLASS _ OUTPUT , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠpackageName , Ġ"$ className . class " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠException ("$ packageName .$ className Ġshouldn 't Ġbe Ġgenerated ") ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠAssertionError ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġlibrary Classpath Files () Ġ= ĊĠĠĠĠĠĠĠ Ġget System Classpath Files () Ġ+ ĠFile (" src / test / test - data / lib / test - library . jar ") ĊĊĠĠĠ Ġprivate Ġfun Ġget System Classpath Files (): ĠSet < File > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġpath Separator Ġ= ĠSystem . getProperty (" path . separator ") ĊĠĠĠĠĠĠĠ Ġreturn ĠSystem . getProperty (" java . class . path "). split ( path Separator ). map Ġ{ ĠFile ( it ) Ġ}. toSet () ĊĠĠĠ Ġ} Ċ } Ċ