당직근무 0.10.0 소스와 위젯 꾸미기 및 제작 매뉴얼 공개
위젯별 투명도와 밝은·어두운 색상 및 글자 크기와 표시 항목을 추가했다. 모든 위젯에 함께 적용하는 기본값과 개별 설정을 구분하고 크기에 따라 배치를 바꾼다. 포럼에 APK와 전체 소스 및 사용법과 제작 매뉴얼을 함께 배포한다. 앱 단위 검사 34개와 서버 검사 63개 및 웹 날짜·업데이트 검사 통과. 공개 소스에서 APK 빌드와 정적 검사 오류 0개 확인. 경고는 69개다. Android 16 가상 기기에서 기존 앱 위에 설치하고 투명 위젯과 큰 글자 및 RemoteViews 검사를 확인했다. 실제 휴대폰과 다른 홈 화면 앱의 절전·크기 동작은 별도 확인이 필요하다. 회원 DB와 인증 정보 및 배포 서명 키와 내부 운영 기록은 공개 자료에 포함하지 않았다.
This commit is contained in:
commit
8112721fa8
96 files changed
+7495
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package kr.co.itosm.dutycalendar
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import java.time.LocalDate
|
||||
|
||||
class AnniversaryRuleTest {
|
||||
private fun table(): LunarTable {
|
||||
val file = listOf(File("src/main/assets/lunar-months.json"),File("app/src/main/assets/lunar-months.json")).first { it.isFile }
|
||||
var year=1899
|
||||
val rows=Regex("\\[(-?\\d+),(\\d+),([01])\\]").findAll(file.readText()).map { match ->
|
||||
val start=match.groupValues[1].toLong();val month=match.groupValues[2].toInt();val leap=match.groupValues[3]=="1"
|
||||
if(month==1&&!leap)year=LocalDate.ofEpochDay(start).year
|
||||
LunarMonth(start,month,leap,year)
|
||||
}.toList()
|
||||
return LunarTable(rows)
|
||||
}
|
||||
@Test fun solarLeapBirthdayUsesMonthEnd() {
|
||||
val rule=AnniversaryRule("SOLAR",2,29)
|
||||
assertTrue(rule.matches(LocalDate.of(2026,2,28)));assertFalse(rule.matches(LocalDate.of(2028,2,28)));assertTrue(rule.matches(LocalDate.of(2028,2,29)))
|
||||
}
|
||||
@Test fun lunarNewYearAndChuseokUseKoreanDates() {
|
||||
val data=table()
|
||||
assertTrue(AnniversaryRule("LUNAR",1,1).matches(LocalDate.of(2026,2,17),data.day(LocalDate.of(2026,2,17))))
|
||||
assertTrue(AnniversaryRule("LUNAR",8,15).matches(LocalDate.of(2026,9,25),data.day(LocalDate.of(2026,9,25))))
|
||||
}
|
||||
@Test fun leapMonthDoesNotDuplicateRegularMonth() {
|
||||
val data=table();val leap=AnniversaryRule("LUNAR",6,1,true);val normal=AnniversaryRule("LUNAR",6,1)
|
||||
val date=LocalDate.of(2025,7,25)
|
||||
assertTrue(leap.matches(date,data.day(date)));assertFalse(normal.matches(date,data.day(date)))
|
||||
for(year in listOf(2025,2026)) {
|
||||
val dates=(0L..365L).map{LocalDate.of(year,1,1).plusDays(it)}.filter{it.year==year&&leap.matches(it,data.day(it))}
|
||||
assertEquals(1,dates.size)
|
||||
}
|
||||
}
|
||||
@Test fun missingLunarThirtyUsesLastDay() {
|
||||
val data=table();val day=(0L..364L).map{LocalDate.of(2026,1,1).plusDays(it)}.first{data.day(it)?.let{v->v.length==29&&v.day==29}==true}
|
||||
val lunar=data.day(day)!!
|
||||
assertTrue(AnniversaryRule("LUNAR",lunar.month,30,lunar.leap).matches(day,lunar))
|
||||
}
|
||||
@Test fun unsupportedRangeIsNotInvented() {
|
||||
val data=table();assertNull(data.day(LocalDate.of(2051,1,1)));assertNotNull(data.day(LocalDate.of(2050,12,31)))
|
||||
assertFalse(AnniversaryRule("LUNAR",1,1).matches(LocalDate.of(2051,1,1)))
|
||||
}
|
||||
@Test fun invalidCalendarDatesAreRejected() {
|
||||
for(rule in listOf({AnniversaryRule("SOLAR",2,30)},{AnniversaryRule("SOLAR",4,31)},{AnniversaryRule("LUNAR",2,31)},{AnniversaryRule("SOLAR",2,1,true)})) {
|
||||
assertTrue(runCatching{rule()}.isFailure)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package kr.co.itosm.dutycalendar
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.time.LocalDate
|
||||
|
||||
class EventRepeatTest {
|
||||
private fun d(value:String)=LocalDate.parse(value)
|
||||
@Test fun monthlyUsesOriginalDayAfterShortMonth(){val rule=EventRepeat(d("2026-01-31"),d("2026-01-31"),"MONTHLY");assertEquals(d("2026-02-28"),rule.occurrenceOn(d("2026-02-28")));assertEquals(d("2026-03-31"),rule.occurrenceOn(d("2026-03-31")));assertNull(rule.occurrenceOn(d("2026-03-28")))}
|
||||
@Test fun weeklyStopsAtLastAllowedStart(){val rule=EventRepeat(d("2026-11-20"),d("2026-11-22"),"WEEKLY",d("2026-11-27"));assertEquals(d("2026-11-27"),rule.occurrenceOn(d("2026-11-29")));assertNull(rule.occurrenceOn(d("2026-12-04")))}
|
||||
@Test fun annualLeapDayAndBeforeStart(){val rule=EventRepeat(d("2024-02-29"),d("2024-02-29"),"YEARLY");assertEquals(d("2025-02-28"),rule.occurrenceOn(d("2025-02-28")));assertNull(rule.occurrenceOn(d("2023-02-28")));assertNull(rule.occurrenceOn(d("2028-02-28")))}
|
||||
@Test fun dailyAndNonRepeatingRanges(){val daily=EventRepeat(d("2026-11-20"),d("2026-11-20"),"DAILY",d("2026-11-22"));assertEquals(d("2026-11-21"),daily.occurrenceOn(d("2026-11-21")));assertNull(daily.occurrenceOn(d("2026-11-23")));assertEquals(d("2026-11-20"),EventRepeat(d("2026-11-20"),d("2026-11-22")).occurrenceOn(d("2026-11-22")))}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package kr.co.itosm.dutycalendar
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
/** 화면 재진입과 네트워크 복구만으로 전체 자료를 다시 받지 않는 갱신 계약을 확인한다. */
|
||||
class RefreshPolicyTest {
|
||||
private val saved = 1_700_000_000_000L
|
||||
@Test fun reopeningBeforeMonthlyRefreshReusesSavedData() {
|
||||
assertFalse(RefreshPolicy.needsRefresh(saved, saved + 15 * 60 * 1000))
|
||||
assertFalse(RefreshPolicy.needsRefresh(saved, saved + RefreshPolicy.MONTH_MS - 1))
|
||||
assertTrue(RefreshPolicy.needsRefresh(saved, saved + RefreshPolicy.MONTH_MS))
|
||||
}
|
||||
@Test fun manualOrChangeNotificationRefreshesImmediately() {
|
||||
assertTrue(RefreshPolicy.needsRefresh(saved, saved, requested = true))
|
||||
}
|
||||
@Test fun firstConnectionAndClockRollbackRecover() {
|
||||
assertTrue(RefreshPolicy.needsRefresh(0, saved))
|
||||
assertTrue(RefreshPolicy.needsRefresh(saved, saved - 1))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package kr.co.itosm.dutycalendar
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import java.time.LocalDate
|
||||
import java.time.YearMonth
|
||||
|
||||
/**
|
||||
* 반복 근무 계산에서 틀리기 쉬운 기준일 이전과 연말 및 윤년 경계를 확인한다.
|
||||
* 안드로이드 화면 없이 순수 날짜 계산을 검사해 기기 시간이나 네트워크 상태의 영향을 받지 않게 한다.
|
||||
* 화면 배치와 위젯 추가 및 공휴일 통신은 가상 기기에서 별도로 확인한다.
|
||||
*/
|
||||
class ScheduleTest {
|
||||
private val anchor = LocalDate.of(2026, 11, 20)
|
||||
@Test fun twoDayCycle() {
|
||||
val schedule = Schedule(anchor, Schedule.preset(2))
|
||||
assertEquals(listOf(Shift.DUTY, Shift.OFF, Shift.DUTY, Shift.OFF), (0L..3L).map { schedule.shiftOn(anchor.plusDays(it)) })
|
||||
}
|
||||
@Test fun threeDayCycle() {
|
||||
val schedule = Schedule(anchor, Schedule.preset(3))
|
||||
assertEquals(Shift.REGULAR, schedule.shiftOn(anchor.plusDays(2)))
|
||||
assertEquals(Shift.DUTY, schedule.shiftOn(anchor.plusDays(3)))
|
||||
}
|
||||
@Test fun datesBeforeAnchorUseSameCycle() {
|
||||
val schedule = Schedule(anchor, Schedule.preset(3))
|
||||
assertEquals(Shift.REGULAR, schedule.shiftOn(anchor.minusDays(1)))
|
||||
assertEquals(Shift.OFF, schedule.shiftOn(anchor.minusDays(2)))
|
||||
assertEquals(Shift.DUTY, schedule.shiftOn(anchor.minusDays(3)))
|
||||
}
|
||||
@Test fun customPatternIsPreservedAcrossYearBoundary() {
|
||||
val schedule = Schedule(LocalDate.of(2026, 12, 30), listOf(Shift.OFF, Shift.REGULAR, Shift.DUTY, Shift.OFF))
|
||||
assertEquals(Shift.DUTY, schedule.shiftOn(LocalDate.of(2027, 1, 1)))
|
||||
}
|
||||
@Test fun leapDayAndMarchAreConsecutive() {
|
||||
val schedule = Schedule(LocalDate.of(2028, 2, 28), Schedule.preset(3))
|
||||
assertEquals(Shift.OFF, schedule.shiftOn(LocalDate.of(2028, 2, 29)))
|
||||
assertEquals(Shift.REGULAR, schedule.shiftOn(LocalDate.of(2028, 3, 1)))
|
||||
}
|
||||
@Test fun monthGridIncludesAllDaysAndStartsSunday() {
|
||||
val days = calendarDays(YearMonth.of(2026, 8))
|
||||
assertEquals(42, days.size)
|
||||
assertEquals(java.time.DayOfWeek.SUNDAY, days.first().dayOfWeek)
|
||||
assertTrue(days.contains(LocalDate.of(2026, 8, 31)))
|
||||
}
|
||||
@Test(expected = IllegalArgumentException::class) fun emptyCycleRejected() { Schedule(anchor, emptyList()) }
|
||||
@Test fun longestCycleWorks() {
|
||||
val schedule = Schedule(anchor, Schedule.preset(366))
|
||||
assertEquals(Shift.REGULAR, schedule.shiftOn(anchor.plusDays(365)))
|
||||
assertEquals(Shift.DUTY, schedule.shiftOn(anchor.plusDays(366)))
|
||||
}
|
||||
@Test fun dutyNumberKeepsDutyOffAndFillsRemainingDays() {
|
||||
val schedule = Schedule(anchor, Schedule.preset(5))
|
||||
assertEquals(listOf(Shift.DUTY, Shift.OFF, Shift.REGULAR, Shift.REGULAR, Shift.REGULAR, Shift.DUTY), (0L..5).map { schedule.shiftOn(anchor.plusDays(it)) })
|
||||
}
|
||||
@Test fun nightOffAndRestRemainDistinctAcrossMonthBoundary() {
|
||||
val schedule = Schedule(LocalDate.of(2026, 11, 29), listOf(Shift.DAY, Shift.NIGHT, Shift.OFF, Shift.REST))
|
||||
assertEquals(Shift.NIGHT, schedule.shiftOn(LocalDate.of(2026, 11, 30)))
|
||||
assertEquals(Shift.OFF, schedule.shiftOn(LocalDate.of(2026, 12, 1)))
|
||||
assertEquals(Shift.REST, schedule.shiftOn(LocalDate.of(2026, 12, 2)))
|
||||
assertEquals(Shift.DAY, schedule.shiftOn(LocalDate.of(2026, 12, 3)))
|
||||
assertFalse(Shift.REST.working)
|
||||
assertTrue(Shift.EVENING.working)
|
||||
}
|
||||
@Test(expected = IllegalArgumentException::class) fun oversizedCycleRejected() { Schedule(anchor, List(367) { Shift.DAY }) }
|
||||
@Test fun fiveDaySaturdayKeepsDutyAndRestsOtherShifts() {
|
||||
val saturday = LocalDate.of(2026, 11, 21)
|
||||
Shift.entries.forEach { shift ->
|
||||
assertEquals(if (shift == Shift.DUTY) Shift.DUTY else Shift.REST,
|
||||
Schedule(saturday, listOf(shift), 5).shiftOn(saturday))
|
||||
}
|
||||
}
|
||||
@Test fun saturdayRestDoesNotMoveFollowingRotation() {
|
||||
val schedule = Schedule(anchor, listOf(Shift.DUTY, Shift.REGULAR, Shift.NIGHT), 5)
|
||||
assertEquals(Shift.REST, schedule.shiftOn(anchor.plusDays(1)))
|
||||
assertEquals(Shift.NIGHT, schedule.shiftOn(anchor.plusDays(2)))
|
||||
assertEquals(Shift.DUTY, schedule.shiftOn(anchor.plusDays(3)))
|
||||
}
|
||||
@Test fun sixDayAndLegacySaturdayKeepOriginalDuty() {
|
||||
val saturday = LocalDate.of(2026, 11, 21)
|
||||
Shift.entries.forEach { shift ->
|
||||
assertEquals(shift, Schedule(saturday, listOf(shift)).shiftOn(saturday))
|
||||
assertEquals(shift, Schedule(saturday, listOf(shift), 6).shiftOn(saturday))
|
||||
}
|
||||
}
|
||||
@Test fun saturdayColorsFollowWorkWeekAndHolidayWins() {
|
||||
val saturday = LocalDate.of(2026, 11, 21)
|
||||
val five = Schedule(anchor, Schedule.preset(3), 5)
|
||||
val six = five.copy(workWeek = 6)
|
||||
assertEquals(0xFFBD5163.toInt(), five.dateColor(saturday))
|
||||
assertEquals(0xFF365FAD.toInt(), six.dateColor(saturday))
|
||||
assertEquals(0xFFBD5163.toInt(), six.dateColor(saturday, holiday = true))
|
||||
}
|
||||
@Test(expected = IllegalArgumentException::class) fun invalidWorkWeekRejected() { Schedule(anchor, Schedule.preset(3), 7) }
|
||||
@Test fun weekdayDutyChangesOnlyDateColor() {
|
||||
val duty = Schedule(anchor, listOf(Shift.DUTY), 5, true)
|
||||
listOf(LocalDate.of(2026, 11, 21), LocalDate.of(2026, 11, 22), LocalDate.of(2026, 12, 25)).forEach {
|
||||
assertEquals(0xFF1D2939.toInt(), duty.dateColor(it, true))
|
||||
assertEquals(Shift.DUTY, duty.shiftOn(it))
|
||||
assertEquals(0xFFBD5163.toInt(), duty.copy(dutyAsWeekday = false).dateColor(it, true))
|
||||
}
|
||||
val sunday = LocalDate.of(2026, 11, 22)
|
||||
assertEquals(0xFFBD5163.toInt(), duty.copy(pattern = listOf(Shift.OFF)).dateColor(sunday))
|
||||
}
|
||||
@Test fun offColorOptionDoesNotChangeRotationOrOtherShifts() {
|
||||
val monday = LocalDate.of(2026, 11, 23)
|
||||
val off = Schedule(monday, listOf(Shift.OFF), offAsHoliday = true)
|
||||
assertEquals(0xFFBD5163.toInt(), off.dateColor(monday))
|
||||
assertEquals(0xFFBD5163.toInt(), off.shiftColor(monday))
|
||||
assertEquals(Shift.OFF, off.shiftOn(monday))
|
||||
assertEquals(Shift.OFF.color, off.copy(offAsHoliday = false).shiftColor(monday))
|
||||
assertEquals(Shift.REGULAR.color, off.copy(pattern = listOf(Shift.REGULAR)).shiftColor(monday))
|
||||
assertEquals(0xFF1D2939.toInt(), off.copy(pattern = listOf(Shift.DUTY), dutyAsWeekday = true).dateColor(monday, true))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package kr.co.itosm.dutycalendar
|
||||
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
|
||||
class UpdatePolicyTest {
|
||||
@Test fun installedAndOlderReleasesNeverPrompt() {
|
||||
assertFalse(UpdatePolicy.shouldPrompt(6, 6, 0, 0, 100))
|
||||
assertFalse(UpdatePolicy.shouldPrompt(5, 6, 0, 0, 100))
|
||||
}
|
||||
@Test fun deferralOnlyHidesSameReleaseUntilDeadline() {
|
||||
assertFalse(UpdatePolicy.shouldPrompt(7, 6, 7, 200, 100))
|
||||
assertTrue(UpdatePolicy.shouldPrompt(7, 6, 7, 200, 200))
|
||||
assertTrue(UpdatePolicy.shouldPrompt(8, 6, 7, 200, 100))
|
||||
}
|
||||
@Test fun rapidReopensReuseVersionAndClockRollbackChecksAgain() {
|
||||
assertFalse(UpdatePolicy.needsCheck(1_000, 2_000))
|
||||
assertTrue(UpdatePolicy.needsCheck(1_000, 1_000 + UpdatePolicy.CHECK_MS))
|
||||
assertTrue(UpdatePolicy.needsCheck(1_000, 999))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user