Compare commits

..

No commits in common. "b7c24af28a9ed1ea60e1b553d5df6cbbebe459b0" and "ff3185b914b8163e6d64e8218fe016ca05e392e7" have entirely different histories.

3 changed files with 2 additions and 15 deletions

View File

@ -82,7 +82,6 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:${rootProject.extra["lifecycle_version"]}")
implementation("androidx.navigation:navigation-compose:2.7.4")
// Testing Depedencies
androidTestImplementation(platform("androidx.compose:compose-bom:2023.10.01"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
androidTestImplementation("androidx.navigation:navigation-testing:2.7.4")

View File

@ -39,7 +39,7 @@ class CupcakeScreenNavigationTest {
* Note: To access to an empty activity, the code uses ComponentActivity instead of
* MainActivity.
*/
@get:Rule // Aturan Pengujian
@get:Rule
val composeTestRule = createAndroidComposeRule<ComponentActivity>()
private lateinit var navController: TestNavHostController
@ -54,20 +54,17 @@ class CupcakeScreenNavigationTest {
}
}
// Testing Verifikasi Tujuan Awal Aplikasi Dimulai
@Test
fun cupcakeNavHost_verifyStartDestination() {
navController.assertCurrentRouteName(CupcakeScreen.Start.name)
}
// Testing Fungsi Tombol Kembali di Menu Awal (Tidak ada tombol kembali)
@Test
fun cupcakeNavHost_verifyBackNavigationNotShownOnStartOrderScreen() {
val backText = composeTestRule.activity.getString(R.string.back_button)
composeTestRule.onNodeWithContentDescription(backText).assertDoesNotExist()
}
// Testing Pilih Opsi --> Navigasi Ke Halaman Flavor
@Test
fun cupcakeNavHost_clickOneCupcake_navigatesToSelectFlavorScreen() {
composeTestRule.onNodeWithStringId(R.string.one_cupcake)
@ -75,7 +72,6 @@ class CupcakeScreenNavigationTest {
navController.assertCurrentRouteName(CupcakeScreen.Flavor.name)
}
// Testing Next Button --> Navigasi Ke Halaman Pickup (Flavor)
@Test
fun cupcakeNavHost_clickNextOnFlavorScreen_navigatesToPickupScreen() {
navigateToFlavorScreen()
@ -84,7 +80,6 @@ class CupcakeScreenNavigationTest {
navController.assertCurrentRouteName(CupcakeScreen.Pickup.name)
}
// Testing Back Button --> Navigasi Ke Halaman Awal (Flavor)
@Test
fun cupcakeNavHost_clickBackOnFlavorScreen_navigatesToStartOrderScreen() {
navigateToFlavorScreen()
@ -92,7 +87,6 @@ class CupcakeScreenNavigationTest {
navController.assertCurrentRouteName(CupcakeScreen.Start.name)
}
// Testing Cancel Button --> Navigasi Ke Halaman Awal (Flavor)
@Test
fun cupcakeNavHost_clickCancelOnFlavorScreen_navigatesToStartOrderScreen() {
navigateToFlavorScreen()
@ -101,7 +95,6 @@ class CupcakeScreenNavigationTest {
navController.assertCurrentRouteName(CupcakeScreen.Start.name)
}
// Testing Next Button --> Navigasi Ke Halaman Summary (Pickup)
@Test
fun cupcakeNavHost_clickNextOnPickupScreen_navigatesToSummaryScreen() {
navigateToPickupScreen()
@ -112,7 +105,6 @@ class CupcakeScreenNavigationTest {
navController.assertCurrentRouteName(CupcakeScreen.Summary.name)
}
// Testing Back Button --> Navigasi Ke Halaman Flavor (Pickup)
@Test
fun cupcakeNavHost_clickBackOnPickupScreen_navigatesToFlavorScreen() {
navigateToPickupScreen()
@ -120,7 +112,6 @@ class CupcakeScreenNavigationTest {
navController.assertCurrentRouteName(CupcakeScreen.Flavor.name)
}
// Testing Cancel Button --> Navigasi Ke Halaman Awal (Pickup)
@Test
fun cupcakeNavHost_clickCancelOnPickupScreen_navigatesToStartOrderScreen() {
navigateToPickupScreen()
@ -129,7 +120,6 @@ class CupcakeScreenNavigationTest {
navController.assertCurrentRouteName(CupcakeScreen.Start.name)
}
// Testing Cancel Button --> Navigasi Ke Halaman Awal (Summary)
@Test
fun cupcakeNavHost_clickCancelOnSummaryScreen_navigatesToStartOrderScreen() {
navigateToSummaryScreen()
@ -138,8 +128,6 @@ class CupcakeScreenNavigationTest {
navController.assertCurrentRouteName(CupcakeScreen.Start.name)
}
// FUNGSI NAVIGASI HALAMAN
private fun navigateToFlavorScreen() {
composeTestRule.onNodeWithStringId(R.string.one_cupcake)
.performClick()

View File

@ -56,7 +56,7 @@ import com.example.cupcake.ui.StartOrderScreen
* enum values that represent the screens in the app
*/
enum class CupcakeScreen(@StringRes val title: Int) {
Start(title = R.string.app_name), // Tampilan Awal Aplikasi
Start(title = R.string.app_name),
Flavor(title = R.string.choose_flavor),
Pickup(title = R.string.choose_pickup_date),
Summary(title = R.string.order_summary)