diff --git a/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java b/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java index bdc2b2432..52422197a 100644 --- a/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java +++ b/app/src/androidTest/java/com/orgzly/android/espresso/QueryFragmentTest.java @@ -31,7 +31,9 @@ import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.startsWith; +import static org.junit.Assume.assumeTrue; +import android.icu.util.Calendar; import android.widget.DatePicker; import android.widget.TextView; import android.widget.TimePicker; @@ -58,7 +60,9 @@ public class QueryFragmentTest extends OrgzlyTest { @Override public void tearDown() throws Exception { super.tearDown(); - scenario.close(); + if (scenario != null) { + scenario.close(); + } } private void defaultSetUp() { @@ -811,11 +815,14 @@ public void testInactiveDeadline() { onNotesInSearch().check(matches(recyclerViewItemCount(0))); } - // FIXME: Fails at an hour (or less) from midnight @Test public void testScheduledTimestamp() { + Calendar calendar = Calendar.getInstance(); + // Skip this test if current time is less than an hour before midnight + assumeTrue(calendar.get(Calendar.HOUR_OF_DAY) < 23); + final long currentTime = calendar.getTimeInMillis(); String inOneHour = new OrgDateTime.Builder() - .setDateTime(System.currentTimeMillis() + 1000 * 60 * 60) + .setDateTime(currentTime + 1000 * 60 * 60) .setHasTime(true) .setIsActive(true) .build()