package Ġcom . ati ur in . sample app . tests . uia utom ator Ċ Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġcom . ati ur in . sample app . R Ċ import Ġcom . ati ur in . sample app . activity . Ui Elements Activity Ċ import Ġcom . ati ur in . sample app . framework . utils . Assert Utils Ċ import Ġcom . ati ur in . sample app . framework . utils . TestData Utils Ċ import Ġcom . ati ur in . sample app . pages . Ui Object Elements Page Ċ import Ġcom . ati ur in . sample app . tests . Ui Elements Test Ċ import Ġcom . ati ur in . ul tron . core . uia utom ator . u io bject . Ul tron Ui Object . Companion . ui Selector Ċ import Ġcom . ati ur in . ul tron . utils . getTarget String Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Test Ċ Ċ class ĠU l tron Ui Object Actions Test : ĠUi Elements Test () Ġ{ ĊĠĠĠ Ġval Ġpage Ġ= ĠUi Object Elements Page () ĊĠĠĠ Ġ// getChild ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Child _ exist ed Child (){ ĊĠĠĠĠĠĠĠ Ġval Ġchild Ġ= Ġpage . radio Group . getChild ( ui Selector ( R . id . radio _ g one )) ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( child ) ĊĠĠĠĠĠĠĠ Ġchild . click () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Child _ not Exist ed Child (){ ĊĠĠĠĠĠĠĠ Ġval Ġchild Ġ= Ġpage . radio Group . getChild ( ui Selector ( R . id . button 1 )) ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( child ) ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġchild . with Timeout ( 1 0 0 ). click () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// getChild Count ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Child Count _ child Exist (){ ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 3 , Ġpage . radio Group . getChild Count ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Child Count _ no Child Exist (){ ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 0 , Ġpage . button . getChild Count ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// get From Parent ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfind Object _ exist ed Child Object (){ ĊĠĠĠĠĠĠĠ Ġval Ġchild Ġ= Ġpage . radio Group . get From Parent ( ui Selector ( R . id . radio _ invisible )) ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( child ) ĊĠĠĠĠĠĠĠ Ġchild . click () ĊĠĠĠĠĠĠĠ Ġpage . button . not Exists () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget From Parent _ not Exist ed Child Object (){ ĊĠĠĠĠĠĠĠ Ġval Ġchild Ġ= Ġpage . radio G one Button . get From Parent ( ui Selector ( R . id . button 1 )) ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( child ) ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġchild . with Timeout ( 1 0 0 ). click () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// getText ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetText _ object Has Text (){ ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( getTarget String ( R . string . button _ text ), Ġpage . button . getText ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetText _ object Has No Text (){ ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( Ġpage . sw ip able ImageView . getText () !!. isEmpty ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetText _ not Exist ed Object (){ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). getText () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// get ClassName ĊĠĠĠ Ġ@ Test ĊĊĠĠĠ Ġfun Ġget ClassName _ exist Object (){ ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals (" android . widget . Button ", Ġpage . button . get ClassName ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget ClassName _ not Exist Object (){ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). get ClassName () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// getApplication Package ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Application Package _ exist ed Object (){ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Ġ= ĠInstrument ation Registry . get Instrumentation (). target Context . application Info . packageName ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( expected , Ġpage . button . get PackageName ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Application Package _ not Exist ed Object (){ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). get PackageName () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// get Visible Bounds ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Visible Bounds _ exist ed Object (){ ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( page . button . get Visible Bounds ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Visible Bounds _ not Exist ed Object (){ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). get Visible Bounds () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// getContent Description ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetContent Description _ exist ed Content Description (){ ĊĠĠĠĠĠĠĠ Ġval Ġexpected Cont Desc Ġ= Ġget Target String ( R . string . button _ default _ content _ desc ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( expected Cont Desc , Ġpage . button . getContent Description ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetContent Description _ not Exist ed ResourceName (){ ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( page . checkBox Clickable . getContent Description () !!. isEmpty ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetContent Description _ not Exist ed Object (){ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). getContent Description () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// click ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġclick _ onClick able () Ġ{ ĊĠĠĠĠĠĠĠ Ġpage . button . exists (). click () ĊĠĠĠĠĠĠĠ Ġpage . event Status . text Contains ( TestData Utils . getResource String ( R . string . button _ event _ click )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġclick _ with Duration _ onClick able () Ġ{ ĊĠĠĠĠĠĠĠ Ġpage . button . exists (). click () ĊĠĠĠĠĠĠĠ Ġpage . event Status . text Contains ( TestData Utils . getResource String ( R . string . button _ event _ click )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġclick _ on NotExist ed Object () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). click () Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġ// long Click ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġlong Click _ on Long Clickable () Ġ{ ĊĠĠĠĠĠĠĠ Ġpage . button . exists (). long Click () ĊĠĠĠĠĠĠĠ Ġpage . event Status . text Contains ( getTarget String ( R . string . button _ event _ long _ click )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġlong Click _ on NotExist ed Object () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). long Click () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġlegacy SetText _ to Editable (){ ĊĠĠĠĠĠĠĠ Ġval Ġtext Ġ= Ġ" text Ġto Ġreplace Ġ" ĊĠĠĠĠĠĠĠ Ġpage . edit Text Content Desc ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. clear TextField () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. legacy Add Text ( text ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Text ( text ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġlegacy SetText _ to NotExist ed Object (){ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). legacy Add Text (" some Ġnew Ġtext ") Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġ// replace Text ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġreplace Text _ to Editable (){ ĊĠĠĠĠĠĠĠ Ġval Ġtext Ġ= Ġ" replace Text Ġto Ġnew " ĊĠĠĠĠĠĠĠ Ġpage . edit Text Content Desc ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. replace Text ( text ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. has Text ( text ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġreplace Text _ to Un editable Object (){ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . button . with Timeout ( 1 0 0 ). replace Text (" some Ġnew Ġtext ") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġreplace Text _ to NotExist ed Object (){ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). replace Text (" some Ġnew Ġtext ") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// perform ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġperform _ exist ed Object (){ ĊĠĠĠĠĠĠĠ Ġpage . button . perform ({ Ġthis . click () Ġ}, Ġ" Click Ġon Ġbutton ") ĊĠĠĠĠĠĠĠ Ġpage . event Status . text Contains ( TestData Utils . getResource String ( R . string . button _ event _ click )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġperform _ not Exist ed Object (){ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . not Exist ed Object . with Timeout ( 1 0 0 ). perform ({ this . click ()}, Ġ" Click Ġon Ġbutton ") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// swipe ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġswipe Up Test (){ ĊĠĠĠĠĠĠĠ Ġpage . event Status . has Text ( getTarget String ( R . string . button _ text )) ĊĠĠĠĠĠĠĠ Ġpage . sw ip able ImageView . exists (). isEnabled (). swipe Up () ĊĠĠĠĠĠĠĠ Ġpage . event Status . text Contains ( Ui Elements Activity . Event . SW I PE _ UP . name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġswipe Down Test (){ ĊĠĠĠĠĠĠĠ Ġpage . event Status . has Text ( getTarget String ( R . string . button _ text )) ĊĠĠĠĠĠĠĠ Ġpage . sw ip able ImageView . exists (). swipe Down () ĊĠĠĠĠĠĠĠ Ġpage . event Status . text Contains ( Ui Elements Activity . Event . SW I PE _ DOWN . name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġswipe Right Test (){ ĊĠĠĠĠĠĠĠ Ġpage . event Status . has Text ( getTarget String ( R . string . button _ text )) ĊĠĠĠĠĠĠĠ Ġpage . sw ip able ImageView . exists (). swipe Right () ĊĠĠĠĠĠĠĠ Ġpage . event Status . text Contains ( Ui Elements Activity . Event . SW I PE _ RIGHT . name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġswipe Left Test (){ ĊĠĠĠĠĠĠĠ Ġpage . event Status . has Text ( getTarget String ( R . string . button _ text )) ĊĠĠĠĠĠĠĠ Ġpage . sw ip able ImageView . exists (). swipe Left () ĊĠĠĠĠĠĠĠ Ġpage . event Status . text Contains ( Ui Elements Activity . Event . SW I PE _ LEFT . name ) ĊĠĠĠ Ġ} Ċ }