A fork of Simple Time Tracker with WearOS support. (Now integrated upstream)
0

Configure Feed

Select the types of activity you want to include in your feed.

add more tests

razeeman (Jun 17, 2023, 5:01 PM +0300) 1ca22f03 b74d5de3

+264 -3
+1
features/feature_base_adapter/src/main/res/layout/item_multitask_record_layout.xml
··· 1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <com.example.util.simpletimetracker.feature_base_adapter.multitaskRecord.customView.MultitaskRecordView xmlns:android="http://schemas.android.com/apk/res/android" 3 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 + android:id="@+id/viewMultitaskRecordItem" 4 5 android:layout_width="match_parent" 5 6 android:layout_height="wrap_content" 6 7 android:layout_marginStart="4dp"
+108
app/src/androidTest/java/com/example/util/simpletimetracker/AddRecordTest.kt
··· 18 18 import com.example.util.simpletimetracker.utils.checkViewIsDisplayed 19 19 import com.example.util.simpletimetracker.utils.checkViewIsNotDisplayed 20 20 import com.example.util.simpletimetracker.utils.clickOnRecyclerItem 21 + import com.example.util.simpletimetracker.utils.clickOnView 21 22 import com.example.util.simpletimetracker.utils.clickOnViewWithId 22 23 import com.example.util.simpletimetracker.utils.clickOnViewWithText 23 24 import com.example.util.simpletimetracker.utils.tryAction ··· 287 288 tryAction { checkPreviewUpdated(hasDescendant(withText(comment2))) } 288 289 clickOnViewWithText(comment3) 289 290 tryAction { checkPreviewUpdated(hasDescendant(withText(comment3))) } 291 + } 292 + 293 + @Test 294 + fun favouriteComments() { 295 + val name = "name" 296 + val comment = "comment" 297 + val comment1 = "favourite comment1" 298 + val comment2 = "favourite comment2" 299 + 300 + // Add data 301 + testUtils.addActivity(name) 302 + testUtils.addRecord(typeName = name, comment = comment) 303 + 304 + // Check 305 + NavUtils.openRecordsScreen() 306 + clickOnViewWithId(recordsR.id.btnRecordAdd) 307 + 308 + // No favourites 309 + clickOnViewWithText(coreR.string.change_record_comment_field) 310 + closeSoftKeyboard() 311 + checkViewDoesNotExist(withText(coreR.string.change_record_last_comments_hint)) 312 + checkViewDoesNotExist(withText(coreR.string.change_record_favourite_comments_hint)) 313 + checkViewIsNotDisplayed(withId(changeRecordR.id.btnChangeRecordFavouriteComment)) 314 + 315 + // Add favourite 316 + typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment1) 317 + tryAction { checkPreviewUpdated(hasDescendant(withText(comment1))) } 318 + checkViewIsDisplayed(withId(changeRecordR.id.btnChangeRecordFavouriteComment)) 319 + clickOnViewWithId(changeRecordR.id.btnChangeRecordFavouriteComment) 320 + checkViewIsDisplayed(withText(coreR.string.change_record_favourite_comments_hint)) 321 + checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment1))) 322 + 323 + // Add another 324 + typeTextIntoView(changeRecordR.id.etChangeRecordComment, comment2) 325 + tryAction { checkPreviewUpdated(hasDescendant(withText(comment2))) } 326 + checkViewIsDisplayed(withId(changeRecordR.id.btnChangeRecordFavouriteComment)) 327 + clickOnViewWithId(changeRecordR.id.btnChangeRecordFavouriteComment) 328 + checkViewIsDisplayed(withText(coreR.string.change_record_favourite_comments_hint)) 329 + checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment1))) 330 + checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment2))) 331 + 332 + // Favourite click 333 + clickOnViewWithText(comment1) 334 + tryAction { checkPreviewUpdated(hasDescendant(withText(comment1))) } 335 + 336 + // Remove favourite 337 + clickOnViewWithId(changeRecordR.id.btnChangeRecordFavouriteComment) 338 + checkViewIsDisplayed(withText(coreR.string.change_record_favourite_comments_hint)) 339 + checkViewDoesNotExist(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment1))) 340 + checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment2))) 341 + 342 + // Favourites and last 343 + typeTextIntoView(changeRecordR.id.etChangeRecordComment, "") 344 + clickOnViewWithText(coreR.string.change_record_comment_field) 345 + clickOnViewWithText(coreR.string.change_record_type_field) 346 + clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name)) 347 + clickOnViewWithText(coreR.string.change_record_comment_field) 348 + closeSoftKeyboard() 349 + checkViewIsDisplayed(withText(coreR.string.change_record_last_comments_hint)) 350 + checkViewIsDisplayed(withText(comment)) 351 + checkViewIsDisplayed(withText(coreR.string.change_record_favourite_comments_hint)) 352 + checkViewIsDisplayed(withText(comment2)) 353 + } 354 + 355 + @Test 356 + fun searchComments() { 357 + val name = "name" 358 + val comment1 = "comment" 359 + val comment2 = "another comment" 360 + 361 + // Add data 362 + testUtils.addActivity(name) 363 + testUtils.addRecord(name, comment = comment1) 364 + testUtils.addRecord(name, comment = comment2) 365 + 366 + // Check 367 + NavUtils.openRecordsScreen() 368 + clickOnViewWithId(recordsR.id.btnRecordAdd) 369 + clickOnViewWithText(coreR.string.change_record_comment_field) 370 + closeSoftKeyboard() 371 + 372 + checkViewIsDisplayed(withId(changeRecordR.id.etChangeRecordComment)) 373 + checkViewDoesNotExist(withId(changeRecordR.id.etChangeRecordCommentField)) 374 + clickOnViewWithId(changeRecordR.id.btnChangeRecordSearchComment) 375 + checkViewIsNotDisplayed(withId(changeRecordR.id.etChangeRecordComment)) 376 + checkViewIsDisplayed(withId(changeRecordR.id.etChangeRecordCommentField)) 377 + 378 + typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, "comment") 379 + tryAction { 380 + checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment1))) 381 + } 382 + checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment2))) 383 + 384 + typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, "another") 385 + tryAction { 386 + checkViewDoesNotExist(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment1))) 387 + } 388 + checkViewIsDisplayed(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment2))) 389 + 390 + // Click on search result 391 + clickOnView(allOf(withId(changeRecordR.id.tvChangeRecordItemComment), withText(comment2))) 392 + tryAction { checkPreviewUpdated(hasDescendant(withText(comment2))) } 393 + 394 + // Go back 395 + clickOnViewWithId(changeRecordR.id.btnChangeRecordSearchCommentField) 396 + checkViewIsDisplayed(withId(changeRecordR.id.etChangeRecordComment)) 397 + checkViewIsNotDisplayed(withId(changeRecordR.id.etChangeRecordCommentField)) 290 398 } 291 399 292 400 @Test
+56
app/src/androidTest/java/com/example/util/simpletimetracker/ChangeRunningRecordTest.kt
··· 15 15 import androidx.test.espresso.matcher.ViewMatchers.withSubstring 16 16 import androidx.test.espresso.matcher.ViewMatchers.withText 17 17 import androidx.test.ext.junit.runners.AndroidJUnit4 18 + import com.example.util.simpletimetracker.core.extension.setToStartOfDay 18 19 import com.example.util.simpletimetracker.feature_dialogs.dateTime.CustomTimePicker 19 20 import com.example.util.simpletimetracker.utils.BaseUiTest 20 21 import com.example.util.simpletimetracker.utils.checkViewDoesNotExist ··· 675 676 allGoalsWeeklyFinished, changeRecordR.id.tvRunningRecordItemGoalTime3, weeklyGoal 676 677 ) 677 678 checkGoalMark(allGoalsWeeklyFinished, changeRecordR.id.ivRunningRecordItemGoalTimeCheck3, isVisible = true) 679 + } 680 + 681 + @Test 682 + fun dayTotal() { 683 + val name1 = "name1" 684 + val name2 = "name2" 685 + 686 + // Add data 687 + testUtils.addActivity(name1) 688 + testUtils.addActivity(name2) 689 + 690 + val time = calendar.apply { 691 + timeInMillis = System.currentTimeMillis() 692 + setToStartOfDay() 693 + set(Calendar.HOUR_OF_DAY, 12) 694 + }.timeInMillis 695 + testUtils.addRecord( 696 + typeName = name1, 697 + timeStarted = time, 698 + timeEnded = time + TimeUnit.HOURS.toMillis(1), 699 + ) 700 + 701 + // Check 702 + val day = getString(coreR.string.title_today).lowercase() 703 + val dayTotal = "$day 1$hourString 0$minuteString" 704 + 705 + tryAction { clickOnViewWithText(name1) } 706 + tryAction { 707 + checkViewIsDisplayed( 708 + allOf( 709 + withId(changeRecordR.id.viewRunningRecordItem), 710 + hasDescendant(withText(name1)), 711 + hasDescendant(withText(dayTotal)), 712 + ) 713 + ) 714 + } 715 + 716 + tryAction { clickOnViewWithText(name2) } 717 + tryAction { 718 + checkViewIsDisplayed( 719 + allOf( 720 + withId(changeRecordR.id.viewRunningRecordItem), 721 + hasDescendant(withText(name2)), 722 + ) 723 + ) 724 + } 725 + tryAction { 726 + checkViewDoesNotExist( 727 + allOf( 728 + withId(changeRecordR.id.viewRunningRecordItem), 729 + hasDescendant(withText(name2)), 730 + hasDescendant(withSubstring(day)), 731 + ) 732 + ) 733 + } 678 734 } 679 735 680 736 private fun checkAfterTimeAdjustment(timeStarted: String) {
+99
app/src/androidTest/java/com/example/util/simpletimetracker/StatisticsDetailTest.kt
··· 1108 1108 checkCard(coreR.string.statistics_detail_average_record, "3$hourString 0$minuteString") 1109 1109 } 1110 1110 1111 + @Test 1112 + fun multitask() { 1113 + val name1 = "name1" 1114 + val name2 = "name2" 1115 + 1116 + // Add data 1117 + testUtils.addActivity(name1) 1118 + testUtils.addActivity(name2) 1119 + val time = calendar.apply { 1120 + timeInMillis = System.currentTimeMillis() 1121 + setToStartOfDay() 1122 + set(Calendar.HOUR_OF_DAY, 12) 1123 + }.timeInMillis 1124 + 1125 + testUtils.addRecord( 1126 + typeName = name1, 1127 + timeStarted = time, 1128 + timeEnded = time + TimeUnit.HOURS.toMillis(2), 1129 + ) 1130 + testUtils.addRecord( 1131 + typeName = name2, 1132 + timeStarted = time + TimeUnit.HOURS.toMillis(1), 1133 + timeEnded = time + TimeUnit.HOURS.toMillis(3), 1134 + ) 1135 + 1136 + // Check 1137 + NavUtils.openStatisticsScreen() 1138 + tryAction { clickOnView(allOf(withText(name1), isCompletelyDisplayed())) } 1139 + clickOnViewWithId(statisticsDetailR.id.cardStatisticsDetailFilter) 1140 + clickOnView(withText(coreR.string.multitask_time_name)) 1141 + pressBack() 1142 + 1143 + checkRecordsCard(1) 1144 + checkCard(coreR.string.statistics_detail_total_duration, "1$hourString 0$minuteString") 1145 + 1146 + // Check record 1147 + onView(withId(statisticsDetailR.id.cardStatisticsDetailRecords)).perform(nestedScrollTo(), click()) 1148 + val started = timeMapper.formatTime( 1149 + time = time + TimeUnit.HOURS.toMillis(1), 1150 + useMilitaryTime = true, 1151 + showSeconds = false 1152 + ) 1153 + val ended = timeMapper.formatTime( 1154 + time = time + TimeUnit.HOURS.toMillis(2), 1155 + useMilitaryTime = true, 1156 + showSeconds = false 1157 + ) 1158 + checkViewIsDisplayed( 1159 + allOf( 1160 + withId(baseR.id.viewMultitaskRecordItem), 1161 + hasDescendant(withText(name1)), 1162 + hasDescendant(withText(name2)), 1163 + hasDescendant(withText("1$hourString 0$minuteString")), 1164 + hasDescendant(withText(started)), 1165 + hasDescendant(withText(ended)), 1166 + isCompletelyDisplayed() 1167 + ) 1168 + ) 1169 + } 1170 + 1171 + @Test 1172 + fun runningRecord() { 1173 + val name = "name" 1174 + 1175 + // Add data 1176 + testUtils.addActivity(name) 1177 + val time = calendar.apply { 1178 + timeInMillis = System.currentTimeMillis() 1179 + setToStartOfDay() 1180 + set(Calendar.HOUR_OF_DAY, 12) 1181 + }.timeInMillis 1182 + testUtils.addRecord( 1183 + typeName = name, 1184 + timeStarted = time, 1185 + timeEnded = time + TimeUnit.HOURS.toMillis(1), 1186 + ) 1187 + testUtils.addRunningRecord( 1188 + typeName = name, 1189 + timeStarted = System.currentTimeMillis() - TimeUnit.HOURS.toMillis(1), 1190 + ) 1191 + 1192 + // Check statistics 1193 + NavUtils.openStatisticsScreen() 1194 + checkViewIsDisplayed( 1195 + allOf( 1196 + withId(baseR.id.viewStatisticsItem), 1197 + hasDescendant(withText(name)), 1198 + hasDescendant(withText("2$hourString 0$minuteString")), 1199 + isCompletelyDisplayed() 1200 + ) 1201 + ) 1202 + 1203 + // Check detailed statistics 1204 + tryAction { clickOnView(allOf(withText(name), isCompletelyDisplayed())) } 1205 + onView(withId(statisticsDetailR.id.cardStatisticsDetailTotal)).perform(nestedScrollTo()) 1206 + checkCard(coreR.string.statistics_detail_total_duration, "2$hourString 0$minuteString") 1207 + checkRecordsCard(2) 1208 + } 1209 + 1111 1210 private fun checkPreview(color: Int, icon: Int, name: String) { 1112 1211 checkViewIsDisplayed( 1113 1212 allOf(
-1
data_local/src/main/java/com/example/util/simpletimetracker/data_local/database/FavouriteCommentDao.kt
··· 5 5 import androidx.room.OnConflictStrategy 6 6 import androidx.room.Query 7 7 import com.example.util.simpletimetracker.data_local.model.FavouriteCommentDBO 8 - import com.example.util.simpletimetracker.data_local.model.RecordTypeDBO 9 8 10 9 @Dao 11 10 interface FavouriteCommentDao {
-1
domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/FavouriteCommentInteractor.kt
··· 2 2 3 3 import com.example.util.simpletimetracker.domain.model.FavouriteComment 4 4 import com.example.util.simpletimetracker.domain.repo.FavouriteCommentRepo 5 - import java.util.Locale 6 5 import javax.inject.Inject 7 6 8 7 class FavouriteCommentInteractor @Inject constructor(
-1
features/feature_records_filter/src/main/java/com/example/util/simpletimetracker/feature_records_filter/mapper/RecordsFilterViewDataMapper.kt
··· 34 34 } 35 35 } 36 36 ?.let { mapToViewData(it::class.java) } 37 - 38 37 } 39 38 40 39 fun mapRecordsCount(