11package org.schabi.newpipe.ui.components.common
22
33import androidx.activity.ComponentActivity
4- import androidx.annotation.StringRes
54import androidx.compose.ui.test.assertIsDisplayed
65import androidx.compose.ui.test.junit4.createAndroidComposeRule
7- import androidx.compose.ui.test.onNodeWithText
86import androidx.compose.ui.test.performClick
97import androidx.test.ext.junit.runners.AndroidJUnit4
108import java.net.UnknownHostException
@@ -16,6 +14,7 @@ import org.schabi.newpipe.error.ErrorInfo
1614import org.schabi.newpipe.error.UserAction
1715import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
1816import org.schabi.newpipe.extractor.exceptions.UnsupportedContentInCountryException
17+ import org.schabi.newpipe.onNodeWithText
1918import org.schabi.newpipe.ui.theme.AppTheme
2019
2120@RunWith(AndroidJUnit4 ::class )
@@ -30,7 +29,6 @@ class ErrorPanelTest {
3029 }
3130 }
3231 }
33- private fun text (@StringRes id : Int ) = composeRule.activity.getString(id)
3432
3533 /* *
3634 * Test Network Error
@@ -44,11 +42,11 @@ class ErrorPanelTest {
4442 )
4543
4644 setErrorPanel(networkErrorInfo, onRetry = {})
47- composeRule.onNodeWithText(text( R .string.network_error) ).assertIsDisplayed()
48- composeRule.onNodeWithText(text( R .string.retry) , ignoreCase = true ).assertIsDisplayed()
49- composeRule.onNodeWithText(text( R .string.error_snackbar_action) , ignoreCase = true )
45+ composeRule.onNodeWithText(R .string.network_error).assertIsDisplayed()
46+ composeRule.onNodeWithText(R .string.retry, ignoreCase = true ).assertIsDisplayed()
47+ composeRule.onNodeWithText(R .string.error_snackbar_action, ignoreCase = true )
5048 .assertDoesNotExist()
51- composeRule.onNodeWithText(text( R .string.recaptcha_solve) , ignoreCase = true )
49+ composeRule.onNodeWithText(R .string.recaptcha_solve, ignoreCase = true )
5250 .assertDoesNotExist()
5351 }
5452
@@ -64,9 +62,9 @@ class ErrorPanelTest {
6462 )
6563
6664 setErrorPanel(unexpectedErrorInfo, onRetry = {})
67- composeRule.onNodeWithText(text( R .string.error_snackbar_message) ).assertIsDisplayed()
68- composeRule.onNodeWithText(text( R .string.retry) , ignoreCase = true ).assertIsDisplayed()
69- composeRule.onNodeWithText(text( R .string.error_snackbar_action) , ignoreCase = true )
65+ composeRule.onNodeWithText(R .string.error_snackbar_message).assertIsDisplayed()
66+ composeRule.onNodeWithText(R .string.retry, ignoreCase = true ).assertIsDisplayed()
67+ composeRule.onNodeWithText(R .string.error_snackbar_action, ignoreCase = true )
7068 .assertIsDisplayed()
7169 }
7270
@@ -91,14 +89,14 @@ class ErrorPanelTest {
9189 onRetry = { retryClicked = true }
9290
9391 )
94- composeRule.onNodeWithText(text( R .string.recaptcha_solve) , ignoreCase = true )
92+ composeRule.onNodeWithText(R .string.recaptcha_solve, ignoreCase = true )
9593 .assertIsDisplayed()
96- composeRule.onNodeWithText(text( R .string.retry) , ignoreCase = true )
94+ composeRule.onNodeWithText(R .string.retry, ignoreCase = true )
9795 .assertIsDisplayed()
9896 .performClick()
99- composeRule.onNodeWithText(text( R .string.open_in_browser) , ignoreCase = true )
97+ composeRule.onNodeWithText(R .string.open_in_browser, ignoreCase = true )
10098 .assertIsDisplayed()
101- composeRule.onNodeWithText(text( R .string.error_snackbar_action) , ignoreCase = true )
99+ composeRule.onNodeWithText(R .string.error_snackbar_action, ignoreCase = true )
102100 .assertIsDisplayed()
103101 assert (retryClicked) { " onRetry callback should have been invoked" }
104102 }
@@ -116,11 +114,11 @@ class ErrorPanelTest {
116114
117115 setErrorPanel(contentNotAvailable)
118116
119- composeRule.onNodeWithText(text( R .string.unsupported_content_in_country) )
117+ composeRule.onNodeWithText(R .string.unsupported_content_in_country)
120118 .assertIsDisplayed()
121- composeRule.onNodeWithText(text( R .string.retry) , ignoreCase = true )
119+ composeRule.onNodeWithText(R .string.retry, ignoreCase = true )
122120 .assertDoesNotExist()
123- composeRule.onNodeWithText(text( R .string.error_snackbar_action) , ignoreCase = true )
121+ composeRule.onNodeWithText(R .string.error_snackbar_action, ignoreCase = true )
124122 .assertDoesNotExist()
125123 }
126124}
0 commit comments