package Ġcom . ati ur in . sample app . tests . espress o Ċ Ċ import Ġandroidx . test . espress o . matcher . View Matchers .* Ċ import Ġandroidx . test . rule . Activity Test Rule Ċ import Ġcom . ati ur in . sample app . My Application Ċ import Ġcom . ati ur in . sample app . R Ċ import Ġcom . ati ur in . sample app . activity . MainActivity Ċ import Ġcom . ati ur in . sample app . data . repositories . CONTACT S Ċ import Ġcom . ati ur in . sample app . data . repositories . Contact Re posit ot y Ċ import Ġcom . ati ur in . sample app . framework . Log Ċ import Ġcom . ati ur in . sample app . framework . utils . Assert Utils Ċ import Ġcom . ati ur in . sample app . pages . Chat Page Ċ import Ġcom . ati ur in . sample app . pages . Friends List Page Ċ import Ġcom . ati ur in . sample app . tests . Base Test Ċ import Ġcom . ati ur in . ul tron . core . espress o . recyclerview . with RecyclerView Ċ import Ġcom . ati ur in . ul tron . extensions . has Text Ċ import Ġcom . ati ur in . ul tron . extensions . is Displayed Ċ import Ġcom . ati ur in . ul tron . extensions . with Timeout Ċ import Ġcom . ati ur in . ul tron . test lifecycle . set upt e ardown . SetUp Ċ import Ġcom . ati ur in . ul tron . test lifecycle . set upt e ardown . SetUp Rule Ċ import Ġcom . ati ur in . ul tron . test lifecycle . set upt e ardown . Tear Down Ċ import Ġcom . ati ur in . ul tron . test lifecycle . set upt e ardown . Tear Down Rule Ċ import Ġorg . hamcrest . Matchers . all Of Ċ import Ġorg . hamcrest . Matchers . contains String Ċ import Ġorg . junit . Assert Ċ import Ġorg . junit . Test Ċ Ċ class ĠRecyclerView Test Ġ: ĠBaseTest () Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠCUSTOM _ TIMEOUT Ġ= Ġ" CUSTOM _ TIMEOUT " ĊĠĠĠĠĠĠĠ Ġval Ġnot Exist Item Matcher Ġ= Ġhas Desc endant ( with Text (" z xcb m zx mb c ")) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval ĠsetUp Rule Ġ= ĠSet Up Rule (). add ( CUSTOM _ TIMEOUT ) Ġ{ ĊĠĠĠĠĠĠĠ ĠMy Application . CONTACT S _ LOADING _ TIMEOUT _ MS Ġ= Ġ 6 _ 0 0 0 L ĊĠĠĠ Ġ} ĊĠĠĠ Ġprivate Ġval ĠtearDown Rule Ġ= ĠT ear Down Rule (). add ( CUSTOM _ TIMEOUT ) Ġ{ ĊĠĠĠĠĠĠĠ ĠMy Application . CONTACT S _ LOADING _ TIMEOUT _ MS Ġ= Ġ 5 0 0 L ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġrule Sequence . add ( setUp Rule , ĠtearDown Rule ). add Last ( Activity Test Rule ( MainActivity :: class . java )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġval Ġpage Ġ= ĠF riends List Page ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġchild Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġwith RecyclerView ( R . id . recycler _ friends ). item ( 0 ). getChild ( with Id ( R . id . tv _ status )). has Text ( Contact Re posit ot y . getFirst (). status ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest Displayed Item Positions () Ġ{ ĊĠĠĠĠĠĠĠ Ġfor Ġ( index Ġin Ġ 0 .. 3 ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpage . recycler . item ( index ). assert Matches ( has Desc endant ( with Text ( CONTACT S [ index ]. name ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Matches ( has Desc endant ( with Text ( CONTACT S [ index ]. status ))). is Displayed () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget RecyclerView Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġview Ġ= Ġpage . recycler . get RecyclerView List () ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( view ) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( Visibility . VISIBLE . value , Ġview . visibility ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġscroll To Item Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontact Ġ= ĠCONT ACT S [ CONTACT S . size Ġ- Ġ 1 ] ĊĠĠĠĠĠĠĠ Ġval Ġitem Ġ= Ġpage . get ListItem ( contact . name ) ĊĠĠĠĠĠĠĠ Ġitem . is Displayed () ĊĠĠĠĠĠĠĠ Ġitem . name . has Text ( contact . name ) ĊĠĠĠĠĠĠĠ Ġitem . status . has Text ( contact . status ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwrong Child () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontact Ġ= ĠCONT ACT S [ CONTACT S . size Ġ- Ġ 1 ] ĊĠĠĠĠĠĠĠ Ġval Ġwrong Contact Ġ= ĠCONT ACT S [ CONTACT S . size Ġ- Ġ 2 ] ĊĠĠĠĠĠĠĠ Ġval Ġitem Ġ= Ġpage . get ListItem ( contact . name ) ĊĠĠĠĠĠĠĠ Ġitem . is Displayed () ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġitem . name . with Timeout ( 1 0 0 ). has Text ( wrong Contact . name ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġre cyclerView Item Class Test () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġcontact Ġ= ĠCONT ACT S [ 1 ] ĊĠĠĠĠĠĠĠ Ġwith ( page . get ListItem ( contact . name )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . is Displayed (). is Clickable () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . name . is Displayed (). isEnabled (). has Text ( contact . name ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . status . is Displayed (). isEnabled (). has Text ( contact . status ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġscroll To Last Item () Ġ{ ĊĠĠĠĠĠĠĠ Ġwith RecyclerView ( R . id . recycler _ friends ). item ( CONTACT S . size Ġ- Ġ 1 ). is Displayed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġscroll To Last With Matcher () Ġ{ ĊĠĠĠĠĠĠĠ Ġwith RecyclerView ( R . id . recycler _ friends ). item ( has Desc endant ( with Text (" Friend 1 4 ")) ). is Displayed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget NotExist ed Recycler Item With Position () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpage . recycler . item ( 1 0 0 ). with Timeout ( 1 0 0 ). is Displayed () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġassert List Size () Ġ{ ĊĠĠĠĠĠĠĠ Ġpage . recycler . assert Size ( CONTACT S . size ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġre cyclerView _ not Exist () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwith RecyclerView ( with Text (" Not Ġexisted Ġre cycler ")). with Timeout ( 1 0 0 ). is Displayed () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġitem _ not Exist () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpage . recycler . item ( with Text (" Not Ġexisted Ġitem "), Ġfalse ). with Timeout ( 1 0 0 ). is Displayed () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ SetUp ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġ@ Tear Down ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġfun Ġdefault Timeout On Item Waiting () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . recycler . item ( 1 0 ). is Displayed () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ SetUp ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġ@ Tear Down ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġfun Ġcustom Timeout On Item Waiting () Ġ{ ĊĠĠĠĠĠĠĠ Ġwith RecyclerView ( R . id . recycler _ friends , Ġ 8 0 0 0 ). item ( 1 0 ). is Displayed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ SetUp ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġ@ Tear Down ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġfun Ġitem _ auto Scroll _ False _ item _ Not Loaded () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . recycler . item ( 1 0 , Ġfalse ). is Displayed () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ SetUp ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġ@ Tear Down ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġfun Ġitem _ auto Scroll _ False _ scroll _ Force () Ġ{ ĊĠĠĠĠĠĠĠ Ġwith RecyclerView ( R . id . recycler _ friends , Ġ 8 _ 0 0 0 ). item ( 1 0 , Ġfalse ). scrollTo Item (). is Displayed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġitem Matcher _ auto Scroll _ false _ item Not Displayed () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpage . recycler . item ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhas Desc endant ( with Text (" Friend 1 4 ")), Ġfalse ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ). is Displayed () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġitem Matcher _ auto Scroll _ false _ scroll _ force () Ġ{ ĊĠĠĠĠĠĠĠ Ġpage . recycler . item ( has Desc endant ( with Text (" Friend 1 4 ")), Ġfalse ). scrollTo Item (). is Displayed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ SetUp ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġ@ Tear Down ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġfun Ġitem Matcher _ auto Scroll _ false () Ġ{ ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpage . recycler . item ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhas Desc endant ( with Text (" Friend 1 4 ")), Ġfalse ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ). scrollTo Item (). is Displayed () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġ@ SetUp ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġ@ Tear Down ( CUSTOM _ TIMEOUT ) ĊĠĠĠ Ġfun Ġitem Matcher _ auto Scroll _ true _ custom _ timeout () Ġ{ ĊĠĠĠĠĠĠĠ Ġwith RecyclerView ( R . id . recycler _ friends , Ġ 1 0 _ 0 0 0 ). item ( has Desc endant ( with Text (" Friend 1 4 ")) ). is Displayed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget ViewHolder () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġposition Ġ= ĠCONT ACT S . size Ġ- Ġ 1 ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġposition , ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpage . recycler . item ( has Desc endant ( with Text ( CONTACT S [ position ]. name ))) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. get ViewHolder () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ? . layout Position ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtransfer From Generic To Subclass (){ ĊĠĠĠĠĠĠĠ Ġval Ġposition Ġ= Ġ 5 ĊĠĠĠĠĠĠĠ Ġpage . recycler . getItem < Friends List Page . Friend Recycler Item >( position ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. status . has Text ( CONTACT S [ position ]. status ). is Displayed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget ViewHolder List (){ ĊĠĠĠĠĠĠĠ Ġpage . recycler . wait Items Loaded () ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( page . recycler . get ViewHolder List ( has Desc endant ( with Id ( R . id . tv _ name ))). isNotEmpty ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwait Loaded _ of Already Loaded List (){ ĊĠĠĠĠĠĠĠ Ġpage . recycler . wait Items Loaded () ĊĠĠĠĠĠĠĠ Ġpage . recycler . wait Items Loaded () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġwait Loaded _ all Items Loaded (){ ĊĠĠĠĠĠĠĠ Ġval Ġcount Ġ= Ġpage . recycler . wait Items Loaded (). getSize () ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( CONTACT S . size , Ġcount ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetLast Item (){ ĊĠĠĠĠĠĠĠ Ġpage . recycler . last Item (). is Displayed (). click () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetLast Item With Custom Type (){ ĊĠĠĠĠĠĠĠ Ġpage . recycler . getLast Item < Friends List Page . Friend Recycler Item >(). name . has Text ( Contact Re posit ot y . getLast (). name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġperf Scroll (){ ĊĠĠĠĠĠĠĠ Ġpage . recycler . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġfor Ġ( i Ġin Ġ 0 Ġ.. 1 0 ){ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġlast Item (). is Displayed () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfirst Item (). is Displayed () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget ViewHolder At Position _ out Of Visible List (){ ĊĠĠĠĠĠĠĠ ĠAssert . assertNull ( page . recycler . wait Items Loaded (). get ViewHolder At Position ( 1 5 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget ViewHolder At Position _ in Visible List (){ ĊĠĠĠĠĠĠĠ ĠAssert . assertNotNull ( page . recycler . wait Items Loaded (). get ViewHolder At Position ( 2 )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget Items Adapter Position List (){ ĊĠĠĠĠĠĠĠ Ġpage . recycler . wait Items Loaded () ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String (" Friend ")) )) ĊĠĠĠĠĠĠĠ ĠAssert . assertEquals ( 0 , Ġpage . recycler . get ViewHolder List ( matcher ). size ) ĊĠĠĠĠĠĠĠ ĠAssert . assertTrue ( page . recycler . getItems Adapter Position List ( matcher ). isNotEmpty ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġfirst Item Matched _ exist Item (){ ĊĠĠĠĠĠĠĠ Ġval Ġpattern Ġ= Ġ" Friend " ĊĠĠĠĠĠĠĠ Ġval Ġexpected Contacts Ġ= ĠCONT ACT S . filter Ġ{ Ġit . name . contains ( pattern ) Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String ( pattern )))) ĊĊĠĠĠĠĠĠĠ Ġpage . recycler . first Item Matched ( matcher ). is Displayed (). click () ĊĠĠĠĠĠĠĠ ĠChat Page . assert Toolbar Title ( expected Contacts . first (). name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġitem Matched _ exist Item (){ ĊĠĠĠĠĠĠĠ Ġval Ġpattern Ġ= Ġ" Friend " ĊĠĠĠĠĠĠĠ Ġval Ġexpected Contacts Ġ= ĠCONT ACT S . filter Ġ{ Ġit . name . contains ( pattern ) Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String ( pattern )))) ĊĊĠĠĠĠĠĠĠ Ġpage . recycler . item Matched ( matcher , Ġ 1 ). is Displayed (). click () ĊĠĠĠĠĠĠĠ ĠChat Page . assert Toolbar Title ( expected Contacts [ 1 ]. name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġitem Matched _ not Exist Item (){ ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String (" Friend ")) )) ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . recycler . with Timeout ( 1 0 0 0 ). item Matched ( matcher , Ġ 9 9 ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġlast Item Matched _ exist Item (){ ĊĠĠĠĠĠĠĠ Ġval Ġpattern Ġ= Ġ" Friend " ĊĠĠĠĠĠĠĠ Ġval Ġexpected Contacts Ġ= ĠCONT ACT S . filter Ġ{ Ġit . name . contains ( pattern ) Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String ( pattern )))) ĊĊĠĠĠĠĠĠĠ Ġpage . recycler . item Matched ( matcher , Ġexpected Contacts . last Index ). is Displayed (). click () ĊĠĠĠĠĠĠĠ ĠChat Page . assert Toolbar Title ( expected Contacts . last (). name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġget First Item Matched _ exist Item (){ ĊĠĠĠĠĠĠĠ Ġval Ġpattern Ġ= Ġ" Friend " ĊĠĠĠĠĠĠĠ Ġval Ġexpected Contact Ġ= ĠCONT ACT S . filter Ġ{ Ġit . name . contains ( pattern ) Ġ}. first () ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String ( pattern )))) ĊĊĠĠĠĠĠĠĠ Ġpage . recycler . getFirst Item Matched < Friends List Page . Friend Recycler Item >( matcher ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname . is Displayed (). has Text ( expected Contact . name ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstatus . has Text ( expected Contact . status ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclick () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠChat Page . assert Toolbar Title ( expected Contact . name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetItem Matched _ exist Item (){ ĊĠĠĠĠĠĠĠ Ġval Ġpattern Ġ= Ġ" Friend " ĊĠĠĠĠĠĠĠ Ġval Ġexpected Contact Ġ= ĠCONT ACT S . filter Ġ{ Ġit . name . contains ( pattern ) Ġ} [ 1 ] ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String ( pattern )))) ĊĊĠĠĠĠĠĠĠ Ġpage . recycler . getItem Matched < Friends List Page . Friend Recycler Item >( matcher , Ġ 1 ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname . is Displayed (). has Text ( expected Contact . name ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstatus . has Text ( expected Contact . status ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclick () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠChat Page . assert Toolbar Title ( expected Contact . name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetItem Matched _ not Exist Item (){ ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String (" Friend ")) )) ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . recycler . with Timeout ( 1 0 0 0 ). getItem Matched < Friends List Page . Friend Recycler Item >( matcher , Ġ 9 9 ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun ĠgetLast Item Matched _ exist Item (){ ĊĠĠĠĠĠĠĠ Ġval Ġpattern Ġ= Ġ" Friend " ĊĠĠĠĠĠĠĠ Ġval Ġexpected Contacts Ġ= ĠCONT ACT S . filter Ġ{ Ġit . name . contains ( pattern ) Ġ} ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String ( pattern )))) ĊĊĠĠĠĠĠĠĠ Ġpage . recycler . getItem Matched < Friends List Page . Friend Recycler Item >( matcher , Ġexpected Contacts . last Index ). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġname . is Displayed (). has Text ( expected Contacts . last (). name ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġstatus . has Text ( expected Contacts . last (). status ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġclick () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ ĠChat Page . assert Toolbar Title ( expected Contacts . last (). name ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġassert Item NotExist _ not Exist Item (){ ĊĠĠĠĠĠĠĠ Ġpage . recycler . assert Item NotExist ( not Exist Item Matcher , Ġ 2 0 0 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġassert Item NotExist _ exist Item (){ ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String ( CONTACT S . first (). name )))) ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . recycler . assert Item NotExist ( matcher , Ġ 2 0 0 0 ) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġassert Item NotExist Immediate ly _ not Exist Item (){ ĊĠĠĠĠĠĠĠ Ġpage . recycler . assert Item NotExist Immediate ly ( not Exist Item Matcher , Ġ 2 0 0 0 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġassert Item NotExist Immediate ly _ exist Item (){ ĊĠĠĠĠĠĠĠ Ġpage . recycler . wait Items Loaded () ĊĠĠĠĠĠĠĠ Ġval Ġmatcher Ġ= Ġhas Desc endant ( all Of ( with Id ( R . id . tv _ name ), Ġwith Text ( contains String ( CONTACT S . first (). name )))) ĊĠĠĠĠĠĠĠ ĠAssert Utils . assert Exception Ġ{ Ġpage . recycler . assert Item NotExist Immediate ly ( matcher , Ġ 2 0 0 0 ) Ġ} ĊĠĠĠ Ġ} Ċ } Ċ