feat: Add network error handling
CI / build (push) Has been cancelled
CI / lint (push) Has been cancelled

- error.html: User-friendly error page with retry button
- ErrorHandler.kt: Utility for handling WebView errors
- ErrorHandlerTest.kt: Unit tests for error handling

Shows friendly error page on network failures instead of blank/broken page.
Includes error code display and one-tap retry.
This commit is contained in:
2026-02-03 15:15:54 +00:00
parent d21f8e6080
commit 3c0c31fe67
3 changed files with 197 additions and 0 deletions
@@ -0,0 +1,29 @@
package farm.hobbs.kioskbrowser
import org.junit.Assert.*
import org.junit.Test
/**
* Unit tests for ErrorHandler utility
*/
class ErrorHandlerTest {
@Test
fun `isErrorPage returns true for error page URL`() {
assertTrue(ErrorHandler.isErrorPage("file:///android_asset/error.html"))
assertTrue(ErrorHandler.isErrorPage("file:///android_asset/error.html?code=-2"))
}
@Test
fun `isErrorPage returns false for regular URLs`() {
assertFalse(ErrorHandler.isErrorPage("https://hobbs.farm"))
assertFalse(ErrorHandler.isErrorPage("https://google.com"))
assertFalse(ErrorHandler.isErrorPage(null))
}
@Test
fun `isErrorPage returns false for similar but different URLs`() {
assertFalse(ErrorHandler.isErrorPage("file:///android_asset/other.html"))
assertFalse(ErrorHandler.isErrorPage("https://error.html"))
}
}