mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2026-10-17 04:52:35 +00:00
shared: Fix UI tests
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -15,20 +15,18 @@ import net.newpipe.app.model.Library
|
||||
class LibraryPreviewProvider : PreviewParameterProvider<Library> {
|
||||
|
||||
override val values: Sequence<Library>
|
||||
get() = sequenceOf(library)
|
||||
|
||||
companion object {
|
||||
val library = Library(
|
||||
id = "net.newpipe.extractor",
|
||||
name = "NewPipe Extractor",
|
||||
developers = listOf(
|
||||
Developer(
|
||||
name = "Team NewPipe",
|
||||
organisationUrl = "https://newpipe.net/"
|
||||
)
|
||||
),
|
||||
licenses = listOf("GPL-3.0-or-later"),
|
||||
website = "https://github.com/TeamNewPipe/NewPipeExtractor/"
|
||||
get() = sequenceOf(
|
||||
Library(
|
||||
id = "net.newpipe.extractor",
|
||||
name = "NewPipe Extractor",
|
||||
developers = listOf(
|
||||
Developer(
|
||||
name = "Team NewPipe",
|
||||
organisationUrl = "https://newpipe.net/"
|
||||
)
|
||||
),
|
||||
licenses = listOf("GPL-3.0-or-later"),
|
||||
website = "https://github.com/TeamNewPipe/NewPipeExtractor/"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -10,10 +10,10 @@ import androidx.compose.ui.test.assertIsDisplayed
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.v2.runComposeUiTest
|
||||
import net.newpipe.app.model.Developer
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
import net.newpipe.app.model.Library
|
||||
import net.newpipe.app.model.License
|
||||
|
||||
@OptIn(ExperimentalTestApi::class)
|
||||
class LibraryListItemTest {
|
||||
@@ -23,13 +23,13 @@ class LibraryListItemTest {
|
||||
val library = Library(
|
||||
id = "Test id",
|
||||
name = "Test name",
|
||||
developer = "Test developer",
|
||||
license = License(
|
||||
type = License.Companion.TYPE.APACHE_2_0,
|
||||
text = ""
|
||||
developers = listOf(
|
||||
Developer(name = "Test developer")
|
||||
),
|
||||
licenses = listOf("Apache-2.0"),
|
||||
website = "https://www.example.com"
|
||||
)
|
||||
val desc = "By ${library.developers.first().name} under ${library.licenses.first()}"
|
||||
var clicked = false
|
||||
setContent {
|
||||
LibraryListItem(
|
||||
@@ -41,7 +41,7 @@ class LibraryListItemTest {
|
||||
}
|
||||
|
||||
onNodeWithText(library.name).assertIsDisplayed()
|
||||
onNodeWithText("By ${library.developer} under ${library.license.spdxId}").apply {
|
||||
onNodeWithText(desc).apply {
|
||||
assertIsDisplayed()
|
||||
performClick()
|
||||
assertTrue(clicked)
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performScrollToNode
|
||||
import androidx.compose.ui.test.v2.runComposeUiTest
|
||||
import net.newpipe.app.model.License
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertTrue
|
||||
import net.newpipe.app.preview.LibraryPreviewProvider
|
||||
@@ -26,16 +27,20 @@ class LicenseDialogTest {
|
||||
|
||||
@Test
|
||||
fun testLicenseDialog() = runComposeUiTest {
|
||||
val library = LibraryPreviewProvider.library
|
||||
val license = License(
|
||||
name = "NewPipe e.V.",
|
||||
spdxID = "GPL-3.0-or-later",
|
||||
website = "https://newpipe-ev.de/"
|
||||
)
|
||||
var websiteActionClicked = false
|
||||
setContent {
|
||||
LicenseDialog(
|
||||
library = library,
|
||||
license = license,
|
||||
onOpenWebsite = { websiteActionClicked = true }
|
||||
)
|
||||
}
|
||||
|
||||
onNodeWithText(library.name).assertIsDisplayed()
|
||||
onNodeWithText(license.name).assertIsDisplayed()
|
||||
onNodeWithTag(TEST_TAG_LICENSE_TEXT)
|
||||
.performScrollToNode(hasText("https://www.gnu.org/philosophy/why-not-lgpl.html", substring = true))
|
||||
.assertIsDisplayed()
|
||||
|
||||
Reference in New Issue
Block a user