@@ -43,11 +43,13 @@ import com.example.util.simpletimetracker.utils.clickOnRecyclerItem
4343import com.example.util.simpletimetracker.utils.clickOnView
4444import com.example.util.simpletimetracker.utils.clickOnViewWithId
4545import com.example.util.simpletimetracker.utils.clickOnViewWithText
46+ import com.example.util.simpletimetracker.utils.clickOnVisibleView
4647import com.example.util.simpletimetracker.utils.dateSelectorMatcher
4748import com.example.util.simpletimetracker.utils.getMillis
4849import com.example.util.simpletimetracker.utils.longClickOnCurrentDate
4950import com.example.util.simpletimetracker.utils.longClickOnView
5051import com.example.util.simpletimetracker.utils.longClickOnViewWithId
52+ import com.example.util.simpletimetracker.utils.longClickOnVisibleView
5153import com.example.util.simpletimetracker.utils.recyclerItemCount
5254import com.example.util.simpletimetracker.utils.tryAction
5355import com.example.util.simpletimetracker.utils.typeTextIntoView
@@ -1002,13 +1004,16 @@ class SettingsTest : BaseUiTest() {
10021004 timeString,
10031005 )
10041006 tryAction { clickOnView(allOf(withText(name), isCompletelyDisplayed())) }
1005- checkViewIsDisplayed(
1006- allOf(
1007- withId(statisticsDetailR.id.containerStatisticsDetailCard),
1008- hasDescendant(withText(R .string.statistics_detail_total_duration)),
1009- hasDescendant(withText(timeString)),
1010- ),
1011- )
1007+ NavUtils .fixToCurrentDate()
1008+ tryAction {
1009+ checkViewIsDisplayed(
1010+ allOf(
1011+ withId(statisticsDetailR.id.containerStatisticsDetailCard),
1012+ hasDescendant(withText(R .string.statistics_detail_total_duration)),
1013+ hasDescendant(withText(timeString)),
1014+ ),
1015+ )
1016+ }
10121017 pressBack()
10131018 }
10141019
@@ -1081,6 +1086,207 @@ class SettingsTest : BaseUiTest() {
10811086 checkCheckboxIsNotChecked(settingsCheckboxBesideText(coreR.string.settings_keep_screen_on))
10821087 }
10831088
1089+ @Test
1090+ fun startTimersByLongClick () {
1091+ val name = " Test"
1092+
1093+ // Add data
1094+ runBlocking { prefsInteractor.setAllowMultitasking(false ) }
1095+ testUtils.addActivity(name)
1096+ testUtils.addShortcut(name)
1097+ testUtils.addRecord(
1098+ typeName = name,
1099+ timeStarted = System .currentTimeMillis() - TimeUnit .HOURS .toMillis(1 ),
1100+ timeEnded = System .currentTimeMillis() - TimeUnit .HOURS .toMillis(1 ),
1101+ )
1102+
1103+ // Check disabled
1104+ NavUtils .openSettingsScreen()
1105+ NavUtils .openSettingsAdditional()
1106+ scrollSettingsRecyclerToText(coreR.string.settings_start_timer_by_long_click)
1107+ checkCheckboxIsNotChecked(settingsCheckboxBesideText(coreR.string.settings_start_timer_by_long_click))
1108+ // Type
1109+ NavUtils .openRunningRecordsScreen()
1110+ longClickOnVisibleView(
1111+ allOf(
1112+ withId(R .id.viewRecordTypeItem),
1113+ hasDescendant(withText(name)),
1114+ ),
1115+ )
1116+ checkViewIsDisplayed(withText(R .string.duration_dialog_save))
1117+ pressBack()
1118+ clickOnVisibleView(
1119+ allOf(
1120+ withId(R .id.viewRecordTypeItem),
1121+ hasDescendant(withText(name)),
1122+ ),
1123+ )
1124+ // Running record
1125+ longClickOnView(
1126+ allOf(
1127+ withId(R .id.viewRunningRecordItem),
1128+ hasDescendant(withText(name)),
1129+ ),
1130+ )
1131+ checkViewIsDisplayed(withText(R .string.duration_dialog_save))
1132+ pressBack()
1133+ clickOnView(
1134+ allOf(
1135+ withId(R .id.viewRunningRecordItem),
1136+ hasDescendant(withText(name)),
1137+ ),
1138+ )
1139+ checkViewDoesNotExist(withId(R .id.viewRunningRecordItem))
1140+ // Shortcut
1141+ longClickOnView(
1142+ allOf(
1143+ withId(R .id.viewRecordShortcutItem),
1144+ hasDescendant(withText(name)),
1145+ ),
1146+ )
1147+ clickOnView(withText(R .string.cancel))
1148+ clickOnView(
1149+ allOf(
1150+ withId(R .id.viewRecordShortcutItem),
1151+ hasDescendant(withText(name)),
1152+ ),
1153+ )
1154+ clickOnView(
1155+ allOf(
1156+ withId(R .id.viewRunningRecordItem),
1157+ hasDescendant(withText(name)),
1158+ ),
1159+ )
1160+ checkViewDoesNotExist(withId(R .id.viewRunningRecordItem))
1161+ // Retroactive
1162+ NavUtils .openSettingsScreen()
1163+ scrollSettingsRecyclerToText(coreR.string.settings_retroactive_tracking_mode)
1164+ clickOnSettingsCheckboxBesideText(coreR.string.settings_retroactive_tracking_mode)
1165+ checkCheckboxIsChecked(settingsCheckboxBesideText(coreR.string.settings_retroactive_tracking_mode))
1166+ NavUtils .openRunningRecordsScreen()
1167+ // Untracked
1168+ clickOnView(withText(R .string.untracked_time_name))
1169+ checkViewDoesNotExist(withText(R .string.duration_dialog_save))
1170+ longClickOnView(withText(R .string.untracked_time_name))
1171+ checkViewIsDisplayed(withText(R .string.duration_dialog_save))
1172+ pressBack()
1173+ // Last record
1174+ clickOnView(
1175+ allOf(
1176+ withId(R .id.viewRecordItem),
1177+ hasDescendant(withText(name)),
1178+ isCompletelyDisplayed(),
1179+ ),
1180+ )
1181+ checkViewDoesNotExist(withText(R .string.duration_dialog_save))
1182+ longClickOnView(
1183+ allOf(
1184+ withId(R .id.viewRecordItem),
1185+ hasDescendant(withText(name)),
1186+ isCompletelyDisplayed(),
1187+ ),
1188+ )
1189+ checkViewIsDisplayed(withText(R .string.duration_dialog_save))
1190+ pressBack()
1191+ NavUtils .openSettingsScreen()
1192+ scrollSettingsRecyclerToText(coreR.string.settings_retroactive_tracking_mode)
1193+ clickOnSettingsCheckboxBesideText(coreR.string.settings_retroactive_tracking_mode)
1194+ checkCheckboxIsNotChecked(settingsCheckboxBesideText(coreR.string.settings_retroactive_tracking_mode))
1195+
1196+ // Check enabled
1197+ scrollSettingsRecyclerToText(coreR.string.settings_start_timer_by_long_click)
1198+ clickOnSettingsCheckboxBesideText(coreR.string.settings_start_timer_by_long_click)
1199+ checkCheckboxIsChecked(settingsCheckboxBesideText(coreR.string.settings_start_timer_by_long_click))
1200+ // Type
1201+ NavUtils .openRunningRecordsScreen()
1202+ clickOnVisibleView(
1203+ allOf(
1204+ withId(R .id.viewRecordTypeItem),
1205+ hasDescendant(withText(name)),
1206+ ),
1207+ )
1208+ checkViewIsDisplayed(withText(R .string.duration_dialog_save))
1209+ pressBack()
1210+ longClickOnVisibleView(
1211+ allOf(
1212+ withId(R .id.viewRecordTypeItem),
1213+ hasDescendant(withText(name)),
1214+ ),
1215+ )
1216+ // Running record
1217+ clickOnView(
1218+ allOf(
1219+ withId(R .id.viewRunningRecordItem),
1220+ hasDescendant(withText(name)),
1221+ ),
1222+ )
1223+ checkViewIsDisplayed(withText(R .string.duration_dialog_save))
1224+ pressBack()
1225+ longClickOnView(
1226+ allOf(
1227+ withId(R .id.viewRunningRecordItem),
1228+ hasDescendant(withText(name)),
1229+ ),
1230+ )
1231+ checkViewDoesNotExist(withId(R .id.viewRunningRecordItem))
1232+ // Shortcut
1233+ clickOnView(
1234+ allOf(
1235+ withId(R .id.viewRecordShortcutItem),
1236+ hasDescendant(withText(name)),
1237+ ),
1238+ )
1239+ clickOnView(withText(R .string.cancel))
1240+ longClickOnView(
1241+ allOf(
1242+ withId(R .id.viewRecordShortcutItem),
1243+ hasDescendant(withText(name)),
1244+ ),
1245+ )
1246+ longClickOnView(
1247+ allOf(
1248+ withId(R .id.viewRunningRecordItem),
1249+ hasDescendant(withText(name)),
1250+ ),
1251+ )
1252+ checkViewDoesNotExist(withId(R .id.viewRunningRecordItem))
1253+ // Retroactive
1254+ NavUtils .openSettingsScreen()
1255+ scrollSettingsRecyclerToText(coreR.string.settings_retroactive_tracking_mode)
1256+ clickOnSettingsCheckboxBesideText(coreR.string.settings_retroactive_tracking_mode)
1257+ checkCheckboxIsChecked(settingsCheckboxBesideText(coreR.string.settings_retroactive_tracking_mode))
1258+ NavUtils .openRunningRecordsScreen()
1259+ // Untracked
1260+ longClickOnView(withText(R .string.untracked_time_name))
1261+ checkViewDoesNotExist(withText(R .string.duration_dialog_save))
1262+ clickOnView(withText(R .string.untracked_time_name))
1263+ checkViewIsDisplayed(withText(R .string.duration_dialog_save))
1264+ pressBack()
1265+ // Last record
1266+ longClickOnView(
1267+ allOf(
1268+ withId(R .id.viewRecordItem),
1269+ hasDescendant(withText(name)),
1270+ isCompletelyDisplayed(),
1271+ ),
1272+ )
1273+ checkViewDoesNotExist(withText(R .string.duration_dialog_save))
1274+ Thread .sleep(500 )
1275+ clickOnView(
1276+ allOf(
1277+ withId(R .id.viewRecordItem),
1278+ hasDescendant(withText(name)),
1279+ isCompletelyDisplayed(),
1280+ ),
1281+ )
1282+ checkViewIsDisplayed(withText(R .string.duration_dialog_save))
1283+ pressBack()
1284+ NavUtils .openSettingsScreen()
1285+ scrollSettingsRecyclerToText(coreR.string.settings_retroactive_tracking_mode)
1286+ clickOnSettingsCheckboxBesideText(coreR.string.settings_retroactive_tracking_mode)
1287+ checkCheckboxIsNotChecked(settingsCheckboxBesideText(coreR.string.settings_retroactive_tracking_mode))
1288+ }
1289+
10841290 @Test
10851291 fun firstDayOfWeek () {
10861292 // If today is sunday:
@@ -1134,6 +1340,7 @@ class SettingsTest : BaseUiTest() {
11341340 )
11351341
11361342 // Check detailed statistics
1343+ NavUtils .fixToCurrentDate()
11371344 clickOnCurrentDate()
11381345 clickOnViewWithText(coreR.string.range_week)
11391346 checkViewIsDisplayed(
@@ -1264,7 +1471,8 @@ class SettingsTest : BaseUiTest() {
12641471
12651472 // Check detailed statistics
12661473 clickOnView(allOf(withText(name), isCompletelyDisplayed()))
1267- tryAction { clickOnCurrentDate() }
1474+ NavUtils .fixToCurrentDate()
1475+ clickOnCurrentDate()
12681476 clickOnViewWithText(coreR.string.range_day)
12691477 checkStatisticsDetailRecords(0 )
12701478 clickOnCurrentDate(- 1 )
@@ -1384,7 +1592,8 @@ class SettingsTest : BaseUiTest() {
13841592
13851593 // Check detailed statistics
13861594 clickOnView(allOf(withText(name), isCompletelyDisplayed()))
1387- tryAction { clickOnCurrentDate() }
1595+ NavUtils .fixToCurrentDate()
1596+ clickOnCurrentDate()
13881597 clickOnViewWithText(coreR.string.range_day)
13891598 checkStatisticsDetailRecords(0 )
13901599 clickOnCurrentDate(- 1 )
0 commit comments