Search in sources :

Example 6 with CalendarEventModel

use of com.android.calendar.CalendarEventModel 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);
}
Also used : CalendarEventModel(com.android.calendar.CalendarEventModel) MatrixCursor(android.database.MatrixCursor) SmallTest(android.test.suitebuilder.annotation.SmallTest) Smoke(android.test.suitebuilder.annotation.Smoke)

Example 7 with CalendarEventModel

use of com.android.calendar.CalendarEventModel 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));
}
Also used : CalendarEventModel(com.android.calendar.CalendarEventModel) SmallTest(android.test.suitebuilder.annotation.SmallTest) Smoke(android.test.suitebuilder.annotation.Smoke)

Example 8 with CalendarEventModel

use of com.android.calendar.CalendarEventModel in project Etar-Calendar by Etar-Group.

the class EditEventHelperTest method testIsFirstEventInSeries.

@Smoke
@SmallTest
public void testIsFirstEventInSeries() {
    mModel1 = new CalendarEventModel();
    mModel2 = new CalendarEventModel();
    // It's considered the first event if the original start of the new model matches the
    // start of the old model
    mModel1.mOriginalStart = 100;
    mModel1.mStart = 200;
    mModel2.mOriginalStart = 100;
    mModel2.mStart = 100;
    assertTrue(EditEventHelper.isFirstEventInSeries(mModel1, mModel2));
    mModel1.mOriginalStart = 80;
    assertFalse(EditEventHelper.isFirstEventInSeries(mModel1, mModel2));
}
Also used : CalendarEventModel(com.android.calendar.CalendarEventModel) SmallTest(android.test.suitebuilder.annotation.SmallTest) Smoke(android.test.suitebuilder.annotation.Smoke)

Example 9 with CalendarEventModel

use of com.android.calendar.CalendarEventModel in project Etar-Calendar by Etar-Group.

the class EditEventHelperTest method buildTestModel.

// Generates a default model for testing. Should match up with
// generateTestValues
private CalendarEventModel buildTestModel() {
    CalendarEventModel model = new CalendarEventModel();
    model.mId = TEST_EVENT_ID;
    model.mTitle = "The_Question";
    model.mDescription = "Evaluating_Life_the_Universe_and_Everything";
    model.mLocation = "Earth_Mk2";
    model.mAllDay = true;
    model.mHasAlarm = false;
    model.mCalendarId = 2;
    // Monday, May 3rd, local Time
    model.mStart = TEST_START;
    model.mDuration = "P3652421990D";
    // The model uses the local timezone for allday
    model.mTimezone = "UTC";
    model.mRrule = "FREQ=DAILY;WKST=SU";
    model.mSyncId = "unique_per_calendar_stuff";
    model.mAvailability = 0;
    // This is one less than the values written if >0
    model.mAccessLevel = 2;
    model.mOwnerAccount = "steve@gmail.com";
    model.mHasAttendeeData = true;
    model.mOrganizer = "organizer@gmail.com";
    model.mIsOrganizer = false;
    model.mGuestsCanModify = false;
    model.mEventStatus = Events.STATUS_CONFIRMED;
    int displayColor = Utils.getDisplayColorFromColor(-2350809);
    model.setEventColor(displayColor);
    model.mCalendarAccountName = "steve.owner@gmail.com";
    model.mCalendarAccountType = "gmail.com";
    EventColorCache cache = new EventColorCache();
    cache.insertColor("steve.owner@gmail.com", "gmail.com", displayColor, 12);
    model.mEventColorCache = cache;
    model.mModelUpdatedWithEventCursor = true;
    return model;
}
Also used : CalendarEventModel(com.android.calendar.CalendarEventModel)

Aggregations

CalendarEventModel (com.android.calendar.CalendarEventModel)9 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 Smoke (android.test.suitebuilder.annotation.Smoke)5 AsyncQueryHandler (android.content.AsyncQueryHandler)1 ContentValues (android.content.ContentValues)1 Context (android.content.Context)1 Resources (android.content.res.Resources)1 MatrixCursor (android.database.MatrixCursor)1 ReminderEntry (com.android.calendar.CalendarEventModel.ReminderEntry)1