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 96634a23c..6b5a1931c 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 @@ -39,6 +39,7 @@ import static androidx.test.uiautomator.UiDevice.*; public class BaseUserInterfaceTest { private static final String PKG = "org.isoron.uhabits"; + public static final String EMPTY_DESCRIPTION_HABIT_NAME = "Read books"; public static UiDevice device; @@ -97,24 +98,28 @@ public class BaseUserInterfaceTest Habit h1 = fixtures.createEmptyHabit(); h1.setName("Wake up early"); h1.setQuestion("Did you wake up early today?"); + h1.setDescription("test description 1"); h1.setColor(5); habitList.update(h1); Habit h2 = fixtures.createShortHabit(); h2.setName("Track time"); h2.setQuestion("Did you track your time?"); + h2.setDescription("test description 2"); h2.setColor(5); habitList.update(h2); Habit h3 = fixtures.createLongHabit(); h3.setName("Meditate"); h3.setQuestion("Did meditate today?"); + h3.setDescription("test description 3"); h3.setColor(10); habitList.update(h3); Habit h4 = fixtures.createEmptyHabit(); - h4.setName("Read books"); + h4.setName(EMPTY_DESCRIPTION_HABIT_NAME); h4.setQuestion("Did you read books today?"); + h4.setDescription(""); h4.setColor(2); habitList.update(h4); } diff --git a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/HabitsTest.java b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/HabitsTest.java index 2d92e70a7..87f38a660 100644 --- a/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/HabitsTest.java +++ b/android/uhabits-android/src/androidTest/java/org/isoron/uhabits/acceptance/HabitsTest.java @@ -194,4 +194,12 @@ public class HabitsTest extends BaseUserInterfaceTest verifyDisplaysText("Track time"); verifyDisplaysText("Wake up early"); } + + @Test + public void shouldHideNotesCard() throws Exception + { + launchApp(); + clickText(EMPTY_DESCRIPTION_HABIT_NAME); + verifyShowsScreen(SHOW_HABIT, false); + } } 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 216e6e075..9e36a2038 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,25 +19,40 @@ package org.isoron.uhabits.acceptance.steps; +import android.view.View; + import androidx.annotation.StringRes; -import androidx.test.espresso.*; -import androidx.test.espresso.contrib.*; -import androidx.test.uiautomator.*; - import androidx.recyclerview.widget.RecyclerView; +import androidx.test.espresso.PerformException; +import androidx.test.espresso.contrib.RecyclerViewActions; +import androidx.test.uiautomator.By; +import androidx.test.uiautomator.UiSelector; +import androidx.test.uiautomator.Until; -import org.isoron.uhabits.*; +import org.hamcrest.Matcher; +import org.isoron.uhabits.BaseUserInterfaceTest; import org.isoron.uhabits.R; -import org.isoron.uhabits.activities.habits.list.*; +import org.isoron.uhabits.activities.habits.list.ListHabitsActivity; -import static android.os.Build.VERSION.*; -import static androidx.test.espresso.Espresso.*; -import static androidx.test.espresso.action.ViewActions.*; -import static androidx.test.espresso.assertion.PositionAssertions.*; -import static androidx.test.espresso.assertion.ViewAssertions.*; -import static androidx.test.espresso.matcher.ViewMatchers.*; -import static junit.framework.Assert.*; -import static org.hamcrest.CoreMatchers.*; +import static android.os.Build.VERSION.SDK_INT; +import static androidx.test.espresso.Espresso.onView; +import static androidx.test.espresso.action.ViewActions.click; +import static androidx.test.espresso.action.ViewActions.longClick; +import static androidx.test.espresso.action.ViewActions.scrollTo; +import static androidx.test.espresso.assertion.PositionAssertions.isBelow; +import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist; +import static androidx.test.espresso.assertion.ViewAssertions.matches; +import static androidx.test.espresso.matcher.ViewMatchers.Visibility; +import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant; +import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; +import static androidx.test.espresso.matcher.ViewMatchers.isEnabled; +import static androidx.test.espresso.matcher.ViewMatchers.withClassName; +import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; +import static androidx.test.espresso.matcher.ViewMatchers.withId; +import static androidx.test.espresso.matcher.ViewMatchers.withText; +import static junit.framework.Assert.assertTrue; +import static org.hamcrest.CoreMatchers.endsWith; +import static org.hamcrest.CoreMatchers.instanceOf; public class CommonSteps extends BaseUserInterfaceTest { @@ -152,7 +167,11 @@ public class CommonSteps extends BaseUserInterfaceTest LIST_HABITS, SHOW_HABIT, EDIT_HABIT } - public static void verifyShowsScreen(Screen screen) + public static void verifyShowsScreen(Screen screen) { + verifyShowsScreen(screen, true); + } + + public static void verifyShowsScreen(Screen screen, boolean notesCardVisibleExpected) { switch(screen) { @@ -162,11 +181,15 @@ public class CommonSteps extends BaseUserInterfaceTest break; case SHOW_HABIT: + Matcher noteCardViewMatcher = notesCardVisibleExpected ? isDisplayed() : + withEffectiveVisibility(Visibility.GONE); onView(withId(R.id.subtitleCard)).check(matches(isDisplayed())); + onView(withId(R.id.notesCard)).check(matches(noteCardViewMatcher)); break; case EDIT_HABIT: onView(withId(R.id.tvQuestion)).check(matches(isDisplayed())); + onView(withId(R.id.tvDescription)).check(matches(isDisplayed())); break; } }