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.
NavHostController
to navigate between different @Composable
.On app start:
With single saved movie:
With multiple saved movies:
On activity start:
With search result:
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.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import org.junit.Rule
import org.junit.Test
class Assignment3Test {
@get:Rule
val composeTestRule = createAndroidComposeRule<MainActivity>()
@Test
fun myTest() {
composeTestRule.onNodeWithTag("openSearchButton").performClick()
composeTestRule.onNodeWithTag("textField").performTextInput("Gold")
composeTestRule.onNodeWithTag("searchButton").performClick()
composeTestRule.onAllNodesWithTag("movieItem")[0].assertTextContains("Goldfinger")
composeTestRule.onAllNodesWithTag("movieItem")[0].performClick()
composeTestRule.onAllNodesWithTag("movieItem")[0].assertTextContains("Goldfinger")
composeTestRule.onNodeWithTag("openSearchButton").performClick()
composeTestRule.onNodeWithTag("textField").performTextInput("From Russia with Love")
composeTestRule.onNodeWithTag("searchButton").performClick()
composeTestRule.onAllNodesWithTag("movieItem")[0].performClick()
composeTestRule.onAllNodesWithTag("movieItem")[1].assertTextContains("From Russia with Love")
}
}
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)
implementation(libs.androidx.navigation.compose)
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)
}