package Ġcom . tot em soft . k utils Ċ Ċ import Ġandroid . support . test . espress o . Esp ress o . on View Ċ import Ġandroid . support . test . espress o . action . View Actions . click Ċ import Ġandroid . support . test . rule . Activity Test Rule Ċ import Ġandroid . support . test . runner . Android JUnit 4 Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġandroid . support . test . espress o . matcher . Root Matchers . is Dialog Ċ import Ġandroid . support . test . espress o . assertion . View Assertions . matches Ċ import Ġandroid . support . test . espress o . matcher . View Matchers .* Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠDialog Test Ġ{ ĊĊĠĠĠ Ġ@ get : ĠRule ĊĠĠĠ Ġval Ġactivity Rule Ġ= ĠActivity Test Rule < MainActivity >( MainActivity :: class . java ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġview ShouldBe Visible () Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . button Show Error Dialog )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġon View ( with ResourceName (" alert Title ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. in Root ( is Dialog ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Text (" Error "))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĊĠĠĠĠĠĠĠ Ġon View ( with ResourceName (" message ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. in Root ( is Dialog ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Text (" Some Ġerror Ġmessage ... "))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĊĠĠĠĠĠĠĠ Ġon View ( with ResourceName (" button 1 ")) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. in Root ( is Dialog ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( with Text ( android . R . string . ok ))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} Ċ } Ċ