Skip to content

Commit aaed392

Browse files
committed
fix tests
1 parent b7ebb4f commit aaed392

File tree

25 files changed

+127
-38
lines changed

25 files changed

+127
-38
lines changed

.github/workflows/github_actions.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
strategy:
3838
fail-fast: false
3939
matrix:
40-
api-level: [21, 28, 29]
40+
api-level: [21, 23, 29, 32, 34]
4141

4242
steps:
4343
- name: Check out code
@@ -55,28 +55,18 @@ jobs:
5555
sudo udevadm control --reload-rules
5656
sudo udevadm trigger --name-match=kvm
5757
58-
- name: Run tests
59-
uses: reactivecircus/android-emulator-runner@v2
60-
with:
61-
api-level: ${{ matrix.api-level }}
62-
target: google_apis
63-
arch: x86_64
64-
disable-animations: true
65-
script: ./gradlew app:connectedPlayDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.notAnnotation=com.example.util.simpletimetracker.utils.Widget --stacktrace
58+
- name: Setup Android SDK
59+
uses: android-actions/setup-android@v3
6660

67-
# For some reason widget tests make other tests to fail, so run them separately.
68-
- name: Run widget tests
61+
- name: Run tests
6962
uses: reactivecircus/android-emulator-runner@v2
7063
with:
7164
api-level: ${{ matrix.api-level }}
7265
target: google_apis
7366
arch: x86_64
7467
disable-animations: true
75-
script: ./gradlew app:connectedPlayDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.example.util.simpletimetracker.utils.Widget --stacktrace
76-
77-
- name: Upload tests results
78-
if: ${{ failure() }}
79-
uses: actions/upload-artifact@v2
80-
with:
81-
name: android_tests_results
82-
path: app/build/reports/androidTests/connected
68+
script: |
69+
adb shell settings put global window_animation_scale 0
70+
adb shell settings put global transition_animation_scale 0
71+
adb shell settings put global animator_duration_scale 0
72+
./gradlew app:connectedPlayDebugAndroidTest --stacktrace

