Skip to content

Commit

Permalink
auto update upsert on user action redraw
Browse files Browse the repository at this point in the history
  • Loading branch information
mvmike committed Jan 2, 2024
1 parent 718c990 commit 2bf5b41
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import cat.mvmike.minimalcalendarwidget.domain.intent.ActionableView.CellDay.get
import cat.mvmike.minimalcalendarwidget.domain.intent.ActionableView.ConfigurationIcon
import cat.mvmike.minimalcalendarwidget.domain.intent.ActionableView.MonthAndYearHeader
import cat.mvmike.minimalcalendarwidget.domain.intent.ActionableView.RowHeader
import cat.mvmike.minimalcalendarwidget.domain.intent.AutoUpdate
import cat.mvmike.minimalcalendarwidget.domain.intent.toActionableView
import cat.mvmike.minimalcalendarwidget.infrastructure.activity.CalendarActivity
import cat.mvmike.minimalcalendarwidget.infrastructure.activity.ConfigurationActivity
Expand Down Expand Up @@ -55,5 +56,7 @@ object ProcessIntentUseCase {
RedrawWidgetUseCase.execute(this)
}
else -> PermissionsActivity.start(this)
}.also {
AutoUpdate.set(this)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.appwidget.AppWidgetManager.ACTION_APPWIDGET_UPDATE
import cat.mvmike.minimalcalendarwidget.BaseTest
import cat.mvmike.minimalcalendarwidget.application.RedrawWidgetUseCase
import cat.mvmike.minimalcalendarwidget.domain.configuration.item.SymbolSet
import cat.mvmike.minimalcalendarwidget.domain.intent.AutoUpdate
import cat.mvmike.minimalcalendarwidget.domain.intent.AutoUpdate.ACTION_AUTO_UPDATE
import cat.mvmike.minimalcalendarwidget.infrastructure.activity.CalendarActivity
import cat.mvmike.minimalcalendarwidget.infrastructure.activity.ConfigurationActivity
Expand Down Expand Up @@ -71,14 +72,18 @@ internal class ProcessIntentUseCaseTest : BaseTest() {
mockIntent(action)
mockIsReadCalendarPermitted(false)
mockInstancesSymbolSet(SymbolSet.MINIMAL)
mockkObject(AutoUpdate)

justRun { PermissionsActivity.Companion.start(context) }
justRun { AutoUpdate.set(context) }

ProcessIntentUseCase.execute(context, intent)

verifyIntentAction()
verifyIsReadCalendarPermitted()
verifyInstancesSymbolSet()
verify { PermissionsActivity.Companion.start(context) }
verify { AutoUpdate.set(context) }
}

@ParameterizedTest
Expand All @@ -94,9 +99,11 @@ internal class ProcessIntentUseCaseTest : BaseTest() {
mockGetSystemInstant()
mockOpenCalendarOnClickedDay(false)
mockkObject(RedrawWidgetUseCase)
mockkObject(AutoUpdate)

justRun { CalendarActivity.start(context, systemInstant) }
justRun { RedrawWidgetUseCase.execute(context) }
justRun { AutoUpdate.set(context) }

ProcessIntentUseCase.execute(context, intent)

Expand All @@ -105,6 +112,7 @@ internal class ProcessIntentUseCaseTest : BaseTest() {
verifyGetSystemInstant()
verify { CalendarActivity.start(context, systemInstant) }
verify { RedrawWidgetUseCase.execute(context) }
verify { AutoUpdate.set(context) }
}

@ParameterizedTest
Expand All @@ -121,9 +129,11 @@ internal class ProcessIntentUseCaseTest : BaseTest() {
mockGetSystemInstant()
mockOpenCalendarOnClickedDay(false)
mockkObject(RedrawWidgetUseCase)
mockkObject(AutoUpdate)

justRun { CalendarActivity.start(context, systemInstant) }
justRun { RedrawWidgetUseCase.execute(context) }
justRun { AutoUpdate.set(context) }

ProcessIntentUseCase.execute(context, intent)

Expand All @@ -133,6 +143,7 @@ internal class ProcessIntentUseCaseTest : BaseTest() {
verifyGetSystemInstant()
verify { CalendarActivity.start(context, systemInstant) }
verify { RedrawWidgetUseCase.execute(context) }
verify { AutoUpdate.set(context) }
}

@ParameterizedTest
Expand All @@ -143,9 +154,11 @@ internal class ProcessIntentUseCaseTest : BaseTest() {
mockGetSystemInstant()
mockOpenCalendarOnClickedDay(false)
mockkObject(RedrawWidgetUseCase)
mockkObject(AutoUpdate)

justRun { CalendarActivity.start(context, systemInstant) }
justRun { RedrawWidgetUseCase.execute(context) }
justRun { AutoUpdate.set(context) }

ProcessIntentUseCase.execute(context, intent)

Expand All @@ -155,6 +168,7 @@ internal class ProcessIntentUseCaseTest : BaseTest() {
verifyOpenCalendarOnClickedDay()
verify { CalendarActivity.start(context, systemInstant) }
verify { RedrawWidgetUseCase.execute(context) }
verify { AutoUpdate.set(context) }
}

@ParameterizedTest
Expand All @@ -172,9 +186,11 @@ internal class ProcessIntentUseCaseTest : BaseTest() {
mockGetSystemZoneId()
mockOpenCalendarOnClickedDay(true)
mockkObject(RedrawWidgetUseCase)
mockkObject(AutoUpdate)

justRun { CalendarActivity.start(context, startTimeInstant) }
justRun { RedrawWidgetUseCase.execute(context) }
justRun { AutoUpdate.set(context) }

ProcessIntentUseCase.execute(context, intent)

Expand All @@ -186,6 +202,7 @@ internal class ProcessIntentUseCaseTest : BaseTest() {
verifyOpenCalendarOnClickedDay()
verify { CalendarActivity.start(context, startTimeInstant) }
verify { RedrawWidgetUseCase.execute(context) }
verify { AutoUpdate.set(context) }
}

private fun getMincalCalendarIntentActionAndExpectedExtraInstantAndStartTimeInstant() = listOf(
Expand Down

0 comments on commit 2bf5b41

Please sign in to comment.