Skip to content

Commit 48b0e0b

Browse files
authored
Merge branch 'Razeeman:dev' into dev
2 parents f088209 + 1f06104 commit 48b0e0b

9 files changed

Lines changed: 666 additions & 3 deletions

File tree

app/proguard-debug-rules.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-keepclassmembers class com.example.util.simpletimetracker.feature_views.pieChart.PieChartView$Companion { void setDisableAnimationsForTest(boolean); }
88
-keepclassmembers class com.example.util.simpletimetracker.navigation.ScreenResolver$Companion { void setDisableAnimationsForTest(boolean); }
99
-keepclassmembers class com.example.util.simpletimetracker.feature_settings.viewModel.delegate.SettingsFileWorkDelegate$Companion { void setRestartAppIsBlocked(boolean); }
10+
-keepclassmembers class com.example.util.simpletimetracker.core.base.DelayLoadHandler$Companion { void setDisableForTest(boolean); }
1011
-keepclassmembers class com.example.util.simpletimetracker.core.mapper.ColorMapper$Companion { synthetic java.util.List getAvailableColors$default(com.example.util.simpletimetracker.core.mapper.ColorMapper$Companion,boolean,int,java.lang.Object); }
1112
-keep class com.example.util.simpletimetracker.core.utils.CountingIdlingResourceProvider { *; }
1213
-keep class com.example.util.simpletimetracker.core.utils.TestUtils { *; }

app/src/androidTest/java/com/example/util/simpletimetracker/AddRecordTagTest.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import com.example.util.simpletimetracker.feature_categories.R as categoriesR
4343
import com.example.util.simpletimetracker.feature_change_record.R as changeRecordR
4444
import com.example.util.simpletimetracker.feature_change_record_tag.R as changeRecordTagR
4545
import com.example.util.simpletimetracker.feature_change_record_type.R as changeRecordTypeR
46+
import com.example.util.simpletimetracker.feature_dialogs.R as dialogsR
4647
import com.example.util.simpletimetracker.feature_views.R as viewsR
4748

4849
@HiltAndroidTest
@@ -191,6 +192,22 @@ class AddRecordTagTest : BaseUiTest() {
191192
allOf(withId(changeRecordTagR.id.fieldChangeRecordTagType), withCardColor(viewsR.color.colorBackground)),
192193
)
193194

195+
// Selecting goal time
196+
openGoals()
197+
clickOnView(
198+
allOf(
199+
isDescendantOfA(withId(R.id.layoutChangeRecordTypeGoalSession)),
200+
withId(R.id.fieldChangeRecordTypeGoalDuration),
201+
),
202+
)
203+
clickOnViewWithId(dialogsR.id.tvNumberKeyboard1)
204+
clickOnViewWithId(dialogsR.id.tvNumberKeyboard0)
205+
clickOnViewWithId(dialogsR.id.tvNumberKeyboard0)
206+
clickOnViewWithId(dialogsR.id.tvNumberKeyboard0)
207+
clickOnViewWithText(coreR.string.duration_dialog_save)
208+
checkViewIsDisplayed(withText("10$minuteString"))
209+
openGoals()
210+
194211
// Adding note
195212
onView(withId(changeRecordTagR.id.etChangeRecordTagNote)).perform(nestedScrollTo())
196213
typeTextIntoView(changeRecordTagR.id.etChangeRecordTagNote, note)
@@ -209,6 +226,12 @@ class AddRecordTagTest : BaseUiTest() {
209226
checkViewIsDisplayed(allOf(withId(changeRecordTagR.id.etChangeRecordTagName), withText(name)))
210227
onView(withId(changeRecordTagR.id.etChangeRecordTagNote)).perform(nestedScrollTo())
211228
checkViewIsDisplayed(allOf(withId(changeRecordTagR.id.etChangeRecordTagNote), withText(note)))
229+
230+
// Check goals saved
231+
Thread.sleep(1000)
232+
openGoals()
233+
checkViewIsDisplayed(withText("10$minuteString"))
234+
openGoals()
212235
}
213236

214237
@Test
@@ -584,4 +607,13 @@ class AddRecordTagTest : BaseUiTest() {
584607

585608
private fun checkPreviewUpdated(matcher: Matcher<View>) =
586609
checkViewIsDisplayed(allOf(withId(changeRecordTagR.id.previewChangeRecordTag), matcher))
610+
611+
private fun openGoals() {
612+
clickOnView(
613+
allOf(
614+
withId(changeRecordTagR.id.tvChangeRecordTagGoalHint),
615+
withText(coreR.string.change_record_type_goal_time_hint),
616+
),
617+
)
618+
}
587619
}

app/src/androidTest/java/com/example/util/simpletimetracker/GoalsStatisticsTest.kt

Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,22 @@ import com.example.util.simpletimetracker.GoalsTestUtils.checkStatisticsPercent
1515
import com.example.util.simpletimetracker.GoalsTestUtils.durationInSeconds
1616
import com.example.util.simpletimetracker.GoalsTestUtils.getDailyCountGoal
1717
import com.example.util.simpletimetracker.GoalsTestUtils.getDailyCountGoalCategory
18+
import com.example.util.simpletimetracker.GoalsTestUtils.getDailyCountGoalTag
1819
import com.example.util.simpletimetracker.GoalsTestUtils.getDailyDurationGoal
1920
import com.example.util.simpletimetracker.GoalsTestUtils.getDailyDurationGoalCategory
21+
import com.example.util.simpletimetracker.GoalsTestUtils.getDailyDurationGoalTag
2022
import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyCountGoal
2123
import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyCountGoalCategory
24+
import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyCountGoalTag
2225
import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyDurationGoal
2326
import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyDurationGoalCategory
27+
import com.example.util.simpletimetracker.GoalsTestUtils.getMonthlyDurationGoalTag
2428
import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyCountGoal
2529
import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyCountGoalCategory
30+
import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyCountGoalTag
2631
import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyDurationGoal
2732
import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyDurationGoalCategory
33+
import com.example.util.simpletimetracker.GoalsTestUtils.getWeeklyDurationGoalTag
2834
import com.example.util.simpletimetracker.utils.BaseUiTest
2935
import com.example.util.simpletimetracker.utils.NavUtils
3036
import 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

Comments
 (0)