@@ -15,16 +15,22 @@ import com.example.util.simpletimetracker.GoalsTestUtils.checkStatisticsPercent
1515import com.example.util.simpletimetracker.GoalsTestUtils.durationInSeconds
1616import com.example.util.simpletimetracker.GoalsTestUtils.getDailyCountGoal
1717import com.example.util.simpletimetracker.GoalsTestUtils.getDailyCountGoalCategory
18+ import com.example.util.simpletimetracker.GoalsTestUtils.getDailyCountGoalTag
1819import com.example.util.simpletimetracker.GoalsTestUtils.getDailyDurationGoal
1920import com.example.util.simpletimetracker.GoalsTestUtils.getDailyDurationGoalCategory
21+ import com.example.util.simpletimetracker.GoalsTestUtils.getDailyDurationGoalTag
2022import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyCountGoal
2123import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyCountGoalCategory
24+ import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyCountGoalTag
2225import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyDurationGoal
2326import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyDurationGoalCategory
27+ import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyDurationGoalTag
2428import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyCountGoal
2529import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyCountGoalCategory
30+ import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyCountGoalTag
2631import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyDurationGoal
2732import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyDurationGoalCategory
33+ import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyDurationGoalTag
2834import com.example.util.simpletimetracker.utils.BaseUiTest
2935import com.example.util.simpletimetracker.utils.NavUtils
3036import com.example.util.simpletimetracker.utils.checkViewIsDisplayed
@@ -646,6 +652,310 @@ class GoalsStatisticsTest : BaseUiTest() {
646652 checkNoStatisticsGoal(otherGoals)
647653 }
648654
655+ @Test
656+ fun dailyTagGoal () {
657+ val goal = getString(coreR.string.change_record_type_goal_time_hint).lowercase()
658+
659+ val goalTimeNotFinished = " goalTimeNotFinishedTag"
660+ val goalTimeFinished = " goalTimeFinishedTag"
661+ val goalCountNotFinished = " goalCountNotFinishedTag"
662+ val goalCountFinished = " goalCountFinishedTag"
663+ val otherGoals = " otherDailyTags"
664+
665+ // Activities
666+ testUtils.addActivity(goalTimeNotFinished.first())
667+ testUtils.addActivity(goalTimeNotFinished.second())
668+ testUtils.addActivity(goalTimeFinished.first())
669+ testUtils.addActivity(goalTimeFinished.second())
670+ testUtils.addActivity(goalCountNotFinished.first())
671+ testUtils.addActivity(goalCountNotFinished.second())
672+ testUtils.addActivity(goalCountFinished.first())
673+ testUtils.addActivity(goalCountFinished.second())
674+ testUtils.addActivity(otherGoals.first())
675+ testUtils.addActivity(otherGoals.second())
676+
677+ // Tags
678+ testUtils.addRecordTag(
679+ goalTimeNotFinished,
680+ typeName = goalTimeNotFinished.first(),
681+ goals = listOf (getDailyDurationGoalTag(8 * durationInSeconds)),
682+ )
683+ testUtils.addRecordTag(
684+ goalTimeFinished,
685+ typeName = goalTimeFinished.first(),
686+ goals = listOf (getDailyDurationGoalTag(2 * durationInSeconds)),
687+ )
688+ testUtils.addRecordTag(
689+ goalCountNotFinished,
690+ typeName = goalCountNotFinished.first(),
691+ goals = listOf (getDailyCountGoalTag(8 )),
692+ )
693+ testUtils.addRecordTag(
694+ goalCountFinished,
695+ typeName = goalCountFinished.first(),
696+ goals = listOf (getDailyCountGoalTag(3 )),
697+ )
698+ testUtils.addRecordTag(
699+ otherGoals,
700+ typeName = otherGoals.first(),
701+ goals = listOf (
702+ getWeeklyDurationGoalTag(durationInSeconds),
703+ getMonthlyCountGoalTag(1 ),
704+ ),
705+ )
706+
707+ // Records
708+ addRecords(testUtils, goalTimeNotFinished.first(), tagNames = listOf (goalTimeNotFinished))
709+ addRecords(testUtils, goalTimeNotFinished.second(), tagNames = listOf (goalTimeNotFinished))
710+ addRecords(testUtils, goalTimeFinished.first(), tagNames = listOf (goalTimeFinished))
711+ addRecords(testUtils, goalTimeFinished.second(), tagNames = listOf (goalTimeFinished))
712+
713+ addRecords(testUtils, goalCountNotFinished.first(), tagNames = listOf (goalCountNotFinished))
714+ addRecords(testUtils, goalCountNotFinished.second(), tagNames = listOf (goalCountNotFinished))
715+
716+ testUtils.addRecord(goalCountFinished.first(), tagNames = listOf (goalCountFinished))
717+ testUtils.addRecord(goalCountFinished.second(), tagNames = listOf (goalCountFinished))
718+ addRecords(testUtils, goalCountFinished.first(), tagNames = listOf (goalCountFinished))
719+
720+ addRecords(testUtils, otherGoals.first(), tagNames = listOf (otherGoals))
721+ addRecords(testUtils, otherGoals.second(), tagNames = listOf (otherGoals))
722+
723+ NavUtils .openStatisticsScreen()
724+ NavUtils .openFilter()
725+ clickOnViewWithText(coreR.string.record_tag_hint_short)
726+ pressBack()
727+
728+ // Goal time not finished
729+ scrollTo(goalTimeNotFinished)
730+ checkStatisticsGoal(goalTimeNotFinished, " 20$minuteString " , " $goal - 1$hourString 20$minuteString " )
731+ checkStatisticsPercent(goalTimeNotFinished, " 25%" )
732+ checkStatisticsMark(goalTimeNotFinished, isVisible = false )
733+
734+ // Goal time finished
735+ scrollTo(goalTimeFinished)
736+ checkStatisticsGoal(goalTimeFinished, " 20$minuteString " , " $goal - 20$minuteString " )
737+ checkStatisticsMark(goalTimeFinished, isVisible = true )
738+
739+ // Goal count not finished
740+ scrollTo(goalCountNotFinished)
741+ checkStatisticsGoal(goalCountNotFinished, " 2 Records" , " $goal - 8 Records" )
742+ checkStatisticsPercent(goalCountNotFinished, " 25%" )
743+ checkStatisticsMark(goalCountNotFinished, isVisible = false )
744+
745+ // Goal count finished
746+ scrollTo(goalCountFinished)
747+ checkStatisticsGoal(goalCountFinished, " 3 Records" , " $goal - 3 Records" )
748+ checkStatisticsMark(goalCountFinished, isVisible = true )
749+
750+ // Other goals
751+ scrollBottom()
752+ checkNoStatisticsGoal(otherGoals)
753+ }
754+
755+ @Test
756+ fun weeklyTagGoal () {
757+ val goal = getString(coreR.string.change_record_type_goal_time_hint).lowercase()
758+
759+ val goalTimeNotFinished = " goalTimeNotFinishedTag"
760+ val goalTimeFinished = " goalTimeFinishedTag"
761+ val goalCountNotFinished = " goalCountNotFinishedTag"
762+ val goalCountFinished = " goalCountFinishedTag"
763+ val otherGoals = " otherWeeklyTags"
764+
765+ // Activities
766+ testUtils.addActivity(goalTimeNotFinished.first())
767+ testUtils.addActivity(goalTimeNotFinished.second())
768+ testUtils.addActivity(goalTimeFinished.first())
769+ testUtils.addActivity(goalTimeFinished.second())
770+ testUtils.addActivity(goalCountNotFinished.first())
771+ testUtils.addActivity(goalCountNotFinished.second())
772+ testUtils.addActivity(goalCountFinished.first())
773+ testUtils.addActivity(goalCountFinished.second())
774+ testUtils.addActivity(otherGoals.first())
775+ testUtils.addActivity(otherGoals.second())
776+
777+ // Tags
778+ testUtils.addRecordTag(
779+ tagName = goalTimeNotFinished,
780+ typeName = goalTimeNotFinished.first(),
781+ goals = listOf (getWeeklyDurationGoalTag(8 * durationInSeconds)),
782+ )
783+ testUtils.addRecordTag(
784+ tagName = goalTimeFinished,
785+ typeName = goalTimeFinished.first(),
786+ goals = listOf (getWeeklyDurationGoalTag(2 * durationInSeconds)),
787+ )
788+ testUtils.addRecordTag(
789+ tagName = goalCountNotFinished,
790+ typeName = goalCountNotFinished.first(),
791+ goals = listOf (getWeeklyCountGoalTag(8 )),
792+ )
793+ testUtils.addRecordTag(
794+ tagName = goalCountFinished,
795+ typeName = goalCountFinished.first(),
796+ goals = listOf (getWeeklyCountGoalTag(3 )),
797+ )
798+ testUtils.addRecordTag(
799+ tagName = otherGoals,
800+ typeName = otherGoals.first(),
801+ goals = listOf (
802+ getDailyDurationGoalTag(durationInSeconds),
803+ getMonthlyCountGoalTag(1 ),
804+ ),
805+ )
806+
807+ // Records
808+ addRecords(testUtils, goalTimeNotFinished.first(), tagNames = listOf (goalTimeNotFinished))
809+ addRecords(testUtils, goalTimeNotFinished.second(), tagNames = listOf (goalTimeNotFinished))
810+ addRecords(testUtils, goalTimeFinished.first(), tagNames = listOf (goalTimeFinished))
811+ addRecords(testUtils, goalTimeFinished.second(), tagNames = listOf (goalTimeFinished))
812+
813+ addRecords(testUtils, goalCountNotFinished.first(), tagNames = listOf (goalCountNotFinished))
814+ addRecords(testUtils, goalCountNotFinished.second(), tagNames = listOf (goalCountNotFinished))
815+
816+ testUtils.addRecord(goalCountFinished.first(), tagNames = listOf (goalCountFinished))
817+ testUtils.addRecord(goalCountFinished.second(), tagNames = listOf (goalCountFinished))
818+ addRecords(testUtils, goalCountFinished.first(), tagNames = listOf (goalCountFinished))
819+
820+ addRecords(testUtils, otherGoals.first(), tagNames = listOf (otherGoals))
821+ addRecords(testUtils, otherGoals.second(), tagNames = listOf (otherGoals))
822+
823+ NavUtils .openStatisticsScreen()
824+ clickOnCurrentDate()
825+ clickOnViewWithText(coreR.string.range_week)
826+ NavUtils .openFilter()
827+ clickOnViewWithText(coreR.string.record_tag_hint_short)
828+ pressBack()
829+
830+ // Goal time not finished
831+ scrollTo(goalTimeNotFinished)
832+ checkStatisticsGoal(goalTimeNotFinished, " 40$minuteString " , " $goal - 1$hourString 20$minuteString " )
833+ checkStatisticsPercent(goalTimeNotFinished, " 50%" )
834+ checkStatisticsMark(goalTimeNotFinished, isVisible = false )
835+
836+ // Goal time finished
837+ scrollTo(goalTimeFinished)
838+ checkStatisticsGoal(goalTimeFinished, " 40$minuteString " , " $goal - 20$minuteString " )
839+ checkStatisticsMark(goalTimeFinished, isVisible = true )
840+
841+ // Goal count not finished
842+ scrollTo(goalCountNotFinished)
843+ checkStatisticsGoal(goalCountNotFinished, " 4 Records" , " $goal - 8 Records" )
844+ checkStatisticsPercent(goalCountNotFinished, " 50%" )
845+ checkStatisticsMark(goalCountNotFinished, isVisible = false )
846+
847+ // Goal count finished
848+ scrollTo(goalCountFinished)
849+ checkStatisticsGoal(goalCountFinished, " 4 Records" , " $goal - 3 Records" )
850+ checkStatisticsMark(goalCountFinished, isVisible = true )
851+
852+ // Other goals
853+ scrollBottom()
854+ checkNoStatisticsGoal(otherGoals)
855+ }
856+
857+ @Test
858+ fun monthlyTagGoal () {
859+ val goal = getString(coreR.string.change_record_type_goal_time_hint).lowercase()
860+
861+ val goalTimeNotFinished = " goalTimeNotFinishedTag"
862+ val goalTimeFinished = " goalTimeFinishedTag"
863+ val goalCountNotFinished = " goalCountNotFinishedTag"
864+ val goalCountFinished = " goalCountFinishedTag"
865+ val otherGoals = " otherMonthlyTags"
866+
867+ // Activities
868+ testUtils.addActivity(goalTimeNotFinished.first())
869+ testUtils.addActivity(goalTimeNotFinished.second())
870+ testUtils.addActivity(goalTimeFinished.first())
871+ testUtils.addActivity(goalTimeFinished.second())
872+ testUtils.addActivity(goalCountNotFinished.first())
873+ testUtils.addActivity(goalCountNotFinished.second())
874+ testUtils.addActivity(goalCountFinished.first())
875+ testUtils.addActivity(goalCountFinished.second())
876+ testUtils.addActivity(otherGoals.first())
877+ testUtils.addActivity(otherGoals.second())
878+
879+ // Tags
880+ testUtils.addRecordTag(
881+ goalTimeNotFinished,
882+ typeName = goalTimeNotFinished.first(),
883+ goals = listOf (getMonthlyDurationGoalTag(8 * durationInSeconds)),
884+ )
885+ testUtils.addRecordTag(
886+ goalTimeFinished,
887+ typeName = goalTimeFinished.first(),
888+ goals = listOf (getMonthlyDurationGoalTag(2 * durationInSeconds)),
889+ )
890+ testUtils.addRecordTag(
891+ goalCountNotFinished,
892+ typeName = goalCountNotFinished.first(),
893+ goals = listOf (getMonthlyCountGoalTag(8 )),
894+ )
895+ testUtils.addRecordTag(
896+ goalCountFinished,
897+ typeName = goalCountFinished.first(),
898+ goals = listOf (getMonthlyCountGoalTag(3 )),
899+ )
900+ testUtils.addRecordTag(
901+ otherGoals,
902+ typeName = otherGoals.first(),
903+ goals = listOf (
904+ getDailyDurationGoalTag(durationInSeconds),
905+ getWeeklyCountGoalTag(1 ),
906+ ),
907+ )
908+
909+ // Records
910+ addRecords(testUtils, goalTimeNotFinished.first(), tagNames = listOf (goalTimeNotFinished))
911+ addRecords(testUtils, goalTimeNotFinished.second(), tagNames = listOf (goalTimeNotFinished))
912+ addRecords(testUtils, goalTimeFinished.first(), tagNames = listOf (goalTimeFinished))
913+ addRecords(testUtils, goalTimeFinished.second(), tagNames = listOf (goalTimeFinished))
914+
915+ addRecords(testUtils, goalCountNotFinished.first(), tagNames = listOf (goalCountNotFinished))
916+ addRecords(testUtils, goalCountNotFinished.second(), tagNames = listOf (goalCountNotFinished))
917+
918+ testUtils.addRecord(goalCountFinished.first(), tagNames = listOf (goalCountFinished))
919+ testUtils.addRecord(goalCountFinished.second(), tagNames = listOf (goalCountFinished))
920+ addRecords(testUtils, goalCountFinished.first(), tagNames = listOf (goalCountFinished))
921+
922+ addRecords(testUtils, otherGoals.first(), tagNames = listOf (otherGoals))
923+ addRecords(testUtils, otherGoals.second(), tagNames = listOf (otherGoals))
924+
925+ NavUtils .openStatisticsScreen()
926+ clickOnCurrentDate()
927+ clickOnViewWithText(coreR.string.range_month)
928+ NavUtils .openFilter()
929+ clickOnViewWithText(coreR.string.record_tag_hint_short)
930+ pressBack()
931+
932+ // Goal time not finished
933+ scrollTo(goalTimeNotFinished)
934+ checkStatisticsGoal(goalTimeNotFinished, " 1$hourString 0$minuteString " , " $goal - 1$hourString 20$minuteString " )
935+ checkStatisticsPercent(goalTimeNotFinished, " 75%" )
936+ checkStatisticsMark(goalTimeNotFinished, isVisible = false )
937+
938+ // Goal time finished
939+ scrollTo(goalTimeFinished)
940+ checkStatisticsGoal(goalTimeFinished, " 1$hourString 0$minuteString " , " $goal - 20$minuteString " )
941+ checkStatisticsMark(goalTimeFinished, isVisible = true )
942+
943+ // Goal count not finished
944+ scrollTo(goalCountNotFinished)
945+ checkStatisticsGoal(goalCountNotFinished, " 6 Records" , " $goal - 8 Records" )
946+ checkStatisticsPercent(goalCountNotFinished, " 75%" )
947+ checkStatisticsMark(goalCountNotFinished, isVisible = false )
948+
949+ // Goal count finished
950+ scrollTo(goalCountFinished)
951+ checkStatisticsGoal(goalCountFinished, " 5 Records" , " $goal - 3 Records" )
952+ checkStatisticsMark(goalCountFinished, isVisible = true )
953+
954+ // Other goals
955+ scrollBottom()
956+ checkNoStatisticsGoal(otherGoals)
957+ }
958+
649959 @Test
650960 fun goalNavigation () {
651961 val typeName = " typeName"
0 commit comments