diff --git a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseUserInterfaceTest.java b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseUserInterfaceTest.java index a7de248f9..142de3e92 100644 --- a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseUserInterfaceTest.java +++ b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/BaseUserInterfaceTest.java @@ -115,4 +115,10 @@ public class BaseUserInterfaceTest h4.setColor(2); habitList.update(h4); } + + protected void rotateDevice() throws Exception + { + device.setOrientationLeft(); + device.setOrientationNatural(); + } } diff --git a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/CommonSteps.java b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/CommonSteps.java index ab28be55b..1f8829353 100644 --- a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/CommonSteps.java +++ b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/CommonSteps.java @@ -19,7 +19,6 @@ package org.isoron.uhabits.acceptance.steps; -import android.os.*; import android.support.annotation.*; import android.support.test.espresso.*; import android.support.test.espresso.contrib.*; @@ -27,11 +26,9 @@ import android.support.test.uiautomator.*; import android.support.v7.widget.*; import org.isoron.uhabits.*; -import org.isoron.uhabits.R; import org.isoron.uhabits.activities.habits.list.*; -import static android.os.Build.VERSION.SDK_INT; -import static android.os.Build.VERSION_CODES.LOLLIPOP; +import static android.os.Build.VERSION.*; import static android.support.test.espresso.Espresso.*; import static android.support.test.espresso.action.ViewActions.*; import static android.support.test.espresso.assertion.PositionAssertions.*; diff --git a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/EditHabitSteps.java b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/EditHabitSteps.java index 467c33959..56440730c 100644 --- a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/EditHabitSteps.java +++ b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/steps/EditHabitSteps.java @@ -58,6 +58,28 @@ public class EditHabitSteps typeTextWithId(R.id.tvDescription, name); } + public static void setReminder() + { + onView(withId(R.id.tvReminderTime)).perform(click()); + onView(withId(R.id.done_button)).perform(click()); + } + + public static void clickReminderDays() + { + onView(withId(R.id.tvReminderDays)).perform(click()); + } + + public static void unselectAllDays() + { + onView(withText("Saturday")).perform(click()); + onView(withText("Sunday")).perform(click()); + onView(withText("Monday")).perform(click()); + onView(withText("Tuesday")).perform(click()); + onView(withText("Wednesday")).perform(click()); + onView(withText("Thursday")).perform(click()); + onView(withText("Friday")).perform(click()); + } + private static void typeTextWithId(int id, String name) { onView(withId(id)).perform(clearText(), typeText(name), closeSoftKeyboard()); diff --git a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/regression/SavedStateRegressionTest.kt b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/regression/SavedStateRegressionTest.kt new file mode 100644 index 000000000..59d28790d --- /dev/null +++ b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/regression/SavedStateRegressionTest.kt @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2020 Álinson Santos Xavier + * + * This file is part of Loop Habit Tracker. + * + * Loop Habit Tracker is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * Loop Habit Tracker is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +package org.isoron.uhabits.regression + +import android.support.test.filters.* + +import org.isoron.uhabits.* +import org.junit.* + +import org.isoron.uhabits.acceptance.steps.CommonSteps.* +import org.isoron.uhabits.acceptance.steps.EditHabitSteps.* +import org.isoron.uhabits.acceptance.steps.ListHabitsSteps.* +import org.isoron.uhabits.acceptance.steps.ListHabitsSteps.MenuItem.* +import org.isoron.uhabits.acceptance.steps.WidgetSteps.clickText + +@LargeTest +class SavedStateRegressionTest : BaseUserInterfaceTest() { + + @Test + @Throws(Exception::class) + fun shouldNotCrashWhenRotatingWeekdayPickedDialog() { + // https://github.com/iSoron/uhabits/issues/534 + launchApp() + clickMenu(ADD) + setReminder() + clickReminderDays() + unselectAllDays() + rotateDevice() + clickText("Monday") + } +}