mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 17:18:52 -06:00
creating UI test for blank description
This commit is contained in:
@@ -39,6 +39,7 @@ import static androidx.test.uiautomator.UiDevice.*;
|
|||||||
public class BaseUserInterfaceTest
|
public class BaseUserInterfaceTest
|
||||||
{
|
{
|
||||||
private static final String PKG = "org.isoron.uhabits";
|
private static final String PKG = "org.isoron.uhabits";
|
||||||
|
public static final String EMPTY_DESCRIPTION_HABIT_NAME = "Read books";
|
||||||
|
|
||||||
public static UiDevice device;
|
public static UiDevice device;
|
||||||
|
|
||||||
@@ -97,24 +98,28 @@ public class BaseUserInterfaceTest
|
|||||||
Habit h1 = fixtures.createEmptyHabit();
|
Habit h1 = fixtures.createEmptyHabit();
|
||||||
h1.setName("Wake up early");
|
h1.setName("Wake up early");
|
||||||
h1.setQuestion("Did you wake up early today?");
|
h1.setQuestion("Did you wake up early today?");
|
||||||
|
h1.setDescription("test description 1");
|
||||||
h1.setColor(5);
|
h1.setColor(5);
|
||||||
habitList.update(h1);
|
habitList.update(h1);
|
||||||
|
|
||||||
Habit h2 = fixtures.createShortHabit();
|
Habit h2 = fixtures.createShortHabit();
|
||||||
h2.setName("Track time");
|
h2.setName("Track time");
|
||||||
h2.setQuestion("Did you track your time?");
|
h2.setQuestion("Did you track your time?");
|
||||||
|
h2.setDescription("test description 2");
|
||||||
h2.setColor(5);
|
h2.setColor(5);
|
||||||
habitList.update(h2);
|
habitList.update(h2);
|
||||||
|
|
||||||
Habit h3 = fixtures.createLongHabit();
|
Habit h3 = fixtures.createLongHabit();
|
||||||
h3.setName("Meditate");
|
h3.setName("Meditate");
|
||||||
h3.setQuestion("Did meditate today?");
|
h3.setQuestion("Did meditate today?");
|
||||||
|
h3.setDescription("test description 3");
|
||||||
h3.setColor(10);
|
h3.setColor(10);
|
||||||
habitList.update(h3);
|
habitList.update(h3);
|
||||||
|
|
||||||
Habit h4 = fixtures.createEmptyHabit();
|
Habit h4 = fixtures.createEmptyHabit();
|
||||||
h4.setName("Read books");
|
h4.setName(EMPTY_DESCRIPTION_HABIT_NAME);
|
||||||
h4.setQuestion("Did you read books today?");
|
h4.setQuestion("Did you read books today?");
|
||||||
|
h4.setDescription("");
|
||||||
h4.setColor(2);
|
h4.setColor(2);
|
||||||
habitList.update(h4);
|
habitList.update(h4);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,4 +194,12 @@ public class HabitsTest extends BaseUserInterfaceTest
|
|||||||
verifyDisplaysText("Track time");
|
verifyDisplaysText("Track time");
|
||||||
verifyDisplaysText("Wake up early");
|
verifyDisplaysText("Wake up early");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldHideNotesCard() throws Exception
|
||||||
|
{
|
||||||
|
launchApp();
|
||||||
|
clickText(EMPTY_DESCRIPTION_HABIT_NAME);
|
||||||
|
verifyShowsScreen(SHOW_HABIT, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,25 +19,40 @@
|
|||||||
|
|
||||||
package org.isoron.uhabits.acceptance.steps;
|
package org.isoron.uhabits.acceptance.steps;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.test.espresso.*;
|
|
||||||
import androidx.test.espresso.contrib.*;
|
|
||||||
import androidx.test.uiautomator.*;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
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.R;
|
||||||
import org.isoron.uhabits.activities.habits.list.*;
|
import org.isoron.uhabits.activities.habits.list.ListHabitsActivity;
|
||||||
|
|
||||||
import static android.os.Build.VERSION.*;
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
import static androidx.test.espresso.Espresso.*;
|
import static androidx.test.espresso.Espresso.onView;
|
||||||
import static androidx.test.espresso.action.ViewActions.*;
|
import static androidx.test.espresso.action.ViewActions.click;
|
||||||
import static androidx.test.espresso.assertion.PositionAssertions.*;
|
import static androidx.test.espresso.action.ViewActions.longClick;
|
||||||
import static androidx.test.espresso.assertion.ViewAssertions.*;
|
import static androidx.test.espresso.action.ViewActions.scrollTo;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.*;
|
import static androidx.test.espresso.assertion.PositionAssertions.isBelow;
|
||||||
import static junit.framework.Assert.*;
|
import static androidx.test.espresso.assertion.ViewAssertions.doesNotExist;
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
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
|
public class CommonSteps extends BaseUserInterfaceTest
|
||||||
{
|
{
|
||||||
@@ -152,7 +167,11 @@ public class CommonSteps extends BaseUserInterfaceTest
|
|||||||
LIST_HABITS, SHOW_HABIT, EDIT_HABIT
|
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)
|
switch(screen)
|
||||||
{
|
{
|
||||||
@@ -162,11 +181,15 @@ public class CommonSteps extends BaseUserInterfaceTest
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SHOW_HABIT:
|
case SHOW_HABIT:
|
||||||
|
Matcher<View> noteCardViewMatcher = notesCardVisibleExpected ? isDisplayed() :
|
||||||
|
withEffectiveVisibility(Visibility.GONE);
|
||||||
onView(withId(R.id.subtitleCard)).check(matches(isDisplayed()));
|
onView(withId(R.id.subtitleCard)).check(matches(isDisplayed()));
|
||||||
|
onView(withId(R.id.notesCard)).check(matches(noteCardViewMatcher));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EDIT_HABIT:
|
case EDIT_HABIT:
|
||||||
onView(withId(R.id.tvQuestion)).check(matches(isDisplayed()));
|
onView(withId(R.id.tvQuestion)).check(matches(isDisplayed()));
|
||||||
|
onView(withId(R.id.tvDescription)).check(matches(isDisplayed()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user