comboctl-parser: Don't try to interpret text in error screens
That text shows contents that are different to that of warning screens. Instead of extending the interpretation logic to cover such contents as well, just use a generic ERROR_TEXT AlertScreenState. That text won't be interpreted by any program logic anyway, since error screens are never dismissed automatically. Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
parent
377188353a
commit
cc4cd2dc04
3 changed files with 175 additions and 8 deletions
|
@ -84,6 +84,9 @@ sealed class AlertScreenContent {
|
|||
enum class AlertScreenState {
|
||||
TO_SNOOZE,
|
||||
TO_CONFIRM,
|
||||
// Used when the alert is an error. The text in error screens is not
|
||||
// interpreted, since it is anyway fully up to the user to interpret it.
|
||||
ERROR_TEXT,
|
||||
HISTORY_ENTRY
|
||||
}
|
||||
|
||||
|
@ -1156,15 +1159,14 @@ 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) -> {
|
||||
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
|
||||
}
|
||||
ParseResult.Value(ParsedScreen.AlertScreen(
|
||||
AlertScreenContent.Warning(parseResult.valueAt(2), alertState)
|
||||
))
|
||||
|
@ -1172,7 +1174,14 @@ class AlertScreenParser : Parser() {
|
|||
|
||||
Glyph.LargeSymbol(LargeSymbol.ERROR) -> {
|
||||
ParseResult.Value(ParsedScreen.AlertScreen(
|
||||
AlertScreenContent.Error(parseResult.valueAt(2), alertState)
|
||||
AlertScreenContent.Error(
|
||||
parseResult.valueAt(2),
|
||||
// We don't really care about the state string if an error is shown.
|
||||
// It's not like any logic here will interpret it; that text is
|
||||
// purely for the user. So, don't bother interpreting it here, and
|
||||
// just assign a generic ERROR_TEXT state value instead.
|
||||
AlertScreenContent.AlertScreenState.ERROR_TEXT
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
@ -716,6 +716,24 @@ class ParserTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkE4OcclusionErrorScreenParsing() {
|
||||
val testScreens = listOf(
|
||||
Pair(testFrameE4OcclusionErrorScreen0, AlertScreenContent.Error(4, AlertScreenContent.AlertScreenState.ERROR_TEXT)),
|
||||
Pair(testFrameE4OcclusionErrorScreen1, AlertScreenContent.None),
|
||||
Pair(testFrameE4OcclusionErrorScreen2, AlertScreenContent.Error(4, AlertScreenContent.AlertScreenState.ERROR_TEXT)),
|
||||
Pair(testFrameE4OcclusionErrorScreen3, AlertScreenContent.None),
|
||||
)
|
||||
|
||||
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 screen = (result as ParseResult.Value<*>).value as ParsedScreen.AlertScreen
|
||||
assertEquals(testScreen.second, screen.content)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun checkTemporaryBasalRatePercentageScreenParsing() {
|
||||
val testScreens = listOf(
|
||||
|
|
|
@ -1700,6 +1700,146 @@ val testFrameE2BatteryEmptyErrorScreen1 = makeDisplayFrame(arrayOf(
|
|||
" ████ █████ ████ █ █ █ █ ███ ████ █████ █ █ "
|
||||
))
|
||||
|
||||
val testFrameE4OcclusionErrorScreen0 = makeDisplayFrame(arrayOf(
|
||||
"█ █ █████ ████ ████ █████ ███ ████ █████ █ █ █ █ ███ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ",
|
||||
"█ █ ████ ████ ███ █ █ █ ████ ████ █ █ █ █ █ █ ███ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
" █ █████ █ █ ████ █ ███ █ █ ███ █ █ ████ ",
|
||||
" ",
|
||||
" █████ ████████ ██ ████████ ",
|
||||
" █████████ ██ ███ ██████████ ",
|
||||
" ███████████ ██ ███ ████████████ ",
|
||||
" ███ █████ ███ ██ ████ ██████████████ ",
|
||||
" ██ ███ ██ ██ █ ██ ████████████████ ",
|
||||
" ████ █ ████ ██ ██ ██ █ █ █ █ ██ ",
|
||||
" █████ █████ ██ █ ██ █ ███ ██ █ █ █ █ ",
|
||||
" ██████ ██████ ███████ ██ ██ █ ██ ██ █ █ ██ ",
|
||||
" █████ █████ ██ ██ ██ ██ ██ ██ █ █ ███ ",
|
||||
" ████ █ ████ ██ ████████ █ ██ ██ █ ███ ",
|
||||
" ██ ███ ██ ██ ██ ████████████████ ",
|
||||
" ███ █████ ███ ██ ██ ██████████████ ",
|
||||
" ███████████ ██ ██ ████████████ ",
|
||||
" █████████ ██ ██ ██████████ ",
|
||||
" █████ ████████ ██ ████████ ",
|
||||
" ",
|
||||
" ",
|
||||
" █ ████ █████ █ █ █ █ █ █ ████ ███ █ █ █ █ █████ █████ █ █ ",
|
||||
" ██ █ █ █ █ ██ ██ ██ ██ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
"█ ██ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ ",
|
||||
"███ ███ █ █ █ █ █ █ █ █ █ ███ █ █████ █████ █ █ ████ █ █ █ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
" ████ █ ███ █ █ █ █ ████ ███ █ █ █ █ █████ █ █████ █ █ "
|
||||
))
|
||||
|
||||
val testFrameE4OcclusionErrorScreen1 = makeDisplayFrame(arrayOf(
|
||||
"█ █ █████ ████ ████ █████ ███ ████ █████ █ █ █ █ ███ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ",
|
||||
"█ █ ████ ████ ███ █ █ █ ████ ████ █ █ █ █ █ █ ███ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
" █ █████ █ █ ████ █ ███ █ █ ███ █ █ ████ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" █ ████ █████ █ █ █ █ █ █ ████ ███ █ █ █ █ █████ █████ █ █ ",
|
||||
" ██ █ █ █ █ ██ ██ ██ ██ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
"█ ██ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ ",
|
||||
"███ ███ █ █ █ █ █ █ █ █ █ ███ █ █████ █████ █ █ ████ █ █ █ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
" ████ █ ███ █ █ █ █ ████ ███ █ █ █ █ █████ █ █████ █ █ "
|
||||
))
|
||||
|
||||
val testFrameE4OcclusionErrorScreen2 = makeDisplayFrame(arrayOf(
|
||||
"█ █ █████ ████ ████ █████ ███ ████ █████ █ █ █ █ ███ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ",
|
||||
"█ █ ████ ████ ███ █ █ █ ████ ████ █ █ █ █ █ █ ███ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
" █ █████ █ █ ████ █ ███ █ █ ███ █ █ ████ ",
|
||||
" ",
|
||||
" █████ ████████ ██ ████████ ",
|
||||
" █████████ ██ ███ ██████████ ",
|
||||
" ███████████ ██ ███ ████████████ ",
|
||||
" ███ █████ ███ ██ ████ ██████████████ ",
|
||||
" ██ ███ ██ ██ █ ██ ████████████████ ",
|
||||
" ████ █ ████ ██ ██ ██ █ █ █ █ ██ ",
|
||||
" █████ █████ ██ █ ██ █ ███ ██ █ █ █ █ ",
|
||||
" ██████ ██████ ███████ ██ ██ █ ██ ██ █ █ ██ ",
|
||||
" █████ █████ ██ ██ ██ ██ ██ ██ █ █ ███ ",
|
||||
" ████ █ ████ ██ ████████ █ ██ ██ █ ███ ",
|
||||
" ██ ███ ██ ██ ██ ████████████████ ",
|
||||
" ███ █████ ███ ██ ██ ██████████████ ",
|
||||
" ███████████ ██ ██ ████████████ ",
|
||||
" █████████ ██ ██ ██████████ ",
|
||||
" █████ ████████ ██ ████████ ",
|
||||
" ",
|
||||
" ",
|
||||
" █ ████ █████ ████ █████ █ █ █████ ███ ███ █████ █ █ ",
|
||||
" ██ █ █ █ █ █ ███ █ █ █ █ █ █ █ ",
|
||||
"█ ██ █ █ █ █ █ █ █ █ █ █ █ ██ █ ",
|
||||
"███ ████ ████ ███ █ █ █ █ █ █ ███ ████ █ █ █ ",
|
||||
" █ █ █ █ █ █ █████ █ █ █ █ █ █ ██ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
" ████ █████ ████ █ █ █ █ ███ ████ █████ █ █ "
|
||||
))
|
||||
|
||||
val testFrameE4OcclusionErrorScreen3 = makeDisplayFrame(arrayOf(
|
||||
"█ █ █████ ████ ████ █████ ███ ████ █████ █ █ █ █ ███ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ",
|
||||
"█ █ ████ ████ ███ █ █ █ ████ ████ █ █ █ █ █ █ ███ ",
|
||||
"█ █ █ █ █ █ █ █ █ █ █ █ █ █ ██ █ █ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
" █ █████ █ █ ████ █ ███ █ █ ███ █ █ ████ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" █ ████ █████ ████ █████ █ █ █████ ███ ███ █████ █ █ ",
|
||||
" ██ █ █ █ █ █ ███ █ █ █ █ █ █ █ ",
|
||||
"█ ██ █ █ █ █ █ █ █ █ █ █ █ ██ █ ",
|
||||
"███ ████ ████ ███ █ █ █ █ █ █ ███ ████ █ █ █ ",
|
||||
" █ █ █ █ █ █ █████ █ █ █ █ █ █ ██ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
" ████ █████ ████ █ █ █ █ ███ ████ █████ █ █ "
|
||||
))
|
||||
|
||||
val testFrameTemporaryBasalRatePercentage100Screen = makeDisplayFrame(arrayOf(
|
||||
"█████ ████ ████ █ █ █████ ████ █████ ",
|
||||
" █ █ █ █ █ █ █ █ █ █ █ ",
|
||||
|
|
Loading…
Reference in a new issue