@@ -5,6 +5,7 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
55import androidx.test.espresso.matcher.ViewMatchers.withText
66import androidx.test.ext.junit.runners.AndroidJUnit4
77import com.example.util.simpletimetracker.core.mapper.ColorMapper
8+ import com.example.util.simpletimetracker.domain.darkMode.model.DarkMode
89import com.example.util.simpletimetracker.domain.recordType.model.CardOrder
910import com.example.util.simpletimetracker.domain.recordType.model.RecordType
1011import com.example.util.simpletimetracker.domain.statistics.model.RangeLength
@@ -27,40 +28,85 @@ import java.util.concurrent.TimeUnit
2728@RunWith(AndroidJUnit4 ::class )
2829class ScreenCaptureTest : BaseUiTest () {
2930
31+ override fun setUp () {
32+ super .setUp()
33+ runBlocking {
34+ prefsInteractor.setDarkMode(DarkMode .Enabled )
35+ }
36+ }
37+
38+ override fun after () {
39+ // Do not call super in order to keep prefs.
40+ }
41+
3042 @Test
3143 fun screenshots () {
44+ val isMainTabComplex = false
45+ val showGoals = true
46+ val showMainButtons = true
47+
3248 val colors = ColorMapper .getAvailableColors()
3349 val icons = iconImageMapper
3450 .getAvailableImages(loadSearchHints = false ).values
3551 .flatten().associateBy { it.iconName }.mapValues { it.value.iconResId }
3652 val readType = " Read"
53+ val workType = " Work"
3754 val guitarType = " Guitar"
3855 val readTag = " Mody Dick"
56+ val workTag1 = " Home"
57+ val workTag2 = " Office"
3958 val readComment = " I think it's related to the whale"
59+ val mainFilter = " Main"
4060
4161 // Add data
4262 runBlocking {
4363 prefsInteractor.setCardOrder(CardOrder .COLOR )
4464 prefsInteractor.setNumberOfCards(5 )
4565 prefsInteractor.setShowNotifications(true )
46- prefsInteractor.setEnableRepeatButton(true )
66+ prefsInteractor.setEnableRepeatButton(showMainButtons)
67+ prefsInteractor.setDefaultTypesHidden(true )
4768 prefsInteractor.setStatisticsDetailRange(RangeLength .All )
48- val pomodoroStarted = System .currentTimeMillis() - TimeUnit .MINUTES .toMillis(7 )
49- prefsInteractor.setPomodoroModeStartedTimestampMs(pomodoroStarted)
69+ prefsInteractor.setEnablePomodoroMode(showMainButtons)
70+ if (showMainButtons) {
71+ val pomodoroStarted = System .currentTimeMillis() - TimeUnit .MINUTES .toMillis(7 )
72+ prefsInteractor.setPomodoroModeStartedTimestampMs(pomodoroStarted)
73+ }
5074 }
5175 defaultTypes.forEach { type ->
5276 testUtils.addActivity(
5377 name = type.name,
5478 color = colors.getOrNull(type.colorId),
5579 icon = icons[type.icon],
56- goals = if (type.goal != null ) {
80+ goals = if (type.goal != null && showGoals ) {
5781 GoalsTestUtils .getDailyDurationGoal(type.goal * 60L ).let (::listOf)
5882 } else {
5983 emptyList()
6084 },
6185 )
6286 }
87+ defaultCategories.forEach { category ->
88+ testUtils.addCategory(
89+ tagName = category.name,
90+ color = colors.getOrNull(category.colorId),
91+ )
92+ }
6393 testUtils.addRecordTag(tagName = readTag, typeName = readType)
94+ testUtils.addRecordTag(tagName = workTag1, typeName = workType)
95+ testUtils.addRecordTag(tagName = workTag2, typeName = workType)
96+ if (isMainTabComplex) {
97+ testUtils.addActivityFilter(
98+ name = mainFilter,
99+ color = colors.getOrNull(1 ),
100+ names = mainFilterTypes,
101+ selected = true ,
102+ )
103+
104+ testUtils.addShortcut(readType, listOf (readTag))
105+ testUtils.addShortcut(workType, listOf (workTag1))
106+ testUtils.addShortcut(workType, listOf (workTag2))
107+
108+ testUtils.addSuggestion(readType, listOf (" Sleep" , " Work" , " Tv" ))
109+ }
64110 runBlocking {
65111 val filteredInStatistics = listOf (" Work" , " Sleep" , " Commute" )
66112 recordTypeRepo.getAll()
@@ -147,6 +193,14 @@ class ScreenCaptureTest : BaseUiTest() {
147193 clickOnViewWithText(R .string.change_record_tag_field)
148194 clickOnRecyclerItem(R .id.rvChangeRecordCategories, withText(readTag))
149195 clickOnViewWithText(R .string.change_record_save)
196+
197+ // Main tab complex
198+ if (isMainTabComplex) {
199+ runBlocking {
200+ prefsInteractor.setShowActivityFilters(true )
201+ prefsInteractor.setShowCategoriesAsPredefinedFilters(true )
202+ }
203+ }
150204 }
151205
152206 companion object {
@@ -157,6 +211,28 @@ class ScreenCaptureTest : BaseUiTest() {
157211 val goal : Int? = null , // Minutes
158212 )
159213
214+ private data class DefaultCategory (
215+ val name : String ,
216+ val colorId : Int ,
217+ )
218+
219+ private val mainFilterTypes: List <String > by lazy {
220+ listOf (
221+ " Games" ,
222+ " Tv" ,
223+ " Exercise" ,
224+ " Meditate" ,
225+ " Read" ,
226+ " Chores" ,
227+ " Indoors" ,
228+ " Outdoors" ,
229+ " Cooking" ,
230+ " Sleep" ,
231+ " Work" ,
232+ " Commute" ,
233+ )
234+ }
235+
160236 private val defaultTypes: List <DefaultRecordType > by lazy {
161237 listOf (
162238 DefaultRecordType (name = " Games" , icon = " ic_headset_24px" , colorId = 1 ),
@@ -185,5 +261,17 @@ class ScreenCaptureTest : BaseUiTest() {
185261 DefaultRecordType (name = " Work" , icon = " ic_business_center_24px" , colorId = 10 , goal = 8 * 60 ),
186262 )
187263 }
264+
265+ private val defaultCategories: List <DefaultCategory > by lazy {
266+ listOf (
267+ // DefaultCategory(name = "Chores", colorId = 5),
268+ // DefaultCategory(name = "Food", colorId = 7),
269+ DefaultCategory (name = " Leisure" , colorId = 1 ),
270+ DefaultCategory (name = " Productive" , colorId = 3 ),
271+ // DefaultCategory(name = "Rest", colorId = 5),
272+ // DefaultCategory(name = "Sleep", colorId = 10),
273+ // DefaultCategory(name = "Work", colorId = 10),
274+ )
275+ }
188276 }
189277}
0 commit comments