package Ġcom . genes ys . cloud . messenger . uit est . page Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġandroidx . test . uia utom ator . Ui Device Ċ import Ġandroidx . test . uia utom ator . Ui Selector Ċ import Ġorg . await ility . Await ility Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ class ĠMess enger Page ( activity : ĠActivity ) Ġ: ĠBase Page ( activity ) Ġ{ ĊĊĠĠĠ Ġval Ġtitle Ġ= Ġ" Web ĠMessaging ĠTest bed " ĊĠĠĠ Ġval Ġsend Text Ġ= Ġ" Send " ĊĠĠĠ Ġval Ġbutton Class Ġ= Ġ" android . widget . Button " ĊĠĠĠ Ġval Ġcommand Class Ġ= Ġ" android . widget . EditText " ĊĠĠĠ Ġval Ġresponse Class Ġ= Ġ" android . widget . ScrollView " ĊĊĠĠĠ Ġ// ĠWait Ġuntil Ġandroid Ġcompose Ġprototype Ġbegins ĊĠĠĠ Ġfun Ġverify Page Is Visible ( wait Time : ĠLong Ġ= Ġ 2 0 ) Ġ{ ĊĠĠĠĠĠĠĠ ĠwaitFor Element With UI Autom ator ( title , Ġwait Time ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠSend Ġa Ġcommand Ġin Ġcommand Ġfield ĊĠĠĠ Ġfun Ġenter Command ( command : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġm Device Ġ= ĠUi Device . getInstance ( Instrumentation Registry . get Instrumentation ()) ĊĠĠĠĠĠĠĠ Ġval Ġcommand Box Ġ= Ġm Device . find Object ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠUi Selector (). className ( command Class ). index ( 2 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġcommand Box . click () ĊĠĠĠĠĠĠĠ Ġcommand Box . clear TextField () ĊĠĠĠĠĠĠĠ Ġcommand Box . legacy SetText ( command ) ĊĠĠĠĠĠĠĠ Ġval Ġsend Button Ġ= Ġm Device . find Object ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠUi Selector (). text ( send Text ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġsend Button . click () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠGrab Ġthe Ġclient Ġresponse Ġin Ġclient Ġfield ĊĠĠĠ Ġfun ĠgetClient Response (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġm Device Ġ= ĠUi Device . getInstance ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠInstrument ation Registry . get Instrumentation () ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġval Ġcommand Box Ġ= Ġm Device . find Object ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠUi Selector () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. className ( command Class ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. index ( 3 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġreturn Ġcommand Box . getText () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠWait Ġfor Ġclient Ġto Ġreturn Ġproper Ġresponse ĊĠĠĠ Ġfun ĠwaitFor Pro per Response ( response : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ ĠAwait ility . await (). at Most ( wait Time , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. until Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġget Full Response (). contains ( response , Ġignore Case Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠWait Ġfor Ġclient Ġto Ġbe Ġconnected ĊĠĠĠ Ġfun ĠwaitFor Connected () Ġ{ ĊĠĠĠĠĠĠĠ ĠAwait ility . await (). at Most ( wait Time , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. until Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠgetClient Response (). contains (" Connected ", Ġignore Case Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠWait Ġfor Ġclient Ġto Ġbe Ġclosed ĊĠĠĠ Ġfun ĠwaitFor Closed () Ġ{ ĊĠĠĠĠĠĠĠ ĠAwait ility . await (). at Most ( wait Time , ĠTimeUnit . SECONDS ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. until Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠgetClient Response (). contains (" Closed ", Ġignore Case Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠGet Ġtext Ġfrom Ġresponse Ġfield ĊĠĠĠ Ġfun Ġget Full Response (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġm Device Ġ= ĠUi Device . getInstance ( Instrumentation Registry . get Instrumentation ()) ĊĠĠĠĠĠĠĠ Ġval Ġresponse Box Ġ= Ġm Device . find Object ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠUi Selector () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. className ( response Class ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. index ( 4 ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġreturn Ġresponse Box . getText () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠVerify Ġconfigured Ġfull Ġresponse ĊĠĠĠ Ġfun Ġcheck Configure Full Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġget Full Response () ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" 2 0 0 ", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain Ġ 2 0 0 ") ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains ("\" Connected \": Ġtrue ", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain Ġ\" Connected \": Ġtrue ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠVerify Ġresponse Ġfor Ġsending Ġa Ġmessage ĊĠĠĠ Ġfun Ġcheck Send Msg Full Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġget Full Response () ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" Message Updated ", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain ĠMessage Updated ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠVerify Ġresponse Ġfor Ġthe Ġping Ġcommand ĊĠĠĠ Ġfun Ġcheck Ping Full Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġget Full Response () ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains ("\" type \": Ġ\" response \"", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain Ġ\" Type \": Ġ\" response \" ") ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" 2 0 0 ", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain Ġ 2 0 0 ") ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains ("\" text \": Ġ\" ping \"", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain Ġ\" Text \": Ġ\" ping \" ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠVerify Ġresponse Ġfor Ġthe Ġhistory Ġcommand ĊĠĠĠ Ġfun Ġcheck History Full Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġget Full Response () ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" History F etched ", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain Ġ\" pageSize \": Ġ 1 ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġpull Attachment Id ( response : ĠString ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġstring 1 Ġ= Ġresponse . split (" =") ĊĠĠĠĠĠĠĠ Ġval Ġstring 2 Ġ= Ġstring 1 [ 1 ]. split (",") ĊĠĠĠĠĠĠĠ Ġreturn Ġstring 2 [ 0 ] ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠVerify Ġresponse Ġfor Ġthe Ġattach Ġcommand ĊĠĠĠ Ġfun Ġcheck Attach Full Response (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġget Full Response () ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" Attachment ", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain : ĠAttachment ") ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" fileName =", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain : Ġfilename =") ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" state = Uploaded ", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain : Ġstate = Uploaded ") ĊĠĠĠĠĠĠĠ Ġreturn Ġpull Attachment Id ( response ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// ĠVerify Ġresponse Ġfor Ġthe Ġdetach Ġcommand ĊĠĠĠ Ġfun Ġcheck Detach Full Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġget Full Response () ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" Attachment ", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain : ĠAttachment ") ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" fileName =", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain : Ġfilename =") ĊĠĠĠĠĠĠĠ Ġif Ġ(!( response . contains (" Deleted ", Ġignore Case Ġ= Ġtrue ))) ĠAssertionError (" Response Ġdoes Ġnot Ġcontain : ĠDeleted ") ĊĠĠĠ Ġ} Ċ } Ċ