use of android.test.suitebuilder.annotation.Smoke in project Etar-Calendar by Etar-Group.
the class EditEventHelperTest method testAddRecurrenceRule.
@Smoke
@SmallTest
public void testAddRecurrenceRule() {
mActivity = buildTestContext();
mHelper = new EditEventHelper(mActivity, null);
mValues = new ContentValues();
mExpectedValues = new ContentValues();
mModel1 = new CalendarEventModel();
mExpectedValues.put(Events.RRULE, "Weekly, Monday");
mExpectedValues.put(Events.DURATION, "P60S");
mExpectedValues.put(Events.DTEND, (Long) null);
mModel1.mRrule = "Weekly, Monday";
mModel1.mStart = 1;
mModel1.mEnd = 60001;
mModel1.mAllDay = false;
mHelper.addRecurrenceRule(mValues, mModel1);
assertEquals(mExpectedValues, mValues);
mExpectedValues.put(Events.DURATION, "P1D");
mModel1.mAllDay = true;
mValues.clear();
mHelper.addRecurrenceRule(mValues, mModel1);
assertEquals(mExpectedValues, mValues);
}
use of android.test.suitebuilder.annotation.Smoke in project Etar-Calendar by Etar-Group.
the class EditEventHelperTest method testUpdateRecurrenceRule.
@Smoke
@SmallTest
public void testUpdateRecurrenceRule() {
int selection = EditEventHelper.DOES_NOT_REPEAT;
int weekStart = Calendar.SUNDAY;
mModel1 = new CalendarEventModel();
mModel1.mTimezone = Time.TIMEZONE_UTC;
// Fri, April 30th ~ 3:17PM
mModel1.mStart = 1272665741000L;
mModel1.mRrule = "This should go away";
EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
assertNull(mModel1.mRrule);
mModel1.mRrule = "This shouldn't change";
selection = EditEventHelper.REPEATS_CUSTOM;
EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
assertEquals("This shouldn't change", mModel1.mRrule);
selection = EditEventHelper.REPEATS_DAILY;
EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
assertEquals("FREQ=DAILY;WKST=SU", mModel1.mRrule);
selection = EditEventHelper.REPEATS_EVERY_WEEKDAY;
EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
assertEquals("FREQ=WEEKLY;WKST=SU;BYDAY=MO,TU,WE,TH,FR", mModel1.mRrule);
selection = EditEventHelper.REPEATS_WEEKLY_ON_DAY;
EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
assertEquals("FREQ=WEEKLY;WKST=SU;BYDAY=FR", mModel1.mRrule);
selection = EditEventHelper.REPEATS_MONTHLY_ON_DAY;
EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
assertEquals("FREQ=MONTHLY;WKST=SU;BYMONTHDAY=30", mModel1.mRrule);
selection = EditEventHelper.REPEATS_MONTHLY_ON_DAY_COUNT;
EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
assertEquals("FREQ=MONTHLY;WKST=SU;BYDAY=-1FR", mModel1.mRrule);
selection = EditEventHelper.REPEATS_YEARLY;
EditEventHelper.updateRecurrenceRule(selection, mModel1, weekStart);
assertEquals("FREQ=YEARLY;WKST=SU", mModel1.mRrule);
}
use of android.test.suitebuilder.annotation.Smoke in project Etar-Calendar by Etar-Group.
the class EditEventHelperTest method testSetModelFromCursor.
@Smoke
@SmallTest
public void testSetModelFromCursor() {
mActivity = buildTestContext();
mHelper = new EditEventHelper(mActivity, null);
MatrixCursor c = new MatrixCursor(EditEventHelper.EVENT_PROJECTION);
c.addRow(TEST_CURSOR_DATA);
mModel1 = new CalendarEventModel();
mModel2 = buildTestModel();
EditEventHelper.setModelFromCursor(mModel1, c);
assertEquals(mModel1, mModel2);
TEST_CURSOR_DATA[EditEventHelper.EVENT_INDEX_ALL_DAY] = "0";
c.close();
c = new MatrixCursor(EditEventHelper.EVENT_PROJECTION);
c.addRow(TEST_CURSOR_DATA);
mModel2.mAllDay = false;
// UTC time
mModel2.mStart = TEST_START;
EditEventHelper.setModelFromCursor(mModel1, c);
assertEquals(mModel1, mModel2);
TEST_CURSOR_DATA[EditEventHelper.EVENT_INDEX_RRULE] = null;
c.close();
c = new MatrixCursor(EditEventHelper.EVENT_PROJECTION);
c.addRow(TEST_CURSOR_DATA);
mModel2.mRrule = null;
mModel2.mEnd = TEST_END;
mModel2.mDuration = null;
EditEventHelper.setModelFromCursor(mModel1, c);
assertEquals(mModel1, mModel2);
TEST_CURSOR_DATA[EditEventHelper.EVENT_INDEX_ALL_DAY] = "1";
c.close();
c = new MatrixCursor(EditEventHelper.EVENT_PROJECTION);
c.addRow(TEST_CURSOR_DATA);
mModel2.mAllDay = true;
// Monday, May 3rd, midnight
mModel2.mStart = TEST_START;
// Tuesday, May 4th, midnight
mModel2.mEnd = TEST_END;
EditEventHelper.setModelFromCursor(mModel1, c);
assertEquals(mModel1, mModel2);
}
use of android.test.suitebuilder.annotation.Smoke in project Etar-Calendar by Etar-Group.
the class EditEventHelperTest method testIsSameEvent.
@Smoke
@SmallTest
public void testIsSameEvent() {
mModel1 = new CalendarEventModel();
mModel2 = new CalendarEventModel();
mModel1.mId = 1;
mModel1.mCalendarId = 1;
mModel2.mId = 1;
mModel2.mCalendarId = 1;
// considered the same if the event and calendar ids both match
assertTrue(EditEventHelper.isSameEvent(mModel1, mModel2));
mModel2.mId = 2;
assertFalse(EditEventHelper.isSameEvent(mModel1, mModel2));
mModel2.mId = 1;
mModel2.mCalendarId = 2;
assertFalse(EditEventHelper.isSameEvent(mModel1, mModel2));
}
use of android.test.suitebuilder.annotation.Smoke in project Etar-Calendar by Etar-Group.
the class EditEventHelperTest method testUpdatePastEvents.
@Smoke
@SmallTest
public void testUpdatePastEvents() {
ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
ArrayList<ContentProviderOperation> expectedOps = new ArrayList<ContentProviderOperation>();
// Sep 3, 2016, 12AM UTC time
long initialBeginTime = 1472864400000L;
mValues = new ContentValues();
mModel1 = buildTestModel();
mModel1.mUri = (AUTHORITY_URI + TEST_EVENT_ID);
mActivity = buildTestContext();
mHelper = new EditEventHelper(mActivity, null);
// yyyymmddThhmmssZ
mValues.put(Events.RRULE, "FREQ=DAILY;UNTIL=20160903;WKST=SU");
mValues.put(Events.DTSTART, TEST_START);
ContentProviderOperation.Builder b = ContentProviderOperation.newUpdate(Uri.parse(mModel1.mUri)).withValues(mValues);
expectedOps.add(b.build());
mHelper.updatePastEvents(ops, mModel1, initialBeginTime);
assertEquals(expectedOps, ops);
mModel1.mAllDay = false;
// yyyymmddThhmmssZ
mValues.put(Events.RRULE, "FREQ=DAILY;UNTIL=20160903T005959Z;WKST=SU");
expectedOps.clear();
b = ContentProviderOperation.newUpdate(Uri.parse(mModel1.mUri)).withValues(mValues);
expectedOps.add(b.build());
ops.clear();
mHelper.updatePastEvents(ops, mModel1, initialBeginTime);
assertEquals(expectedOps, ops);
}
Aggregations