comboctl-parser: Also parse text in alert screens

This helps with distinguishing the "snooze" and "confirm" screens.

Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
Carlos Rafael Giani 2023-03-08 17:37:26 +01:00
parent c81578f7ff
commit 76dec4aad6
6 changed files with 1752 additions and 35 deletions

View file

@ -81,8 +81,14 @@ sealed class MainScreenContent {
* Possible contents of alert (= warning/error) screens.
*/
sealed class AlertScreenContent {
data class Warning(val code: Int) : AlertScreenContent()
data class Error(val code: Int) : AlertScreenContent()
enum class AlertScreenState {
TO_SNOOZE,
TO_CONFIRM,
HISTORY_ENTRY
}
data class Warning(val code: Int, val state: AlertScreenState) : AlertScreenContent()
data class Error(val code: Int, val state: AlertScreenState) : AlertScreenContent()
/**
* "Content" while the alert symbol & code currently are "blinked out".
@ -1139,8 +1145,9 @@ class AlertScreenParser : Parser() {
OptionalParser(SingleGlyphTypeParser(Glyph.LargeSymbol::class)), // warning/error symbol
OptionalParser(SingleGlyphTypeParser(Glyph.LargeCharacter::class)), // "W" or "E"
OptionalParser(IntegerParser()), // warning/error number
OptionalParser(SingleGlyphTypeParser(Glyph.LargeSymbol::class)), // stop symbol (only with errors)
SingleGlyphParser(Glyph.SmallSymbol(SmallSymbol.CHECK))
OptionalParser(SingleGlyphTypeParser(Glyph.LargeSymbol::class)), // stop symbol (shown in suspended state)
SingleGlyphParser(Glyph.SmallSymbol(SmallSymbol.CHECK)),
StringParser() // snooze / confirm text
)
).parse(parseContext)
@ -1149,16 +1156,23 @@ class AlertScreenParser : Parser() {
parseResult as ParseResult.Sequence
val stateString = parseResult.valueAt<String>(4)
val alertState = when (knownScreenTitles[stateString]) {
TitleID.ALERT_TO_SNOOZE -> AlertScreenContent.AlertScreenState.TO_SNOOZE
TitleID.ALERT_TO_CONFIRM -> AlertScreenContent.AlertScreenState.TO_CONFIRM
else -> return ParseResult.Failed
}
return when (parseResult.valueAtOrNull<Glyph>(0)) {
Glyph.LargeSymbol(LargeSymbol.WARNING) -> {
ParseResult.Value(ParsedScreen.AlertScreen(
AlertScreenContent.Warning(parseResult.valueAt(2))
AlertScreenContent.Warning(parseResult.valueAt(2), alertState)
))
}
Glyph.LargeSymbol(LargeSymbol.ERROR) -> {
ParseResult.Value(ParsedScreen.AlertScreen(
AlertScreenContent.Error(parseResult.valueAt(2))
AlertScreenContent.Error(parseResult.valueAt(2), alertState)
))
}
@ -1654,7 +1668,10 @@ class MyDataErrorDataScreenParser : Parser() {
index = index,
totalNumEntries = totalNumEntries,
timestamp = timestamp,
alert = if (alertType == SmallSymbol.WARNING) AlertScreenContent.Warning(alertNumber) else AlertScreenContent.Error(alertNumber)
alert = if (alertType == SmallSymbol.WARNING)
AlertScreenContent.Warning(alertNumber, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
else
AlertScreenContent.Error(alertNumber, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
)
}

View file

@ -19,7 +19,9 @@ enum class TitleID {
BOLUS_DATA,
ERROR_DATA,
DAILY_TOTALS,
TBR_DATA
TBR_DATA,
ALERT_TO_SNOOZE,
ALERT_TO_CONFIRM
}
/**
@ -46,6 +48,8 @@ val knownScreenTitles = mapOf(
"ERROR DATA" to TitleID.ERROR_DATA,
"DAILY TOTALS" to TitleID.DAILY_TOTALS,
"TBR DATA" to TitleID.TBR_DATA,
"TO SNOOZE" to TitleID.ALERT_TO_SNOOZE,
"TO CONFIRM" to TitleID.ALERT_TO_CONFIRM,
// Spanish
"QUICK INFO" to TitleID.QUICK_INFO,
@ -60,6 +64,8 @@ val knownScreenTitles = mapOf(
"DATOS DE ERROR" to TitleID.ERROR_DATA,
"TOTALES DIARIOS" to TitleID.DAILY_TOTALS,
"DATOS DE DBT" to TitleID.TBR_DATA,
"REPETIR SEÑAL" to TitleID.ALERT_TO_SNOOZE,
"CONFIRMAR" to TitleID.ALERT_TO_CONFIRM,
// French
"QUICK INFO" to TitleID.QUICK_INFO,
@ -74,6 +80,8 @@ val knownScreenTitles = mapOf(
"ERREURS" to TitleID.ERROR_DATA,
"QUANTITÉS JOURN." to TitleID.DAILY_TOTALS,
"DBT" to TitleID.TBR_DATA,
"RAPPEL TARD" to TitleID.ALERT_TO_SNOOZE, // actually, the text is "RAPPEL + TARD", but the + symbol is ignored to simplify parsing
"POUR CONFIRMER" to TitleID.ALERT_TO_CONFIRM,
// Italian
"QUICK INFO" to TitleID.QUICK_INFO,
@ -88,6 +96,8 @@ val knownScreenTitles = mapOf(
"MEMORIA ALLARMI" to TitleID.ERROR_DATA,
"TOTALI GIORNATA" to TitleID.DAILY_TOTALS,
"MEMORIA PBT" to TitleID.TBR_DATA,
"RIPETI ALLARME" to TitleID.ALERT_TO_SNOOZE,
"PER CONFERMARE" to TitleID.ALERT_TO_CONFIRM,
// Russian
"QUICK INFO" to TitleID.QUICK_INFO,
@ -102,6 +112,8 @@ val knownScreenTitles = mapOf(
"ДАHHЫE OБ O ИБ." to TitleID.ERROR_DATA,
"CУTOЧHЫE ДOЗЫ" to TitleID.DAILY_TOTALS,
"ДАHHЫE O BБC" to TitleID.TBR_DATA,
"BЫKЛ. ЗBУK" to TitleID.ALERT_TO_SNOOZE,
"ПOДTBEPДИTЬ" to TitleID.ALERT_TO_CONFIRM,
// Turkish
"QUICK INFO" to TitleID.QUICK_INFO,
@ -116,6 +128,8 @@ val knownScreenTitles = mapOf(
"HATA VERİLERİ" to TitleID.ERROR_DATA,
"GÜNLÜK TOPLAM" to TitleID.DAILY_TOTALS,
"GBH VERİLERİ" to TitleID.TBR_DATA,
"ERTELE" to TitleID.ALERT_TO_SNOOZE,
"ONAYLA" to TitleID.ALERT_TO_CONFIRM,
// Polish
"QUICK INFO" to TitleID.QUICK_INFO,
@ -130,6 +144,8 @@ val knownScreenTitles = mapOf(
"DANE BŁĘDU" to TitleID.ERROR_DATA,
"DZIEN. D. CAŁK." to TitleID.DAILY_TOTALS,
"DANE TDP" to TitleID.TBR_DATA,
"ABY WYCISZYĆ" to TitleID.ALERT_TO_SNOOZE,
"ABY POTWIERDZ." to TitleID.ALERT_TO_CONFIRM,
// Czech
"QUICK INFO" to TitleID.QUICK_INFO,
@ -144,6 +160,8 @@ val knownScreenTitles = mapOf(
"ÚDAJE CHYB" to TitleID.ERROR_DATA,
"CELK. DEN. DÁVKY" to TitleID.DAILY_TOTALS,
"ÚDAJE DBD" to TitleID.TBR_DATA,
"ODLOŽIT" to TitleID.ALERT_TO_SNOOZE,
"POTVRDIT" to TitleID.ALERT_TO_CONFIRM,
// Hungarian
"QUICK INFO" to TitleID.QUICK_INFO,
@ -158,6 +176,8 @@ val knownScreenTitles = mapOf(
"HIBAADATOK" to TitleID.ERROR_DATA,
"NAPI TELJES" to TitleID.DAILY_TOTALS,
"TBR-ADATOK" to TitleID.TBR_DATA,
"NÉMÍTÁS" to TitleID.ALERT_TO_SNOOZE,
"JÓVÁHAGYÁS" to TitleID.ALERT_TO_CONFIRM,
// Slovak
"QUICK INFO" to TitleID.QUICK_INFO,
@ -172,6 +192,8 @@ val knownScreenTitles = mapOf(
"DÁTA O CHYBÁCH" to TitleID.ERROR_DATA,
"SÚČTY DŇA" to TitleID.DAILY_TOTALS,
"DBD DÁTA" to TitleID.TBR_DATA,
"STLMI" to TitleID.ALERT_TO_SNOOZE,
"POTVRDI" to TitleID.ALERT_TO_CONFIRM,
// Romanian
"QUICK INFO" to TitleID.QUICK_INFO,
@ -186,6 +208,8 @@ val knownScreenTitles = mapOf(
"DATE EROARE" to TitleID.ERROR_DATA,
"TOTALURI ZILNICE" to TitleID.DAILY_TOTALS,
"DATE RBT" to TitleID.TBR_DATA,
"OPRIRE SONERIE" to TitleID.ALERT_TO_SNOOZE,
"CONFIRMARE" to TitleID.ALERT_TO_CONFIRM,
// Croatian
"QUICK INFO" to TitleID.QUICK_INFO,
@ -200,6 +224,8 @@ val knownScreenTitles = mapOf(
"PODACI O GREŠK." to TitleID.ERROR_DATA,
"UKUPNE DNEV.DOZE" to TitleID.DAILY_TOTALS,
"PODACI O PBD-U" to TitleID.TBR_DATA,
"ZA ODGODU" to TitleID.ALERT_TO_SNOOZE,
"ZA POTVRDU" to TitleID.ALERT_TO_CONFIRM,
// Dutch
"QUICK INFO" to TitleID.QUICK_INFO,
@ -214,6 +240,8 @@ val knownScreenTitles = mapOf(
"FOUTENGEGEVENS" to TitleID.ERROR_DATA,
"DAGTOTALEN" to TitleID.DAILY_TOTALS,
"TBD-GEGEVENS" to TitleID.TBR_DATA,
"UITSTELLEN" to TitleID.ALERT_TO_SNOOZE,
"BEVESTIGEN" to TitleID.ALERT_TO_CONFIRM,
// Greek
"QUICK INFO" to TitleID.QUICK_INFO,
@ -228,6 +256,8 @@ val knownScreenTitles = mapOf(
"ΔEΔOМ. ΣΦАΛМАTΩN" to TitleID.ERROR_DATA,
"HМEPHΣIO ΣΥNOΛO" to TitleID.DAILY_TOTALS,
"ΔEΔOМENА П.B.P." to TitleID.TBR_DATA,
"ANAΣTOΛH" to TitleID.ALERT_TO_SNOOZE,
"EПIBEBАIΩΣH" to TitleID.ALERT_TO_CONFIRM,
// Finnish
"QUICK INFO" to TitleID.QUICK_INFO,
@ -242,6 +272,8 @@ val knownScreenTitles = mapOf(
"HÄLYTYSTIEDOT" to TitleID.ERROR_DATA,
"PÄIV. KOK.ANNOS" to TitleID.DAILY_TOTALS,
"TBA - TIEDOT" to TitleID.TBR_DATA,
"ILMOITA MYÖH." to TitleID.ALERT_TO_SNOOZE,
"VAHVISTA" to TitleID.ALERT_TO_CONFIRM,
// Norwegian
"QUICK INFO" to TitleID.QUICK_INFO,
@ -256,6 +288,8 @@ val knownScreenTitles = mapOf(
"FEILDATA" to TitleID.ERROR_DATA,
"DØGNMENGDE" to TitleID.DAILY_TOTALS,
"MBD-DATA" to TitleID.TBR_DATA,
"FOR Å SLUMRE" to TitleID.ALERT_TO_SNOOZE,
"FOR Å BEKREFTE" to TitleID.ALERT_TO_CONFIRM,
// Portuguese
"QUICK INFO" to TitleID.QUICK_INFO,
@ -271,6 +305,8 @@ val knownScreenTitles = mapOf(
"DADOS DE ERROS" to TitleID.ERROR_DATA, "DADOS DE ALARMES" to TitleID.ERROR_DATA,
"TOTAIS DIÁRIOS" to TitleID.DAILY_TOTALS,
"DADOS DBT" to TitleID.TBR_DATA,
"PARA SILENCIAR" to TitleID.ALERT_TO_SNOOZE,
"PARA CONFIRMAR" to TitleID.ALERT_TO_CONFIRM,
// Swedish
"QUICK INFO" to TitleID.QUICK_INFO,
@ -285,6 +321,8 @@ val knownScreenTitles = mapOf(
"FELDATA" to TitleID.ERROR_DATA,
"DYGNSHISTORIK" to TitleID.DAILY_TOTALS,
"TBD DATA" to TitleID.TBR_DATA,
"SNOOZE" to TitleID.ALERT_TO_SNOOZE,
"BEKRÄFTA" to TitleID.ALERT_TO_CONFIRM,
// Danish
"QUICK INFO" to TitleID.QUICK_INFO,
@ -299,6 +337,8 @@ val knownScreenTitles = mapOf(
"FEJLDATA" to TitleID.ERROR_DATA,
"DAGLIG TOTAL" to TitleID.DAILY_TOTALS,
"MBR-DATA" to TitleID.TBR_DATA,
"FOR AT UDSÆTTE" to TitleID.ALERT_TO_SNOOZE,
"FOR GODKEND" to TitleID.ALERT_TO_CONFIRM,
// German
"QUICK INFO" to TitleID.QUICK_INFO,
@ -313,6 +353,8 @@ val knownScreenTitles = mapOf(
"FEHLERMELDUNGEN" to TitleID.ERROR_DATA,
"TAGESGESAMTMENGE" to TitleID.DAILY_TOTALS,
"TBR-INFORMATION" to TitleID.TBR_DATA,
"NEU ERINNERN" to TitleID.ALERT_TO_SNOOZE,
"BESTÄTIGEN" to TitleID.ALERT_TO_CONFIRM,
// Some pumps came preconfigured with a different quick info name
"ACCU CHECK SPIRIT" to TitleID.QUICK_INFO

View file

@ -300,7 +300,7 @@ class ParsedDisplayFrameStreamTest {
// We expect normal parsing behavior.
stream.feedDisplayFrame(testFrameW6CancelTbrWarningScreen)
val parsedWarningFrame = stream.getParsedDisplayFrame(processAlertScreens = false)
assertEquals(ParsedScreen.AlertScreen(AlertScreenContent.Warning(6)), parsedWarningFrame!!.parsedScreen)
assertEquals(ParsedScreen.AlertScreen(AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)), parsedWarningFrame!!.parsedScreen)
// Feed a W6 screen, but with alert screen detection enabled.
// We expect the alert screen to be detected and an exception

View file

@ -723,7 +723,7 @@ class RTNavigationTest {
)),
ParsedScreen.BasalRate1ProgrammingMenuScreen,
ParsedScreen.BasalRate2ProgrammingMenuScreen,
ParsedScreen.AlertScreen(AlertScreenContent.Warning(code = 6)),
ParsedScreen.AlertScreen(AlertScreenContent.Warning(code = 6, AlertScreenContent.AlertScreenState.TO_SNOOZE)),
ParsedScreen.BasalRate3ProgrammingMenuScreen,
ParsedScreen.BasalRate4ProgrammingMenuScreen,
ParsedScreen.BasalRate5ProgrammingMenuScreen
@ -864,7 +864,7 @@ class RTNavigationTest {
ParsedScreen.TemporaryBasalRatePercentageScreen(170, remainingDurationInMinutes = 30),
ParsedScreen.TemporaryBasalRatePercentageScreen(170, remainingDurationInMinutes = 30),
ParsedScreen.TemporaryBasalRatePercentageScreen(170, remainingDurationInMinutes = 30),
ParsedScreen.AlertScreen(AlertScreenContent.Warning(code = 6)),
ParsedScreen.AlertScreen(AlertScreenContent.Warning(code = 6, AlertScreenContent.AlertScreenState.TO_SNOOZE)),
ParsedScreen.TemporaryBasalRatePercentageScreen(160, remainingDurationInMinutes = 30),
ParsedScreen.TemporaryBasalRatePercentageScreen(160, remainingDurationInMinutes = 30)
))

View file

@ -679,16 +679,16 @@ class ParserTest {
assertEquals(ParseResult.Value::class, result::class)
val alertScreen = (result as ParseResult.Value<*>).value as ParsedScreen.AlertScreen
assertEquals(AlertScreenContent.Warning(6), alertScreen.content)
assertEquals(AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE), alertScreen.content)
}
@Test
fun checkW8CancelBolusWarningScreenParsing() {
val testScreens = listOf(
Pair(testFrameW8CancelBolusWarningScreen0, AlertScreenContent.None),
Pair(testFrameW8CancelBolusWarningScreen1, AlertScreenContent.Warning(8)),
Pair(testFrameW8CancelBolusWarningScreen1, AlertScreenContent.Warning(8, AlertScreenContent.AlertScreenState.TO_SNOOZE)),
Pair(testFrameW8CancelBolusWarningScreen2, AlertScreenContent.None),
Pair(testFrameW8CancelBolusWarningScreen3, AlertScreenContent.Warning(8))
Pair(testFrameW8CancelBolusWarningScreen3, AlertScreenContent.Warning(8, AlertScreenContent.AlertScreenState.TO_CONFIRM))
)
for (testScreen in testScreens) {
@ -704,7 +704,7 @@ class ParserTest {
fun checkE2BatteryEmptyErrorScreenParsing() {
val testScreens = listOf(
Pair(testFrameE2BatteryEmptyErrorScreen0, AlertScreenContent.None),
Pair(testFrameE2BatteryEmptyErrorScreen1, AlertScreenContent.Error(2))
Pair(testFrameE2BatteryEmptyErrorScreen1, AlertScreenContent.Error(2, AlertScreenContent.AlertScreenState.TO_CONFIRM))
)
for (testScreen in testScreens) {
@ -963,7 +963,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 1, dayOfMonth = 28, hour = 11, minute = 0, second = 0),
alert = AlertScreenContent.Warning(6)
alert = AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -994,7 +994,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 1, dayOfMonth = 28, hour = 11, minute = 0, second = 0),
alert = AlertScreenContent.Warning(6)
alert = AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1025,7 +1025,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 5, dayOfMonth = 11, hour = 21, minute = 56, second = 0),
alert = AlertScreenContent.Warning(7)
alert = AlertScreenContent.Warning(7, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1056,7 +1056,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 5, dayOfMonth = 11, hour = 21, minute = 56, second = 0),
alert = AlertScreenContent.Warning(7)
alert = AlertScreenContent.Warning(7, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1087,7 +1087,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 5, dayOfMonth = 11, hour = 21, minute = 56, second = 0),
alert = AlertScreenContent.Warning(7)
alert = AlertScreenContent.Warning(7, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1118,7 +1118,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 5, dayOfMonth = 11, hour = 21, minute = 56, second = 0),
alert = AlertScreenContent.Warning(7)
alert = AlertScreenContent.Warning(7, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1149,7 +1149,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 5, dayOfMonth = 11, hour = 21, minute = 56, second = 0),
alert = AlertScreenContent.Warning(7)
alert = AlertScreenContent.Warning(7, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1180,7 +1180,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 5, dayOfMonth = 11, hour = 21, minute = 56, second = 0),
alert = AlertScreenContent.Warning(7)
alert = AlertScreenContent.Warning(7, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1211,7 +1211,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 5, dayOfMonth = 11, hour = 21, minute = 56, second = 0),
alert = AlertScreenContent.Warning(7)
alert = AlertScreenContent.Warning(7, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1242,7 +1242,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 5, dayOfMonth = 11, hour = 21, minute = 56, second = 0),
alert = AlertScreenContent.Warning(7)
alert = AlertScreenContent.Warning(7, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1273,7 +1273,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 5, dayOfMonth = 11, hour = 21, minute = 56, second = 0),
alert = AlertScreenContent.Warning(7)
alert = AlertScreenContent.Warning(7, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1304,7 +1304,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 2, dayOfMonth = 1, hour = 1, minute = 6, second = 0),
alert = AlertScreenContent.Warning(1)
alert = AlertScreenContent.Warning(1, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1335,7 +1335,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 2, dayOfMonth = 1, hour = 1, minute = 6, second = 0),
alert = AlertScreenContent.Warning(1)
alert = AlertScreenContent.Warning(1, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1366,7 +1366,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 2, dayOfMonth = 1, hour = 1, minute = 6, second = 0),
alert = AlertScreenContent.Warning(1)
alert = AlertScreenContent.Warning(1, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1397,7 +1397,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 2, dayOfMonth = 1, hour = 1, minute = 6, second = 0),
alert = AlertScreenContent.Warning(1)
alert = AlertScreenContent.Warning(1, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1428,7 +1428,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 2, dayOfMonth = 1, hour = 1, minute = 6, second = 0),
alert = AlertScreenContent.Warning(1)
alert = AlertScreenContent.Warning(1, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1459,7 +1459,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 2, dayOfMonth = 1, hour = 1, minute = 6, second = 0),
alert = AlertScreenContent.Warning(1)
alert = AlertScreenContent.Warning(1, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1490,7 +1490,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 2, dayOfMonth = 1, hour = 1, minute = 6, second = 0),
alert = AlertScreenContent.Warning(1)
alert = AlertScreenContent.Warning(1, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1521,7 +1521,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 2, dayOfMonth = 1, hour = 1, minute = 6, second = 0),
alert = AlertScreenContent.Warning(1)
alert = AlertScreenContent.Warning(1, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1552,7 +1552,7 @@ class ParserTest {
ParsedScreen.MyDataErrorDataScreen(
index = 1, totalNumEntries = 30,
timestamp = LocalDateTime(year = 0, monthNumber = 1, dayOfMonth = 28, hour = 11, minute = 0, second = 0),
alert = AlertScreenContent.Warning(6)
alert = AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.HISTORY_ENTRY)
)
),
Pair(
@ -1595,6 +1595,180 @@ class ParserTest {
}
}
@Test
fun checkAlertScreenTextParsing() {
val testScreens = listOf(
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextEnglishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextEnglishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextSpanishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextSpanishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextFrenchScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextFrenchScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextItalianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextItalianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextRussianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextRussianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextTurkishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextTurkishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextPolishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextPolishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextCzechScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextCzechScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextHungarianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextHungarianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextSlovakScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextSlovakScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextRomanianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextRomanianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextCroatianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextCroatianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextDutchScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextDutchScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextGreekScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextGreekScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextFinnishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextFinnishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextNorwegianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextNorwegianScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextPortugueseScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextPortugueseScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextSwedishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextSwedishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextDanishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextDanishScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenSnoozeTextGermanScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_SNOOZE)
),
Pair(
AlertSnoozeAndConfirmScreens.testAlertScreenConfirmTextGermanScreen,
AlertScreenContent.Warning(6, AlertScreenContent.AlertScreenState.TO_CONFIRM)
),
)
for (testScreen in testScreens) {
val testContext = TestContext(testScreen.first, 0, skipTitleString = true)
val result = AlertScreenParser().parse(testContext.parseContext)
assertEquals(ParseResult.Value::class, result::class)
val alertScreen = (result as ParseResult.Value<*>).value as ParsedScreen.AlertScreen
assertEquals(testScreen.second, alertScreen.content)
}
}
@Test
fun checkToplevelScreenParsing() {
val testScreens = listOf(