From 19fb9899cd76f4221fd408c415d86358da54cc41 Mon Sep 17 00:00:00 2001 From: Su TT Date: Thu, 3 Jul 2025 14:25:36 -0400 Subject: [PATCH] Fix CommentSectionErrorTest to use named NetworkException for instrumented test compatibility --- .../components/video/comments/CommentSectionErrorTest.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/androidTest/java/org/schabi/newpipe/ui/components/video/comments/CommentSectionErrorTest.kt b/app/src/androidTest/java/org/schabi/newpipe/ui/components/video/comments/CommentSectionErrorTest.kt index bcf9641bd..d4cb2ab54 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/ui/components/video/comments/CommentSectionErrorTest.kt +++ b/app/src/androidTest/java/org/schabi/newpipe/ui/components/video/comments/CommentSectionErrorTest.kt @@ -24,13 +24,14 @@ class CommentSectionErrorTest { /** * Test Resource.Error state - when initial comment info loading fails */ + class TestNetworkException : NetworkException("Connection attempt timed out", null) { + override fun getErrorCode(): Int = NetworkException.ERROR_CONNECTION_TIMED_OUT + override fun isImmediatelyRetryable() = true + } @Test fun testResourceErrorState_ShowsUnableToLoadCommentsUiModel() { - val networkException = object : NetworkException("Connection attempt timed out", null) { - override fun getErrorCode(): Int = NetworkException.ERROR_CONNECTION_TIMED_OUT - override fun isImmediatelyRetryable() = true - } + val networkException = TestNetworkException() val errorResource = Resource.Error(networkException) assertEquals("Should contain the network exception", networkException, errorResource.throwable)