app/proguard-debug-rules.pro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
-keepclassmembers class com.example.util.simpletimetracker.feature_records.view.RecordsContainerFragment$Companion { void setViewPagerSmoothScroll(boolean); }
66
-keepclassmembers class com.example.util.simpletimetracker.feature_statistics.view.StatisticsContainerFragment$Companion { void setViewPagerSmoothScroll(boolean); }
77
-keepclassmembers class com.example.util.simpletimetracker.feature_views.pieChart.PieChartView$Companion { void setDisableAnimationsForTest(boolean); }
8+
-keepclassmembers class com.example.util.simpletimetracker.navigation.ScreenResolver$Companion { void setDisableAnimationsForTest(boolean); }
89
-keepclassmembers class com.example.util.simpletimetracker.core.mapper.ColorMapper$Companion { synthetic java.util.List getAvailableColors$default(com.example.util.simpletimetracker.core.mapper.ColorMapper$Companion,boolean,int,java.lang.Object); }
910
-keep class com.example.util.simpletimetracker.core.utils.CountingIdlingResourceProvider { *; }
1011
-keep class com.example.util.simpletimetracker.core.utils.TestUtils { *; }

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class AddCategoryTest : BaseUiTest() {
149149

150150
// Check types saved
151151
longClickOnView(withText(name))
152+
Thread.sleep(1000)
152153
clickOnViewWithText(coreR.string.change_category_types_hint)
153154
checkViewIsDisplayed(withText(coreR.string.something_selected))
154155
checkViewIsDisplayed(withId(baseR.id.viewDividerItem))
@@ -157,6 +158,7 @@ class AddCategoryTest : BaseUiTest() {
157158

158159
// Check goals saved
159160
clickOnViewWithText(coreR.string.change_category_types_hint)
161+
Thread.sleep(1000)
160162
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
161163
checkViewIsDisplayed(withText("10$minuteString"))
162164
}
@@ -197,6 +199,7 @@ class AddCategoryTest : BaseUiTest() {
197199
tryAction { longClickOnView(withText(typeName1)) }
198200

199201
// Add category
202+
Thread.sleep(1000)
200203
clickOnViewWithText(coreR.string.category_hint)
201204
clickOnViewWithText(coreR.string.categories_add_category)
202205
typeTextIntoView(changeCategoryR.id.etChangeCategoryName, categoryName1)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ class AddRecordTagTest : BaseUiTest() {
329329

330330
NavUtils.openRunningRecordsScreen()
331331
longClickOnView(withText(typeName1))
332+
Thread.sleep(1000)
332333
clickOnViewWithText(coreR.string.change_record_type_icon_image_hint)
333334
clickOnRecyclerItem(changeRecordTagR.id.rvIconSelection, withTag(newIcon))
334335
pressBack()

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class AddRecordTypeTest : BaseUiTest() {
176176
@Test
177177
fun addRecordTypeEmpty() {
178178
tryAction { clickOnViewWithText(coreR.string.running_records_add_type) }
179+
closeSoftKeyboard()
179180

180181
// Goal time is disabled
181182
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.example.util.simpletimetracker
22

33
import android.view.View
4+
import androidx.test.espresso.Espresso.onView
45
import androidx.test.espresso.Espresso.pressBack
56
import androidx.test.espresso.ViewInteraction
67
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
@@ -24,6 +25,7 @@ import com.example.util.simpletimetracker.utils.clickOnView
2425
import com.example.util.simpletimetracker.utils.clickOnViewWithId
2526
import com.example.util.simpletimetracker.utils.clickOnViewWithText
2627
import com.example.util.simpletimetracker.utils.longClickOnView
28+
import com.example.util.simpletimetracker.utils.nestedScrollTo
2729
import com.example.util.simpletimetracker.utils.scrollRecyclerInPagerToView
2830
import com.example.util.simpletimetracker.utils.tryAction
2931
import com.example.util.simpletimetracker.utils.withCardColor
@@ -68,8 +70,10 @@ class GoalsDaysOfWeek : BaseUiTest() {
6870

6971
// Check
7072
tryAction { longClickOnView(withText(name)) }
73+
onView(withText(R.string.change_record_type_goal_time_hint)).perform(nestedScrollTo())
7174
clickOnViewWithText(R.string.change_record_type_goal_time_hint)
7275

76+
onView(withId(changeRecordTypeR.id.layoutChangeRecordTypeGoalSession)).perform(nestedScrollTo())
7377
checkString(
7478
changeRecordTypeR.id.layoutChangeRecordTypeGoalSession,
7579
withText("1$secondString"),
@@ -81,6 +85,7 @@ class GoalsDaysOfWeek : BaseUiTest() {
8185
::checkViewDoesNotExist,
8286
)
8387

88+
onView(withId(changeRecordTypeR.id.layoutChangeRecordTypeGoalDaily)).perform(nestedScrollTo())
8489
checkString(
8590
changeRecordTypeR.id.layoutChangeRecordTypeGoalDaily,
8691
withText("1$secondString"),
@@ -92,6 +97,7 @@ class GoalsDaysOfWeek : BaseUiTest() {
9297
::checkViewIsDisplayed,
9398
)
9499

100+
onView(withId(changeRecordTypeR.id.layoutChangeRecordTypeGoalWeekly)).perform(nestedScrollTo())
95101
checkString(
96102
changeRecordTypeR.id.layoutChangeRecordTypeGoalWeekly,
97103
withText("1$secondString"),
@@ -103,6 +109,7 @@ class GoalsDaysOfWeek : BaseUiTest() {
103109
::checkViewDoesNotExist,
104110
)
105111

112+
onView(withId(changeRecordTypeR.id.layoutChangeRecordTypeGoalMonthly)).perform(nestedScrollTo())
106113
checkString(
107114
changeRecordTypeR.id.layoutChangeRecordTypeGoalMonthly,
108115
withText("1$secondString"),
@@ -125,6 +132,7 @@ class GoalsDaysOfWeek : BaseUiTest() {
125132
tryAction { longClickOnView(withText(name)) }
126133

127134
// No days by default
135+
onView(withText(R.string.change_record_type_goal_time_hint)).perform(nestedScrollTo())
128136
clickOnViewWithText(R.string.change_record_type_goal_time_hint)
129137
checkViewDoesNotExist(withText(R.string.day_of_week_sunday))
130138

@@ -198,6 +206,7 @@ class GoalsDaysOfWeek : BaseUiTest() {
198206

199207
// Change days
200208
tryAction { longClickOnView(withText(name1)) }
209+
onView(withText(R.string.change_record_type_goal_time_hint)).perform(nestedScrollTo())
201210
clickOnViewWithText(R.string.change_record_type_goal_time_hint)
202211
clickOnView(withText(R.string.day_of_week_monday))
203212
clickOnView(withText(R.string.day_of_week_wednesday))
@@ -206,6 +215,7 @@ class GoalsDaysOfWeek : BaseUiTest() {
206215

207216
// Days are saved
208217
tryAction { longClickOnView(withText(name1)) }
218+
onView(withText(R.string.change_record_type_goal_time_hint)).perform(nestedScrollTo())
209219
clickOnViewWithText(R.string.change_record_type_goal_time_hint)
210220
checkTypeDay(stringResId = R.string.day_of_week_sunday, colorResId = R.color.colorActive)
211221
checkTypeDay(stringResId = R.string.day_of_week_monday, colorResId = R.color.colorInactive)
@@ -218,6 +228,7 @@ class GoalsDaysOfWeek : BaseUiTest() {
218228
pressBack()
219229

220230
tryAction { longClickOnView(withText(name2)) }
231+
onView(withText(R.string.change_record_type_goal_time_hint)).perform(nestedScrollTo())
221232
clickOnViewWithText(R.string.change_record_type_goal_time_hint)
222233
daysResIdList.forEach { checkTypeDay(stringResId = it, colorResId = R.color.colorActive) }
223234
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import com.example.util.simpletimetracker.utils.checkViewIsDisplayed
3030
import com.example.util.simpletimetracker.utils.clickOnView
3131
import com.example.util.simpletimetracker.utils.clickOnViewWithText
3232
import com.example.util.simpletimetracker.utils.longClickOnView
33+
import com.example.util.simpletimetracker.utils.nestedScrollTo
3334
import com.example.util.simpletimetracker.utils.scrollRecyclerToView
3435
import com.example.util.simpletimetracker.utils.selectTabAtPosition
3536
import com.example.util.simpletimetracker.utils.tryAction
@@ -91,6 +92,7 @@ class GoalsTabTest : BaseUiTest() {
9192
is RecordTypeGoal.Type.Count -> goal.value.toString()
9293
}
9394

95+
onView(withId(layout)).perform(nestedScrollTo())
9496
checkViewIsDisplayed(
9597
allOf(
9698
isDescendantOfA(withId(layout)),
@@ -107,6 +109,7 @@ class GoalsTabTest : BaseUiTest() {
107109
goals.forEach { goalsToAdd ->
108110
// Add goals
109111
tryAction { longClickOnView(withText(type)) }
112+
onView(withText(coreR.string.change_record_type_goal_time_hint)).perform(nestedScrollTo())
110113
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
111114
goalsToAdd.forEach { goal ->
112115
NavUtils.addGoalToActivity(goal)
@@ -116,6 +119,7 @@ class GoalsTabTest : BaseUiTest() {
116119

117120
// Check goals saved
118121
longClickOnView(withText(type))
122+
onView(withText(coreR.string.change_record_type_goal_time_hint)).perform(nestedScrollTo())
119123
clickOnViewWithText(coreR.string.change_record_type_goal_time_hint)
120124
goalsToAdd.forEach { goal ->
121125
checkGoal(goal)

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import com.example.util.simpletimetracker.utils.clickOnView
2323
import com.example.util.simpletimetracker.utils.clickOnViewWithText
2424
import com.example.util.simpletimetracker.utils.getMillis
2525
import com.example.util.simpletimetracker.utils.longClickOnView
26+
import com.example.util.simpletimetracker.utils.nestedScrollTo
2627
import com.example.util.simpletimetracker.utils.scrollRecyclerToView
2728
import dagger.hilt.android.testing.HiltAndroidTest
2829
import kotlinx.coroutines.runBlocking
@@ -91,6 +92,7 @@ class RecordActionsAdjustTest : BaseUiTest() {
9192
adjust(isStart = true, buttonText = "-30")
9293
adjust(isStart = false, buttonText = "+30")
9394
adjust(isStart = false, buttonText = "+30")
95+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
9496
clickOnViewWithText(coreR.string.change_record_actions_hint)
9597
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_adjust))
9698
clickOnViewWithText(coreR.string.change_record_adjust)
@@ -176,6 +178,7 @@ class RecordActionsAdjustTest : BaseUiTest() {
176178
adjust(isStart = false, buttonText = "+1")
177179
clickOnViewWithText(coreR.string.change_record_type_field)
178180
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name2))
181+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
179182
clickOnViewWithText(coreR.string.change_record_actions_hint)
180183
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_adjust))
181184
clickOnViewWithText(coreR.string.change_record_adjust)
@@ -240,6 +243,7 @@ class RecordActionsAdjustTest : BaseUiTest() {
240243
allOf(isDescendantOfA(withId(baseR.id.viewRunningRecordItem)), withText(name2), isCompletelyDisplayed()),
241244
)
242245
clickOnViewWithText("-5")
246+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
243247
clickOnViewWithText(coreR.string.change_record_actions_hint)
244248
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_adjust))
245249
clickOnViewWithText(coreR.string.change_record_adjust)
@@ -292,6 +296,7 @@ class RecordActionsAdjustTest : BaseUiTest() {
292296
adjust(isStart = true, buttonText = "-30")
293297
adjust(isStart = false, buttonText = "+30")
294298
adjust(isStart = false, buttonText = "+30")
299+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
295300
clickOnViewWithText(coreR.string.change_record_actions_hint)
296301
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_adjust))
297302
clickOnViewWithText(coreR.string.change_record_adjust)
@@ -391,6 +396,7 @@ class RecordActionsAdjustTest : BaseUiTest() {
391396
}
392397

393398
// Deselect
399+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
394400
clickOnViewWithText(coreR.string.change_record_actions_hint)
395401

396402
scrollToView(name5)

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import com.example.util.simpletimetracker.utils.clickOnView
1717
import com.example.util.simpletimetracker.utils.clickOnViewWithId
1818
import com.example.util.simpletimetracker.utils.clickOnViewWithText
1919
import com.example.util.simpletimetracker.utils.longClickOnView
20+
import com.example.util.simpletimetracker.utils.nestedScrollTo
2021
import com.example.util.simpletimetracker.utils.recyclerItemCount
2122
import com.example.util.simpletimetracker.utils.scrollRecyclerToView
2223
import com.example.util.simpletimetracker.utils.tryAction
@@ -72,6 +73,7 @@ class RecordActionsContinueTest : BaseUiTest() {
7273

7374
// Continue
7475
clickOnViewWithText(fullName)
76+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
7577
clickOnViewWithText(coreR.string.change_record_actions_hint)
7678
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
7779
clickOnViewWithText(coreR.string.change_record_continue)
@@ -120,17 +122,20 @@ class RecordActionsContinueTest : BaseUiTest() {
120122
clickOnViewWithText(coreR.string.untracked_time_name)
121123

122124
// Continue untracked doesn't work
125+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
123126
clickOnViewWithText(coreR.string.change_record_actions_hint)
124127
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
125128
clickOnViewWithText(coreR.string.change_record_continue)
126129
clickOnViewWithId(com.google.android.material.R.id.snackbar_text)
130+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
127131
clickOnViewWithText(coreR.string.change_record_actions_hint)
128132

129133
// Select activity
130134
clickOnViewWithText(coreR.string.change_record_type_field)
131135
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name))
132136

133137
// Continue
138+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
134139
clickOnViewWithText(coreR.string.change_record_actions_hint)
135140
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
136141
clickOnViewWithText(coreR.string.change_record_continue)
@@ -178,17 +183,20 @@ class RecordActionsContinueTest : BaseUiTest() {
178183
clickOnViewWithId(recordsR.id.btnRecordAdd)
179184

180185
// Continue untracked doesn't work
186+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
181187
clickOnViewWithText(coreR.string.change_record_actions_hint)
182188
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
183189
clickOnViewWithText(coreR.string.change_record_continue)
184190
clickOnViewWithId(com.google.android.material.R.id.snackbar_text)
191+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
185192
clickOnViewWithText(coreR.string.change_record_actions_hint)
186193

187194
// Select activity
188195
clickOnViewWithText(coreR.string.change_record_type_field)
189196
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name))
190197

191198
// Continue
199+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
192200
clickOnViewWithText(coreR.string.change_record_actions_hint)
193201
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
194202
clickOnViewWithText(coreR.string.change_record_continue)
@@ -241,6 +249,7 @@ class RecordActionsContinueTest : BaseUiTest() {
241249
// Try continue record
242250
NavUtils.openRecordsScreen()
243251
clickOnView(allOf(withText(name), isCompletelyDisplayed()))
252+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
244253
clickOnViewWithText(coreR.string.change_record_actions_hint)
245254
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
246255
clickOnViewWithText(coreR.string.change_record_continue)
@@ -261,6 +270,7 @@ class RecordActionsContinueTest : BaseUiTest() {
261270
adjust("+30")
262271
adjust("+30")
263272
adjust("+5")
273+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
264274
clickOnViewWithText(coreR.string.change_record_actions_hint)
265275
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
266276
clickOnViewWithText(coreR.string.change_record_continue)
@@ -288,6 +298,7 @@ class RecordActionsContinueTest : BaseUiTest() {
288298
}
289299

290300
// Try continue record
301+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
291302
clickOnViewWithText(coreR.string.change_record_actions_hint)
292303
checkViewDoesNotExist(withText(coreR.string.change_record_continue))
293304
}
@@ -305,6 +316,7 @@ class RecordActionsContinueTest : BaseUiTest() {
305316
clickOnViewWithId(recordsR.id.btnRecordAdd)
306317
clickOnViewWithText(coreR.string.change_record_type_field)
307318
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name))
319+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
308320
clickOnViewWithText(coreR.string.change_record_actions_hint)
309321
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
310322
clickOnViewWithText(coreR.string.change_record_continue)
@@ -337,6 +349,7 @@ class RecordActionsContinueTest : BaseUiTest() {
337349
clickOnViewWithId(recordsR.id.btnRecordAdd)
338350
clickOnViewWithText(coreR.string.change_record_type_field)
339351
clickOnRecyclerItem(changeRecordR.id.rvChangeRecordType, withText(name2))
352+
onView(withText(coreR.string.change_record_actions_hint)).perform(nestedScrollTo())
340353
clickOnViewWithText(coreR.string.change_record_actions_hint)
341354
scrollRecyclerToView(changeRecordR.id.rvChangeRecordAction, withText(coreR.string.change_record_continue))
342355
clickOnViewWithText(coreR.string.change_record_continue)

0 commit comments

Comments
 (0)