forked from plusonelabs/calendar-widget
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
178 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
package org.andstatus.todoagenda; | ||
|
||
import android.test.InstrumentationTestCase; | ||
|
||
import org.andstatus.todoagenda.provider.MockCalendarContentProvider; | ||
import org.joda.time.DateTime; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
public class BaseWidgetTest extends InstrumentationTestCase { | ||
public class BaseWidgetTest { | ||
|
||
final String TAG = this.getClass().getSimpleName(); | ||
|
||
|
@@ -19,18 +21,16 @@ protected int getNumberOfOpenTasksSources() { | |
return 0; | ||
} | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
@Before | ||
public void setUp() throws Exception { | ||
provider = MockCalendarContentProvider.getContentProvider(this, getNumberOfOpenTasksSources()); | ||
factory = new EventRemoteViewsFactory(provider.getContext(), provider.getWidgetId()); | ||
assertTrue(factory.getWidgetEntries().isEmpty()); | ||
} | ||
|
||
@Override | ||
protected void tearDown() throws Exception { | ||
@After | ||
public void tearDown() throws Exception { | ||
provider.tearDown(); | ||
super.tearDown(); | ||
} | ||
|
||
DateTime dateTime( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,22 @@ | |
import org.andstatus.todoagenda.widget.CalendarEntry; | ||
import org.joda.time.DateTime; | ||
import org.json.JSONException; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
public class BirthdayTest extends BaseWidgetTest { | ||
|
||
@Test | ||
public void testBirthdayOneDayOnly() throws IOException, JSONException { | ||
QueryResultsStorage inputs = provider.loadResults(this.getInstrumentation().getContext(), | ||
QueryResultsStorage inputs = provider.loadResults(InstrumentationRegistry.getInstrumentation().getContext(), | ||
org.andstatus.todoagenda.tests.R.raw.birthday); | ||
|
||
provider.startEditing(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,17 @@ | |
import org.joda.time.DateTime; | ||
import org.joda.time.DateTimeZone; | ||
import org.joda.time.LocalDateTime; | ||
import org.junit.Test; | ||
|
||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
|
@@ -28,6 +32,7 @@ public class IllegalInstantDueToTimeZoneTransitionTest extends BaseWidgetTest { | |
* <p> | ||
* I couldn't reproduce the problem though. | ||
*/ | ||
@Test | ||
public void testIllegalInstantDueToTimeZoneOffsetTransition() { | ||
reproducedTimeZoneOffsetTransitionException(); | ||
oneTimeDst("2014-09-07T00:00:00+00:00"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,17 +9,24 @@ | |
import org.andstatus.todoagenda.widget.WidgetEntry; | ||
import org.joda.time.DateTime; | ||
import org.json.JSONException; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
public class MultidayAllDayEventTest extends BaseWidgetTest { | ||
|
||
@Test | ||
public void testInsidePeriod() throws IOException, JSONException { | ||
final String method = "testInsidePeriod"; | ||
QueryResultsStorage inputs = provider.loadResults(this.getInstrumentation().getContext(), | ||
QueryResultsStorage inputs = provider.loadResults(InstrumentationRegistry.getInstrumentation().getContext(), | ||
org.andstatus.todoagenda.tests.R.raw.multi_day); | ||
provider.addResults(inputs.getResults()); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,13 @@ | |
import org.andstatus.todoagenda.widget.CalendarEntry; | ||
import org.andstatus.todoagenda.widget.WidgetEntry; | ||
import org.joda.time.DateTime; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* @author [email protected] | ||
|
@@ -20,6 +27,7 @@ public class MultidayEventTest extends BaseWidgetTest { | |
/** | ||
* Issue #206 https://github.com/plusonelabs/calendar-widget/issues/206 | ||
*/ | ||
@Test | ||
public void testEventWhichCarryOverToTheNextDay() { | ||
DateTime today = DateUtil.now(provider.getSettings().getTimeZone()).withTimeAtStartOfDay(); | ||
CalendarEvent event = new CalendarEvent(provider.getContext(), provider.getWidgetId(), | ||
|
@@ -64,6 +72,7 @@ public void testEventWhichCarryOverToTheNextDay() { | |
/** | ||
* https://github.com/plusonelabs/calendar-widget/issues/184#issuecomment-142671469 | ||
*/ | ||
@Test | ||
public void testThreeDaysEvent() { | ||
DateTime friday = dateTime(2015, 9, 18); | ||
DateTime sunday = friday.plusDays(2); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,12 @@ | |
import org.andstatus.todoagenda.widget.CalendarEntry; | ||
import org.andstatus.todoagenda.widget.WidgetEntry; | ||
import org.joda.time.DateTime; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* @author [email protected] | ||
|
@@ -16,6 +22,7 @@ public class OngoingEventTest extends BaseWidgetTest { | |
/** | ||
* @see <a href="https://github.com/plusonelabs/calendar-widget/issues/199">Issue 199</a> | ||
*/ | ||
@Test | ||
public void testTodaysOngoingEvent() { | ||
DateTime today = DateUtil.now(provider.getSettings().getTimeZone()).withTimeAtStartOfDay(); | ||
CalendarEvent event = new CalendarEvent(provider.getContext(), provider.getWidgetId(), | ||
|
@@ -45,6 +52,7 @@ public void testTodaysOngoingEvent() { | |
/** | ||
* @see <a href="https://github.com/plusonelabs/calendar-widget/issues/199">Issue 199</a> | ||
*/ | ||
@Test | ||
public void testYesterdaysOngoingEvent() { | ||
DateTime today = DateUtil.now(provider.getSettings().getTimeZone()).withTimeAtStartOfDay(); | ||
CalendarEvent event = new CalendarEvent(provider.getContext(), provider.getWidgetId(), | ||
|
@@ -73,6 +81,7 @@ public void testYesterdaysOngoingEvent() { | |
assertEquals("End Time didn't change for yesterday's event", event.getEndDate(), entry.getEndDate()); | ||
} | ||
|
||
@Test | ||
public void testEventWhichCarryOverToTheNextDay() { | ||
DateTime today = DateUtil.now(provider.getSettings().getTimeZone()).withTimeAtStartOfDay(); | ||
CalendarEvent event = new CalendarEvent(provider.getContext(), provider.getWidgetId(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,14 @@ | |
import org.andstatus.todoagenda.widget.CalendarEntry; | ||
import org.andstatus.todoagenda.widget.TaskEntry; | ||
import org.json.JSONException; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
|
@@ -23,9 +28,10 @@ protected int getNumberOfOpenTasksSources() { | |
/** | ||
* https://github.com/plusonelabs/calendar-widget/issues/205 | ||
*/ | ||
@Test | ||
public void testPastDueHeaderWithTasks() throws IOException, JSONException { | ||
final String method = "testPastDueHeaderWithTasks"; | ||
QueryResultsStorage inputs = provider.loadResults(this.getInstrumentation().getContext(), | ||
QueryResultsStorage inputs = provider.loadResults(InstrumentationRegistry.getInstrumentation().getContext(), | ||
org.andstatus.todoagenda.tests.R.raw.past_due_header_with_tasks); | ||
provider.addResults(inputs.getResults()); | ||
Log.d(method, "Results executed at " + inputs.getResults().get(0).getExecutedAt()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,12 @@ | |
import org.andstatus.todoagenda.widget.CalendarEntry; | ||
import org.andstatus.todoagenda.widget.WidgetEntry; | ||
import org.joda.time.DateTime; | ||
import org.junit.Test; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
|
@@ -20,6 +23,7 @@ public class RecurringEventsTest extends BaseWidgetTest { | |
* @see <a href="https://github.com/plusonelabs/calendar-widget/issues/191">Issue 191</a> and | ||
* <a href="https://github.com/plusonelabs/calendar-widget/issues/46">Issue 46</a> | ||
*/ | ||
@Test | ||
public void testShowRecurringEvents() { | ||
generateEventInstances(); | ||
assertEquals("Entries: " + factory.getWidgetEntries().size(), 15, countCalendarEntries()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,11 @@ | |
import org.andstatus.todoagenda.widget.WidgetEntry; | ||
import org.joda.time.DateTime; | ||
import org.joda.time.DateTimeZone; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotSame; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* @author [email protected] | ||
|
@@ -14,6 +19,7 @@ public class SingleEventTest extends BaseWidgetTest { | |
|
||
private int eventId = 0; | ||
|
||
@Test | ||
public void testEventAttributes() { | ||
DateTime today = DateUtil.now(provider.getSettings().getTimeZone()).withTimeAtStartOfDay(); | ||
DateUtil.setNow(today.plusHours(10)); | ||
|
@@ -35,6 +41,7 @@ public void testEventAttributes() { | |
assertOneEvent(event, true); | ||
} | ||
|
||
@Test | ||
public void testAlldayEventAttributes() { | ||
DateTime today = DateUtil.now(provider.getSettings().getTimeZone()).withTimeAtStartOfDay(); | ||
DateUtil.setNow(today.plusHours(10)); | ||
|
@@ -53,6 +60,7 @@ public void testAlldayEventAttributes() { | |
} | ||
|
||
|
||
@Test | ||
public void testAlldayEventMillis() { | ||
DateTime today = DateUtil.now(DateTimeZone.UTC).withTimeAtStartOfDay(); | ||
CalendarEvent event = new CalendarEvent(provider.getContext(), provider.getWidgetId(), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,14 @@ | |
import org.andstatus.todoagenda.provider.QueryResultsStorage; | ||
import org.andstatus.todoagenda.widget.CalendarEntry; | ||
import org.json.JSONException; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
|
@@ -16,9 +21,10 @@ public class WrongDatesLostEventsTest extends BaseWidgetTest { | |
/** | ||
* https://github.com/plusonelabs/calendar-widget/issues/205 | ||
*/ | ||
@Test | ||
public void testIssue205() throws IOException, JSONException { | ||
final String method = "testIssue205"; | ||
QueryResultsStorage inputs = provider.loadResults(this.getInstrumentation().getContext(), | ||
QueryResultsStorage inputs = provider.loadResults(InstrumentationRegistry.getInstrumentation().getContext(), | ||
org.andstatus.todoagenda.tests.R.raw.wrong_dates_lost_events); | ||
provider.addResults(inputs.getResults()); | ||
Log.d(method, "Results executed at " + inputs.getResults().get(0).getExecutedAt()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,14 @@ | |
|
||
import android.test.InstrumentationTestCase; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* @author [email protected] | ||
*/ | ||
public class KeywordsFilterTest extends InstrumentationTestCase { | ||
|
||
@Test | ||
public void testPhrases() { | ||
String query = "\"do it\""; | ||
final String keywordDN = "do it"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.