Skip to content

Commit 25e2168

Browse files
committed
fix tests
1 parent c8ac08a commit 25e2168

5 files changed

Lines changed: 20 additions & 13 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ class RecordActionsDuplicateTest : BaseUiTest() {
196196
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name))
197197
clickOnViewWithText(coreR.string.change_record_comment_field)
198198
typeTextIntoView(changeRecordR.id.etChangeRecordCommentField, comment)
199-
closeSoftKeyboard()
200199
clickOnViewWithText(coreR.string.change_record_comment_field)
201200

202201
// Duplicate

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import com.example.util.simpletimetracker.utils.checkViewDoesNotExist
3535
import com.example.util.simpletimetracker.utils.checkViewIsDisplayed
3636
import com.example.util.simpletimetracker.utils.checkViewIsNotDisplayed
3737
import com.example.util.simpletimetracker.utils.clickOnCurrentDate
38+
import com.example.util.simpletimetracker.utils.clickOnCurrentSelectedDate
3839
import com.example.util.simpletimetracker.utils.clickOnPrevDate
3940
import com.example.util.simpletimetracker.utils.clickOnRecyclerItem
4041
import com.example.util.simpletimetracker.utils.clickOnView
@@ -1320,7 +1321,7 @@ class SettingsTest : BaseUiTest() {
13201321

13211322
// Check detailed statistics
13221323
clickOnView(allOf(withText(name), isCompletelyDisplayed()))
1323-
tryAction { clickOnCurrentDate() }
1324+
clickOnCurrentSelectedDate()
13241325
clickOnViewWithText(coreR.string.range_day)
13251326
checkStatisticsDetailRecords(0)
13261327
clickOnCurrentDate(-1)

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.example.util.simpletimetracker.utils.NavUtils
1717
import com.example.util.simpletimetracker.utils.checkViewDoesNotExist
1818
import com.example.util.simpletimetracker.utils.checkViewIsDisplayed
1919
import com.example.util.simpletimetracker.utils.clickOnCurrentDate
20+
import com.example.util.simpletimetracker.utils.clickOnCurrentSelectedDate
2021
import com.example.util.simpletimetracker.utils.clickOnNextDate
2122
import com.example.util.simpletimetracker.utils.clickOnView
2223
import com.example.util.simpletimetracker.utils.clickOnViewWithText
@@ -104,7 +105,7 @@ class StatisticsDetailTest : BaseUiTest() {
104105
tryAction { clickOnView(allOf(withText(name), isCompletelyDisplayed())) }
105106

106107
// Check one day
107-
clickOnCurrentDate()
108+
clickOnCurrentSelectedDate()
108109
clickOnViewWithText(coreR.string.range_custom)
109110
NavUtils.setCustomRange(
110111
yearStarted = calendarToday.get(Calendar.YEAR),
@@ -614,7 +615,7 @@ class StatisticsDetailTest : BaseUiTest() {
614615
checkPreview(color, icon, name)
615616

616617
// Switch range
617-
clickOnCurrentDate()
618+
clickOnCurrentSelectedDate()
618619
clickOnViewWithText(coreR.string.range_week)
619620

620621
// Daily calendar
@@ -988,7 +989,7 @@ class StatisticsDetailTest : BaseUiTest() {
988989
checkPreview(color, icon, name)
989990

990991
// Switch range
991-
clickOnCurrentDate()
992+
clickOnCurrentSelectedDate()
992993
clickOnView(withPluralText(coreR.plurals.range_last, 7, 7))
993994
clickOnViewWithText(coreR.string.duration_dialog_save)
994995

@@ -1165,7 +1166,7 @@ class StatisticsDetailTest : BaseUiTest() {
11651166
NavUtils.openStatisticsScreen()
11661167
tryAction { clickOnView(allOf(withText(coreR.string.untracked_time_name), isCompletelyDisplayed())) }
11671168

1168-
clickOnCurrentDate(-1)
1169+
tryAction { clickOnCurrentDate(-1) }
11691170
checkCard(coreR.string.statistics_detail_total_duration, "24$hourString 0$minuteString")
11701171
checkRecordsCard(1)
11711172
checkCard(coreR.string.statistics_detail_average_record, "24$hourString 0$minuteString")
@@ -1290,7 +1291,7 @@ class StatisticsDetailTest : BaseUiTest() {
12901291
// Check on one record
12911292
NavUtils.openStatisticsScreen()
12921293
tryAction { clickOnView(allOf(withText(name1), isCompletelyDisplayed())) }
1293-
clickOnCurrentDate()
1294+
clickOnCurrentSelectedDate()
12941295
clickOnViewWithText(coreR.string.range_overall)
12951296
checkViewDoesNotExist(
12961297
allOf(withTag(StatisticsDetailBlock.ChartSplitByActivity), isCompletelyDisplayed()),

app/src/androidTest/java/com/example/util/simpletimetracker/utils/ViewActions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ fun scrollToBottom(): ViewAction = object : ViewAction {
243243
}
244244

245245
fun tryAction(action: () -> Unit) {
246-
repeat(5) {
246+
repeat(3) {
247247
try {
248248
action()
249249
return
250-
} catch (e: Throwable) {
250+
} catch (_: Throwable) {
251251
Thread.sleep(1000)
252252
}
253253
}
@@ -261,7 +261,7 @@ fun tryActionWithFallback(
261261
try {
262262
action()
263263
return
264-
} catch (e: Throwable) {
264+
} catch (_: Throwable) {
265265
onError.invoke()
266266
}
267267
action()

app/src/androidTest/java/com/example/util/simpletimetracker/utils/ViewInteractions.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:Suppress("unused")
2+
13
package com.example.util.simpletimetracker.utils
24

35
import android.view.View
@@ -42,15 +44,19 @@ fun typeTextIntoView(id: Int, text: String): ViewInteraction =
4244
fun clickOnViewWithId(id: Int): ViewInteraction =
4345
onView(withId(id)).perform(click())
4446

45-
fun clickOnPrevDate(): ViewInteraction =
47+
fun clickOnPrevDate() {
4648
unconstrainedClickOnView(dateSelectorMatcher(-1))
49+
Thread.sleep(200) // Wait for scroll.
50+
}
4751

48-
fun clickOnNextDate(): ViewInteraction =
52+
fun clickOnNextDate() {
4953
unconstrainedClickOnView(dateSelectorMatcher(1))
54+
Thread.sleep(200) // Wait for scroll.
55+
}
5056

5157
fun clickOnCurrentDate(position: Int = 0) {
5258
unconstrainedClickOnView(dateSelectorMatcher(position))
53-
Thread.sleep(200)
59+
Thread.sleep(200) // Wait for scroll.
5460
}
5561

5662
fun clickOnCurrentSelectedDate() {

0 commit comments

Comments
 (0)