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.

fix tests

razeeman (Dec 10, 2023, 12:29 PM +0300) ebb15c10 6649edca

+62 -36
+1
app/src/androidTest/java/com/example/util/simpletimetracker/AddCategoryTest.kt
··· 86 86 ) 87 87 88 88 // Open activity chooser 89 + clickOnViewWithText(coreR.string.change_category_color_hint) 89 90 clickOnViewWithText(coreR.string.change_category_types_hint) 90 91 checkViewIsNotDisplayed(withId(changeCategoryR.id.rvChangeCategoryColor)) 91 92 checkViewIsDisplayed(withId(changeCategoryR.id.rvChangeCategoryType))
+43 -15
app/src/androidTest/java/com/example/util/simpletimetracker/AddDefaultRecordTypeTest.kt
··· 1 1 package com.example.util.simpletimetracker 2 2 3 + import android.view.View 4 + import androidx.test.espresso.Espresso.onView 3 5 import androidx.test.espresso.Espresso.pressBack 6 + import androidx.test.espresso.ViewAssertion 7 + import androidx.test.espresso.assertion.PositionAssertions.isCompletelyAbove 8 + import androidx.test.espresso.assertion.PositionAssertions.isCompletelyLeftOf 9 + import androidx.test.espresso.assertion.PositionAssertions.isTopAlignedWith 4 10 import androidx.test.espresso.matcher.ViewMatchers.hasDescendant 11 + import androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA 5 12 import androidx.test.espresso.matcher.ViewMatchers.withId 6 13 import androidx.test.espresso.matcher.ViewMatchers.withText 7 14 import androidx.test.ext.junit.runners.AndroidJUnit4 ··· 14 21 import com.example.util.simpletimetracker.utils.withCardColor 15 22 import dagger.hilt.android.testing.HiltAndroidTest 16 23 import org.hamcrest.CoreMatchers.allOf 24 + import org.hamcrest.Matcher 17 25 import org.junit.Test 18 26 import org.junit.runner.RunWith 19 27 import com.example.util.simpletimetracker.core.R as coreR 20 28 import com.example.util.simpletimetracker.feature_base_adapter.R as baseR 21 - import com.example.util.simpletimetracker.feature_views.R as viewsR 22 29 23 30 @HiltAndroidTest 24 31 @RunWith(AndroidJUnit4::class) 25 32 class AddDefaultRecordTypeTest : BaseUiTest() { 26 33 27 34 @Test 28 - fun addRecordType() { 35 + fun default() { 29 36 val name1 = "Games" 37 + val name1next = "Tv" 30 38 val color1 = ColorMapper.getAvailableColors()[1] 31 - val name2 = "Work" 32 - val color2 = ColorMapper.getAvailableColors()[10] 39 + val name2 = "Chores" 40 + val name2next = "Cleaning" 41 + val color2 = ColorMapper.getAvailableColors()[5] 33 42 34 43 tryAction { 35 44 checkViewIsDisplayed( ··· 48 57 // Open dialog 49 58 clickOnViewWithText(coreR.string.running_records_add_default) 50 59 Thread.sleep(1000) 60 + checkViewIsDisplayed(withText(coreR.string.nothing_selected)) 51 61 checkActivity(name1, color1) 52 62 checkActivity(name2, color2) 63 + checkOrder(name1, name1next, ::isCompletelyLeftOf, ::isTopAlignedWith) 64 + checkOrder(name2, name2next, ::isCompletelyLeftOf, ::isTopAlignedWith) 53 65 54 66 // Close without saving 55 67 pressBack() ··· 61 73 // Check selection 62 74 clickOnViewWithText(coreR.string.running_records_add_default) 63 75 clickOnViewWithText(name1) 64 - checkActivity(name1, viewsR.color.colorFiltered) 65 - checkActivity(name2, color2) 76 + checkViewIsDisplayed(withText(coreR.string.something_selected)) 77 + checkOrder(name1, name1next, ::isCompletelyAbove) 78 + checkOrder(name2, name2next, ::isCompletelyLeftOf, ::isTopAlignedWith) 66 79 67 80 clickOnViewWithText(name1) 68 81 clickOnViewWithText(name2) 69 - checkActivity(name1, color1) 70 - checkActivity(name2, viewsR.color.colorFiltered) 82 + checkViewIsDisplayed(withText(coreR.string.something_selected)) 83 + checkOrder(name1, name1next, ::isCompletelyLeftOf, ::isTopAlignedWith) 84 + checkOrder(name2, name2next, ::isCompletelyAbove) 71 85 72 - clickOnViewWithText(coreR.string.types_filter_show_all) 73 - checkActivity(name1, color1) 74 - checkActivity(name2, color2) 86 + clickOnViewWithText(coreR.string.select_all) 87 + checkViewIsDisplayed(withText(coreR.string.something_selected)) 88 + checkOrder(name1, name1next, ::isCompletelyLeftOf, ::isTopAlignedWith) 89 + checkOrder(name2, name2next, ::isCompletelyLeftOf, ::isTopAlignedWith) 75 90 76 - clickOnViewWithText(coreR.string.types_filter_hide_all) 77 - checkActivity(name1, viewsR.color.colorFiltered) 78 - checkActivity(name2, viewsR.color.colorFiltered) 91 + clickOnViewWithText(coreR.string.select_nothing) 92 + checkViewIsDisplayed(withText(coreR.string.nothing_selected)) 93 + checkOrder(name1, name1next, ::isCompletelyLeftOf, ::isTopAlignedWith) 94 + checkOrder(name2, name2next, ::isCompletelyLeftOf, ::isTopAlignedWith) 79 95 80 96 // Try to save when nothing selected 81 97 clickOnViewWithText(coreR.string.duration_dialog_save) ··· 101 117 checkViewIsDisplayed( 102 118 allOf( 103 119 withId(baseR.id.viewRecordTypeItem), 104 - withCardColor(color), 120 + hasDescendant(withCardColor(color)), 105 121 hasDescendant(withText(name)), 106 122 ), 107 123 ) 124 + } 125 + 126 + private fun checkOrder( 127 + first: String, 128 + second: String, 129 + vararg matchers: (Matcher<View>) -> ViewAssertion, 130 + ) { 131 + matchers.forEach { matcher -> 132 + onView(allOf(isDescendantOfA(withId(baseR.id.viewRecordTypeItem)), withText(first))).check( 133 + matcher(allOf(isDescendantOfA(withId(baseR.id.viewRecordTypeItem)), withText(second))) 134 + ) 135 + } 108 136 } 109 137 }
+2 -2
app/src/androidTest/java/com/example/util/simpletimetracker/AddRecordTypeTest.kt
··· 78 78 79 79 // Selecting color 80 80 clickOnRecyclerItem(changeRecordTypeR.id.rvChangeRecordTypeColor, withCardColor(firstColor)) 81 - checkPreviewUpdated(withCardColor(firstColor)) 81 + checkPreviewUpdated(hasDescendant(withCardColor(firstColor))) 82 82 checkViewIsDisplayed( 83 83 allOf(withId(changeRecordTypeR.id.viewColorItemSelected), withParent(withCardColor(firstColor))), 84 84 ) ··· 86 86 // Selecting color 87 87 scrollRecyclerToPosition(changeRecordTypeR.id.rvChangeRecordTypeColor, lastColorPosition) 88 88 clickOnRecyclerItem(changeRecordTypeR.id.rvChangeRecordTypeColor, withCardColor(lastColor)) 89 - checkPreviewUpdated(withCardColor(lastColor)) 89 + checkPreviewUpdated(hasDescendant(withCardColor(lastColor))) 90 90 checkViewIsDisplayed( 91 91 allOf(withId(changeRecordTypeR.id.viewColorItemSelected), withParent(withCardColor(lastColor))), 92 92 )
+1 -1
app/src/androidTest/java/com/example/util/simpletimetracker/ArchiveTest.kt
··· 185 185 NavUtils.openRecordsScreen() 186 186 clickOnViewWithId(recordsR.id.btnRecordAdd) 187 187 clickOnViewWithText(coreR.string.change_record_type_field) 188 - clickOnView(withText(name1)) 188 + clickOnView(allOf(withId(R.id.viewRecordTypeItem), hasDescendant(withText(name1)))) 189 189 tryAction { checkTagVisible(tag1) } 190 190 checkTagNotVisible(tag2) 191 191 checkTagVisible(tag3)
+2
app/src/androidTest/java/com/example/util/simpletimetracker/ChangeCategoryTest.kt
··· 17 17 import com.example.util.simpletimetracker.utils.clickOnViewWithText 18 18 import com.example.util.simpletimetracker.utils.longClickOnView 19 19 import com.example.util.simpletimetracker.utils.scrollRecyclerToView 20 + import com.example.util.simpletimetracker.utils.tryAction 20 21 import com.example.util.simpletimetracker.utils.typeTextIntoView 21 22 import com.example.util.simpletimetracker.utils.withCardColor 22 23 import dagger.hilt.android.testing.HiltAndroidTest ··· 73 74 checkViewIsDisplayed( 74 75 allOf(withId(changeCategoryR.id.viewColorItemSelected), withParent(withCardColor(lastColor))) 75 76 ) 77 + clickOnViewWithText(coreR.string.change_record_type_color_hint) 76 78 77 79 clickOnViewWithText(coreR.string.change_category_types_hint) 78 80 onView(withText(typeName1)).check(isCompletelyAbove(withId(changeCategoryR.id.viewDividerItem)))
+2 -2
app/src/androidTest/java/com/example/util/simpletimetracker/ChangeRecordTypeTest.kt
··· 56 56 57 57 // Preview is updated 58 58 checkPreviewUpdated(hasDescendant(withText(name))) 59 - checkPreviewUpdated(withCardColor(firstColor)) 59 + checkPreviewUpdated(hasDescendant(withCardColor(firstColor))) 60 60 checkPreviewUpdated(hasDescendant(withTag(firstIcon))) 61 61 62 62 // Change item ··· 69 69 ) 70 70 scrollRecyclerToView(changeRecordTypeR.id.rvChangeRecordTypeColor, withCardColor(lastColor)) 71 71 clickOnRecyclerItem(changeRecordTypeR.id.rvChangeRecordTypeColor, withCardColor(lastColor)) 72 - checkPreviewUpdated(withCardColor(lastColor)) 72 + checkPreviewUpdated(hasDescendant(withCardColor(lastColor))) 73 73 checkViewIsDisplayed( 74 74 allOf(withId(changeRecordTypeR.id.viewColorItemSelected), withParent(withCardColor(lastColor))), 75 75 )
+5 -4
app/src/androidTest/java/com/example/util/simpletimetracker/CustomColorTest.kt
··· 190 190 // Select color 191 191 clickOnViewWithText(coreR.string.change_record_type_color_hint) 192 192 clickOnRecyclerItem(changeRecordTypeR.id.rvChangeRecordTypeColor, withCardColorInt(colorInt)) 193 - checkPreviewUpdated(withCardColorInt(colorInt)) 193 + checkPreviewUpdated(hasDescendant(withCardColorInt(colorInt))) 194 194 checkViewIsDisplayed(allOf(withId(dialogsR.id.viewColorItemSelected), withParent(withCardColorInt(colorInt)))) 195 195 196 196 // Check selected color is preselected on color selection ··· 211 211 clickOnViewWithText(coreR.string.duration_dialog_save) 212 212 213 213 // Check new color selected 214 - checkPreviewUpdated(withCardColorInt(customColorInt)) 214 + checkPreviewUpdated(hasDescendant(withCardColorInt(customColorInt))) 215 215 checkViewIsNotDisplayed( 216 216 allOf(withId(dialogsR.id.viewColorItemSelected), withParent(withCardColorInt(colorInt))) 217 217 ) ··· 231 231 checkViewIsDisplayed( 232 232 allOf( 233 233 withId(dialogsR.id.viewRecordTypeItem), 234 - withCardColorInt(customColorInt), 234 + hasDescendant(withCardColorInt(customColorInt)), 235 235 hasDescendant(withText(name)), 236 236 ) 237 237 ) 238 238 longClickOnView(withText(name)) 239 - checkPreviewUpdated(withCardColorInt(customColorInt)) 239 + checkPreviewUpdated(hasDescendant(withCardColorInt(customColorInt))) 240 240 clickOnViewWithText(coreR.string.change_record_type_color_hint) 241 241 checkViewIsDisplayed( 242 242 allOf( ··· 343 343 withParent(withId(dialogsR.id.layoutColorPaletteItem)) 344 344 ) 345 345 ) 346 + clickOnViewWithText(coreR.string.change_category_color_hint) 346 347 347 348 // Save tag 348 349 typeTextIntoView(changeCategoryR.id.etChangeCategoryName, categoryName)
+2 -1
app/src/androidTest/java/com/example/util/simpletimetracker/DeleteRecordTypeTest.kt
··· 35 35 val icon = firstIcon 36 36 37 37 // Add item 38 + Thread.sleep(1000) 38 39 testUtils.addActivity(name = name, color = color, icon = icon) 39 40 testUtils.addRecord(name) 40 41 ··· 44 45 withId(baseR.id.viewRecordTypeItem), 45 46 hasDescendant(withText(name)), 46 47 hasDescendant(withTag(icon)), 47 - withCardColor(color) 48 + hasDescendant(withCardColor(color)) 48 49 ) 49 50 ) 50 51 }
+1 -9
app/src/androidTest/java/com/example/util/simpletimetracker/SettingsTest.kt
··· 91 91 allOf(withText(coreR.string.untracked_time_name), isCompletelyDisplayed()), 92 92 ) 93 93 94 - // Add record 95 - NavUtils.addRecord(name) 96 - checkViewDoesNotExist( 97 - allOf(withText(coreR.string.untracked_time_name), isCompletelyDisplayed()), 98 - ) 99 - checkViewIsDisplayed(allOf(withText(name), isCompletelyDisplayed())) 100 - 101 94 // Change setting 102 95 NavUtils.openSettingsScreen() 103 96 onView(withId(settingsR.id.checkboxSettingsShowUntrackedInRecords)).perform(nestedScrollTo()) ··· 108 101 // Untracked is shown 109 102 NavUtils.openRecordsScreen() 110 103 checkViewIsDisplayed(allOf(withText(coreR.string.untracked_time_name), isCompletelyDisplayed())) 111 - checkViewIsDisplayed(allOf(withText(name), isCompletelyDisplayed())) 112 104 } 113 105 114 106 @Test ··· 142 134 143 135 // Add record 144 136 NavUtils.openRecordsScreen() 145 - NavUtils.addRecord(name) 137 + testUtils.addRecord(name) 146 138 NavUtils.openStatisticsScreen() 147 139 checkViewDoesNotExist( 148 140 allOf(withText(coreR.string.untracked_time_name), isCompletelyDisplayed()),
+1 -1
app/src/androidTest/java/com/example/util/simpletimetracker/Widget.kt
··· 53 53 checkViewIsDisplayed( 54 54 allOf( 55 55 withId(baseR.id.viewRecordTypeItem), 56 - withCardColor(color), 56 + hasDescendant(withCardColor(color)), 57 57 hasDescendant(withText(name)) 58 58 ) 59 59 )
+1 -1
app/src/androidTest/java/com/example/util/simpletimetracker/WidgetUniversal.kt
··· 202 202 checkViewIsDisplayed( 203 203 allOf( 204 204 withId(baseR.id.viewRecordTypeItem), 205 - withCardColor(color), 205 + hasDescendant(withCardColor(color)), 206 206 hasDescendant(withText(name)) 207 207 ) 208 208 )
+1
app/src/androidTest/java/com/example/util/simpletimetracker/utils/NavUtils.kt
··· 216 216 clickOnViewWithText(coreR.string.change_category_color_hint) 217 217 scrollRecyclerToView(changeCategoryR.id.rvChangeCategoryColor, withCardColor(color)) 218 218 clickOnRecyclerItem(changeCategoryR.id.rvChangeCategoryColor, withCardColor(color)) 219 + clickOnViewWithText(coreR.string.change_category_color_hint) 219 220 } 220 221 221 222 // Activities