package Ġcz . font an . gom oku _ gui . espress o Ċ Ċ import Ġandroid . view . Input Device Ċ import Ġandroid . view . Motion Event Ċ import Ġandroidx . test . espress o . Esp ress o Ċ import Ġandroidx . test . espress o . Id ling Registry Ċ import Ġandroidx . test . espress o . View Action Ċ import Ġandroidx . test . espress o . action . General Click Action Ċ import Ġandroidx . test . espress o . action . Press Ċ import Ġandroidx . test . espress o . action . Tap Ċ import Ġandroidx . test . espress o . action . View Actions . click Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers Ċ import Ġandroidx . test . ext . junit . rules . Activity Scenario Rule Ċ import Ġcz . font an . gom oku _ gui . Count ing Id ling Resource Singleton Ċ import Ġcz . font an . gom oku _ gui . MainActivity Ċ import Ġcz . font an . gom oku _ gui . R Ċ import Ġorg . hamcrest . Core Matchers . not Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ Ċ class ĠMainActivity UIT est Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġactivity Rule : ĠActivity Scenario Rule < MainActivity > Ġ= ĊĠĠĠĠĠĠĠ ĠActivity Scenario Rule ( MainActivity :: class . java ) ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġregister Id ling Resource () Ġ{ ĊĠĠĠĠĠĠĠ ĠId ling Registry . getInstance () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. register ( Count ing Id ling Resource Singleton . count ing Id ling Resource ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun Ġunregister Id ling Resource () Ġ{ ĊĠĠĠĠĠĠĠ ĠId ling Registry . getInstance () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. unregister ( Count ing Id ling Resource Singleton . count ing Id ling Resource ) ĊĠĠĠ Ġ} ĊĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnew Game _ MainActivity () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠNew Game ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ new )). perform ( click ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ Ġ// ĠCheck ĠButtons ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ play )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ stop )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ redo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ undo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġplay _ MainActivity () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠNew Game Ġclicked ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ new )). perform ( click ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ Ġ// ĠPlay Ġclicked ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ play )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ// ĠCheck ĠButtons ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ play )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ stop )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ redo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ undo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ new )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠ Ġ// ĠUndo Ġclicked ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ undo )). perform ( click ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ redo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĊĠĠĠĠĠĠĠ Ġ// ĠPlay Ġclicked ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 0 .. 1 0 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ play )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ// ĠUndo Ġclicked ĊĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 0 .. 1 0 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ undo )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())). perform ( click ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ redo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ undo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ new )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmouse Click _ MainActivity () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠNew Game Ġclicked ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ new )). perform ( click ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ Ġ// ĠMouse Ġclicked ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . board _ view )). perform ( click XY ( 5 0 f , Ġ 5 0 f )) ĊĠĠĠĠĠĠĠ Ġ// ĠCheck ĠButtons ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ play )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ stop )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ redo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ undo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ new )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠ Ġ// ĠUndo Ġclicked ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ undo )). perform ( click ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ redo )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĊĠĠĠĠĠĠĠ ĠE sp ress o . on View ( View Matchers . with Id ( R . id . button _ new )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( View Matchers . isEnabled ())) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( not ( View Matchers . isEnabled ()))) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġclick XY ( pct X : ĠFloat , Ġp ct Y : ĠFloat ): ĠView Action Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠGeneral Click Action ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠT ap . SINGLE , Ġ{ Ġview Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġscreen Pos Ġ= ĠInt Array ( 2 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġview . getLocation On Screen ( screen Pos ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġscreen X : ĠFloat Ġ= Ġscreen Pos [ 0 ] Ġ+ Ġview . width Ġ* Ġp ct X Ġ/ Ġ 1 0 0 f ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġscreen Y : ĠFloat Ġ= Ġscreen Pos [ 1 ] Ġ+ Ġview . height Ġ* Ġp ct Y Ġ/ Ġ 1 0 0 f ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfloat ArrayOf ( screen X , Ġscreen Y ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPress . F ING ER , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInput Device . SOURCE _ MOUSE , ĊĠĠĠĠĠĠĠĠĠĠĠ ĠMotion Event . BUTTON _ PRIMARY ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} Ċ }