@@ -11,13 +11,15 @@ import android.provider.CalendarContract.Events
1111import android.provider.CalendarContract.ExtendedProperties
1212import androidx.core.content.contentValuesOf
1313import at.bitfire.dateTimeValue
14+ import at.bitfire.dateValue
1415import at.bitfire.synctools.icalendar.dtStart
1516import at.bitfire.synctools.icalendar.recurrenceId
1617import at.bitfire.synctools.storage.calendar.EventAndExceptions
1718import at.bitfire.synctools.storage.calendar.EventsContract
18- import at.bitfire.synctools.util.AndroidTimeUtils
19+ import net.fortuna.ical4j.model.Parameter
1920import net.fortuna.ical4j.model.Property
2021import net.fortuna.ical4j.model.TimeZoneRegistryFactory
22+ import net.fortuna.ical4j.model.parameter.Value
2123import net.fortuna.ical4j.model.property.DtStart
2224import net.fortuna.ical4j.model.property.ExDate
2325import net.fortuna.ical4j.model.property.ProdId
@@ -148,6 +150,43 @@ class AndroidEventHandlerTest {
148150 assertTrue(result.exceptions.isEmpty())
149151 }
150152
153+ @Test
154+ fun `mapToVEvents rewrites cancelled all-day exception to EXDATE with VALUE=DATE` () {
155+ val result = handler.mapToVEvents(
156+ eventAndExceptions = EventAndExceptions (
157+ main = Entity (contentValuesOf(
158+ Events .TITLE to " Recurring all-day event with cancelled all-day exception" ,
159+ Events .DTSTART to 1594056600000L ,
160+ Events .EVENT_TIMEZONE to " UTC" ,
161+ Events .ALL_DAY to 1 , // main event is all-day
162+ Events .RRULE to " FREQ=DAILY;COUNT=10"
163+ )),
164+ exceptions = listOf (
165+ Entity (contentValuesOf(
166+ Events .ORIGINAL_INSTANCE_TIME to 1594143000000L ,
167+ Events .ORIGINAL_ALL_DAY to 1 , // exception is all-day
168+ Events .DTSTART to 1594143000000L ,
169+ Events .ALL_DAY to 1 ,
170+ Events .EVENT_TIMEZONE to " UTC" ,
171+ Events .STATUS to Events .STATUS_CANCELED
172+ ))
173+ )
174+ )
175+ ).associatedEvents
176+ val main = result.main!!
177+ assertEquals(" Recurring all-day event with cancelled all-day exception" , main.summary.value)
178+ assertEquals(" FREQ=DAILY;COUNT=10" , main.getProperty<RRule <* >>(Property .RRULE ).get().value)
179+
180+ // Check that EXDATE has VALUE=DATE
181+ val exDate = main.getProperty<ExDate <* >>(Property .EXDATE ).get()
182+ assertEquals(Value .DATE , exDate.getParameter<Value >(Parameter .VALUE ).get())
183+ assertEquals(
184+ dateValue(" 20200707" ),
185+ main.getProperty<ExDate <* >>(Property .EXDATE )?.getOrNull()?.dates?.first()
186+ )
187+ assertTrue(result.exceptions.isEmpty())
188+ }
189+
151190 @Test
152191 fun `mapToVEvents rewrites cancelled exception using UTC to EXDATE` () {
153192 val result = handler.mapToVEvents(
0 commit comments