mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Implement test reproducing #713
This commit is contained in:
@@ -69,6 +69,10 @@ object CommonSteps : BaseUserInterfaceTest() {
|
||||
device.waitForIdle()
|
||||
}
|
||||
|
||||
fun offsetHeaders() {
|
||||
device.swipe(750, 160, 600, 160, 20)
|
||||
}
|
||||
|
||||
fun scrollToText(text: String?) {
|
||||
try {
|
||||
if (device
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.isoron.uhabits.regression
|
||||
|
||||
import android.view.View
|
||||
import androidx.test.espresso.NoMatchingViewException
|
||||
import androidx.test.espresso.ViewAssertion
|
||||
import androidx.test.espresso.matcher.ViewMatchers.assertThat
|
||||
import org.hamcrest.CoreMatchers.equalTo
|
||||
import org.isoron.uhabits.activities.habits.list.views.HabitCardView
|
||||
|
||||
class HasButtonsViewAssertion(private val buttons: List<Int>) : ViewAssertion {
|
||||
override fun check(view: View?, noViewFoundException: NoMatchingViewException?) {
|
||||
if (noViewFoundException != null) {
|
||||
throw noViewFoundException
|
||||
}
|
||||
|
||||
if (view !is HabitCardView) {
|
||||
throw IllegalStateException("Not an HabitCardView.")
|
||||
}
|
||||
|
||||
for (p in view.checkmarkPanel.buttons zip buttons) {
|
||||
assertThat("", p.first.value, equalTo(p.second))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,11 @@
|
||||
|
||||
package org.isoron.uhabits.regression
|
||||
|
||||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.filters.LargeTest
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.isoron.uhabits.BaseUserInterfaceTest
|
||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.Screen.EDIT_HABIT
|
||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.Screen.LIST_HABITS
|
||||
@@ -27,6 +31,8 @@ import org.isoron.uhabits.acceptance.steps.CommonSteps.Screen.SELECT_HABIT_TYPE
|
||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.clickText
|
||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.launchApp
|
||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.longClickText
|
||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.offsetHeaders
|
||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.scrollToText
|
||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.verifyDisplaysText
|
||||
import org.isoron.uhabits.acceptance.steps.CommonSteps.verifyShowsScreen
|
||||
import org.isoron.uhabits.acceptance.steps.EditHabitSteps.clickSave
|
||||
@@ -62,4 +68,55 @@ class ListHabitsRegressionTest : BaseUserInterfaceTest() {
|
||||
verifyDisplaysText("Hello world")
|
||||
longPressCheckmarks("Hello world", 3)
|
||||
}
|
||||
|
||||
/**
|
||||
* https://github.com/iSoron/uhabits/issues/713
|
||||
*/
|
||||
@Test
|
||||
@Throws(Exception::class)
|
||||
fun should_update_out_of_screen_checkmarks_when_scrolling_horizontally() {
|
||||
launchApp()
|
||||
|
||||
verifyShowsScreen(LIST_HABITS)
|
||||
longPressCheckmarks("Wake up early", 1)
|
||||
|
||||
verifyShowsScreen(LIST_HABITS)
|
||||
assertCorrectNumberCheckmarks(listOf(2, -1, -1, -1))
|
||||
|
||||
fun createHabit(habitName: String) {
|
||||
clickMenu(ADD)
|
||||
verifyShowsScreen(SELECT_HABIT_TYPE)
|
||||
clickText("Yes or No")
|
||||
|
||||
verifyShowsScreen(EDIT_HABIT)
|
||||
typeName(habitName)
|
||||
clickSave()
|
||||
}
|
||||
|
||||
createHabit("H")
|
||||
createHabit("H")
|
||||
createHabit("H")
|
||||
createHabit("H")
|
||||
createHabit("H")
|
||||
createHabit("H")
|
||||
createHabit("H")
|
||||
createHabit("Last Habit")
|
||||
|
||||
scrollToText("Last Habit")
|
||||
offsetHeaders()
|
||||
assertCorrectNumberCheckmarks(listOf(-1, -1, -1, -1))
|
||||
}
|
||||
|
||||
private fun assertCorrectNumberCheckmarks(vals: List<Int>) {
|
||||
val habit = "Wake up early"
|
||||
|
||||
scrollToText(habit)
|
||||
|
||||
Espresso.onView(
|
||||
allOf(
|
||||
ViewMatchers.hasDescendant(ViewMatchers.withText(habit)),
|
||||
ViewMatchers.withClassName(CoreMatchers.endsWith("HabitCardView"))
|
||||
)
|
||||
).check(HasButtonsViewAssertion(vals))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class HabitCardView(
|
||||
numberPanel.threshold = value
|
||||
}
|
||||
|
||||
private var checkmarkPanel: CheckmarkPanelView
|
||||
var checkmarkPanel: CheckmarkPanelView
|
||||
private var numberPanel: NumberPanelView
|
||||
private var innerFrame: LinearLayout
|
||||
private var label: TextView
|
||||
|
||||
Reference in New Issue
Block a user