Fix acceptance tests

pull/316/head^2
Alinson S. Xavier 8 years ago
parent 2f7509b94e
commit 882ddba324

@ -13,7 +13,6 @@ android {
minSdkVersion 19
targetSdkVersion 25
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArgument "size", "medium"
javaCompileOptions {
annotationProcessorOptions {

@ -26,11 +26,10 @@ import com.linkedin.android.testbutler.*;
import org.isoron.uhabits.core.models.*;
import org.isoron.uhabits.core.preferences.*;
import org.isoron.uhabits.core.ui.screens.habits.list.*;
import org.isoron.uhabits.core.utils.*;
import org.junit.*;
import java.io.*;
import static android.support.test.InstrumentationRegistry.*;
import static android.support.test.uiautomator.UiDevice.*;
@ -48,6 +47,8 @@ public class BaseUserInterfaceTest
private HabitFixtures fixtures;
private HabitCardListCache cache;
public static void startActivity(Class cls)
{
Intent intent = new Intent();
@ -57,7 +58,7 @@ public class BaseUserInterfaceTest
}
@Before
public void setUp() throws IOException
public void setUp() throws Exception
{
TestButler.setup(getTargetContext());
TestButler.verifyAnimationsDisabled(getTargetContext());
@ -68,6 +69,7 @@ public class BaseUserInterfaceTest
component = app.getComponent();
habitList = component.getHabitList();
prefs = component.getPreferences();
cache = component.getHabitCardListCache();
fixtures = new HabitFixtures(component.getModelFactory(), habitList);
resetState();
}
@ -80,12 +82,14 @@ public class BaseUserInterfaceTest
TestButler.teardown(getTargetContext());
}
private void resetState()
private void resetState() throws Exception
{
prefs.reset();
prefs.setFirstRun(false);
prefs.updateLastHint(100, DateUtils.getStartOfToday());
fixtures.purgeHabits(habitList);
habitList.removeAll();
cache.refreshAllHabits();
Thread.sleep(1000);
Habit h1 = fixtures.createEmptyHabit();
h1.setName("Wake up early");

@ -25,8 +25,9 @@ import org.isoron.uhabits.*;
import static android.support.test.espresso.Espresso.*;
import static android.support.test.espresso.action.ViewActions.*;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.matcher.ViewMatchers.*;
import static org.isoron.uhabits.BaseUserInterfaceTest.device;
import static org.isoron.uhabits.BaseUserInterfaceTest.*;
public class EditHabitSteps
{
@ -59,6 +60,6 @@ public class EditHabitSteps
private static void typeTextWithId(int id, String name)
{
onView(withId(id)).perform(clearText(), typeText(name));
onView(withId(id)).perform(clearText(), typeText(name), closeSoftKeyboard());
}
}

@ -147,6 +147,7 @@ public abstract class HabitList implements Iterable<Habit>
List<Habit> copy = new LinkedList<>();
for (Habit h : this) copy.add(h);
for (Habit h : copy) remove(h);
observable.notifyListeners();
}
/**

Loading…
Cancel
Save