package Ġcom . example . android . architecture . blueprint s . todo app . TestCase s Ċ Ċ import Ġandroid . view . Gravity Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġandroidx . test . espress o . Esp ress o Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . contrib . Drawer Actions Ċ import Ġandroidx . test . espress o . contrib . Drawer Matchers . is Closed Ċ import Ġandroidx . test . espress o . contrib . Navigation View Actions Ċ import Ġandroidx . test . espress o . contrib . RecyclerView Actions Ċ import Ġandroidx . test . espress o . matcher . View Matchers .* Ċ import Ġandroidx . test . ext . junit . rules . Activity Scenario Rule Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġcom . example . android . architecture . blueprint s . todo app . R Ċ import Ġcom . example . android . architecture . blueprint s . todo app . TestUtil . IdList Ċ import Ġcom . example . android . architecture . blueprint s . todo app . TestUtil . test Util Ċ import Ġcom . example . android . architecture . blueprint s . todo app . tasks . Tasks Activity Ċ import Ġorg . junit .* Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠStatistics _ Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġactivity Rule Ġ= ĠActivity Scenario Rule ( Tasks Activity :: class . java ) ĊĊĠĠĠ Ġval Ġid List Ġ= ĠId List () ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstatistics _ percentage _ with _ all _ active _ test (){ ĊĠĠĠĠĠĠĠ Ġ// Prepare Ġtwo Ġtasks Ġfor Ġtesting Ġdata ĊĠĠĠĠĠĠĠ Ġval Ġdata Count Ġ= Ġ 2 ĊĠĠĠĠĠĠĠ Ġval Ġutil Ġ= Ġtest Util () ĊĠĠĠĠĠĠĠ Ġutil . prepare Tasks By Customer ( data Count ) ĊĊĠĠĠĠĠĠĠ Ġ// é» ŀ éģ¸ navigation Ġdrawer ĊĠĠĠĠĠĠĠ Ġon View ( id List . drawer _ layout ). check ( matches ( is Closed ( Gravity . LEFT ))). perform ( Drawer Actions . open ()) ĊĠĠĠĠĠĠĠ Ġ// é» ŀ éģ¸ Statistics ĊĠĠĠĠĠĠĠ Ġon View ( id List . nav _ view ). perform ( Navigation View Actions . navigate To ( R . id . statistics _ fragment _ dest )) ĊĊĠĠĠĠĠĠĠ Ġ// Verify Ġthe Ġstatistics Ġdescription ĊĠĠĠĠĠĠĠ Ġon View ( id List . stats _ active _ text ). check ( matches ( with Text (" Active Ġtasks : Ġ 1 0 0 . 0 % "))) ĊĠĠĠĠĠĠĠ Ġon View ( id List . stats _ completed _ text ). check ( matches ( with Text (" Completed Ġtasks : Ġ 0 . 0 % "))) ĊĊĠĠĠĠĠĠĠ Ġ// Delete Ġtesting Ġtask ĊĠĠĠĠĠĠĠ Ġutil . delete Tasks By Customer ( data Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstatistics _ percentage _ with _ mid _ range _ test (){ ĊĊĠĠĠĠĠĠĠ Ġ// Prepare Ġtwo Ġtasks Ġfor Ġtesting Ġdata ĊĠĠĠĠĠĠĠ Ġval Ġdata Count Ġ= Ġ 2 ĊĠĠĠĠĠĠĠ Ġval Ġutil Ġ= Ġtest Util () ĊĠĠĠĠĠĠĠ Ġutil . prepare Tasks By Customer ( data Count ) ĊĊĊĠĠĠĠĠĠĠ Ġ// Click Ġone Ġtask 's Ġcheckbox Ġas Ġcomplete ĊĠĠĠĠĠĠĠ Ġon View ( id List . task _ list Ġ). perform ( RecyclerView Actions . action On Item At Position < RecyclerView . ViewHolder >( 0 Ġ, Ġutil . click Item With Id ( R . id . complete _ checkbox ))) ĊĊĠĠĠĠĠĠĠ Ġ// é» ŀ éģ¸ navigation Ġdrawer ĊĠĠĠĠĠĠĠ Ġon View ( id List . drawer _ layout Ġ). check ( matches ( is Closed ( Gravity . LEFT ))). perform ( Drawer Actions . open ()) ĊĠĠĠĠĠĠĠ Ġ// é» ŀ éģ¸ Statistics ĊĠĠĠĠĠĠĠ Ġon View ( id List . nav _ view Ġ). perform ( Navigation View Actions . navigate To ( R . id . statistics _ fragment _ dest )) ĊĊĠĠĠĠĠĠĠ Ġ// Verify Ġthe Ġstatistics Ġdescription ĊĠĠĠĠĠĠĠ Ġon View ( id List . stats _ active _ text Ġ). check ( matches ( with Text (" Active Ġtasks : Ġ 5 0 . 0 % "))) ĊĠĠĠĠĠĠĠ Ġon View ( id List . stats _ completed _ text Ġ). check ( matches ( with Text (" Completed Ġtasks : Ġ 5 0 . 0 % "))) ĊĊĠĠĠĠĠĠĠ Ġ// éĤ Ħ åİŁ ĊĠĠĠĠĠĠĠ ĠE sp ress o . press Back () ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 5 0 0 ) ĊĠĠĠĠĠĠĠ Ġon View ( id List . task _ list ). perform ( RecyclerView Actions . action On Item At Position < RecyclerView . ViewHolder >( 0 Ġ, Ġutil . click Item With Id ( R . id . complete _ checkbox ))) ĊĊĠĠĠĠĠĠĠ Ġ// Delete Ġtesting Ġtask ĊĠĠĠĠĠĠĠ Ġutil . delete Tasks By Customer ( data Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstatistics _ percentage _ with _ all _ complete _ test (){ ĊĠĠĠĠĠĠĠ Ġ// Prepare Ġtwo Ġtasks Ġfor Ġtesting Ġdata ĊĠĠĠĠĠĠĠ Ġval Ġdata Count Ġ= Ġ 2 ĊĠĠĠĠĠĠĠ Ġval Ġutil Ġ= Ġtest Util () ĊĠĠĠĠĠĠĠ Ġutil . prepare Tasks By Customer ( data Count ) ĊĊĠĠĠĠĠĠĠ Ġ// Click Ġall Ġtasks ' Ġcheckbox Ġas Ġcomplete ĊĠĠĠĠĠĠĠ Ġon View ( id List . task _ list ). perform ( RecyclerView Actions . action On Item At Position < RecyclerView . ViewHolder >( 0 Ġ, Ġutil . click Item With Id ( R . id . complete _ checkbox ))) ĊĠĠĠĠĠĠĠ Ġon View ( id List . task _ list ). perform ( RecyclerView Actions . action On Item At Position < RecyclerView . ViewHolder >( 1 Ġ, Ġutil . click Item With Id ( R . id . complete _ checkbox ))) ĊĊĠĠĠĠĠĠĠ Ġ// é» ŀ éģ¸ navigation Ġdrawer ĊĠĠĠĠĠĠĠ Ġon View ( id List . drawer _ layout ). check ( matches ( is Closed ( Gravity . LEFT ))). perform ( Drawer Actions . open ()) ĊĠĠĠĠĠĠĠ Ġ// é» ŀ éģ¸ Statistics ĊĠĠĠĠĠĠĠ Ġon View ( id List . nav _ view ). perform ( Navigation View Actions . navigate To ( R . id . statistics _ fragment _ dest )) ĊĊĠĠĠĠĠĠĠ Ġ// Verify Ġthe Ġstatistics Ġdescription ĊĠĠĠĠĠĠĠ Ġon View ( id List . stats _ active _ text ). check ( matches ( with Text (" Active Ġtasks : Ġ 0 . 0 % "))) ĊĠĠĠĠĠĠĠ Ġon View ( id List . stats _ completed _ text ). check ( matches ( with Text (" Completed Ġtasks : Ġ 1 0 0 . 0 % "))) ĊĊĠĠĠĠĠĠĠ Ġ// éĤ Ħ åİŁ ĊĠĠĠĠĠĠĠ ĠE sp ress o . press Back () ĊĠĠĠĠĠĠĠ ĠThread . sleep ( 5 0 0 ) ĊĠĠĠĠĠĠĠ Ġon View ( id List . task _ list ). perform ( RecyclerView Actions . action On Item At Position < RecyclerView . ViewHolder >( 0 Ġ, Ġutil . click Item With Id ( R . id . complete _ checkbox ))) ĊĠĠĠĠĠĠĠ Ġon View ( id List . task _ list ). perform ( RecyclerView Actions . action On Item At Position < RecyclerView . ViewHolder >( 1 Ġ, Ġutil . click Item With Id ( R . id . complete _ checkbox ))) ĊĊĠĠĠĠĠĠĠ Ġ// Delete Ġtesting Ġtask ĊĠĠĠĠĠĠĠ Ġutil . delete Tasks By Customer ( data Count ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġstatistics _ percentage _ with _ empty _ task _ test (){ ĊĠĠĠĠĠĠĠ Ġ// é» ŀ éģ¸ navigation Ġdrawer ĊĠĠĠĠĠĠĠ Ġon View ( id List . drawer _ layout ). check ( matches ( is Closed ( Gravity . LEFT ))). perform ( Drawer Actions . open ()) ĊĠĠĠĠĠĠĠ Ġ// é» ŀ éģ¸ Statistics ĊĠĠĠĠĠĠĠ Ġon View ( id List . nav _ view ). perform ( Navigation View Actions . navigate To ( R . id . statistics _ fragment _ dest )) ĊĠĠĠĠĠĠĠ Ġ// Verify Ġthe Ġview ĊĠĠĠĠĠĠĠ Ġon View ( with Text (" You Ġhave Ġno Ġtasks . ")). check ( matches ( is Displayed ())) ĊĠĠĠ Ġ} ĊĊĊ Ċ }