Please conduct the following tasks alone. For implementation details you can refer to the lecture slides or the Android developer website. Please do not hesitate to ask me or the tutor if you have any questions.
LazyColumn
to your MainActivity displaying items according to the row data below@Composable
for a movie item as describedUse a data model which represents the movie items:
data class Movie (
val title: String,
val year: String,
val actor: String
)
Example Layout:
Use this data to fill out your rows:
title | year | actor |
---|---|---|
Dr. No | 1962 | Sean Connery |
From Russia with Love | 1963 | Sean Connery |
Goldfinger | 1964 | Sean Connery |
Thunderball | 1965 | Sean Connery |
You Only Live Twice | 1967 | Sean Connery |
package de.hdmstuttgart.movietracker
import androidx.compose.ui.test.assertTextContains
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.compose.ui.test.performClick
import org.junit.Rule
import org.junit.Test
class Assignment2Test {
@get:Rule
val composeTestRule = createAndroidComposeRule<MainActivity>()
@Test
fun myTest() {
composeTestRule.onAllNodesWithTag("movieItem")[0].assertTextContains("Dr. No")
composeTestRule.onAllNodesWithTag("movieItem")[1].assertTextContains("From Russia with Love")
composeTestRule.onAllNodesWithTag("movieItem")[2].assertTextContains("Goldfinger")
composeTestRule.onAllNodesWithTag("movieItem")[3].assertTextContains("Thunderball")
composeTestRule.onAllNodesWithTag("movieItem")[4].assertTextContains("You Only Live Twice")
composeTestRule.onAllNodesWithTag("movieItem")[0].performClick()
composeTestRule.onAllNodesWithTag("movieItem")[0].assertTextContains("From Russia with Love")
composeTestRule.onAllNodesWithTag("movieItem")[0].performClick()
composeTestRule.onAllNodesWithTag("movieItem")[0].assertTextContains("Goldfinger")
}
}
Module build.gradle.kts
:
dependencies {
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}