-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
frontend/app/src/androidTest/java/com/example/speechbuddy/BackupSettingsScreenTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.example.speechbuddy | ||
|
||
import android.content.Intent | ||
import androidx.activity.compose.setContent | ||
import androidx.compose.foundation.layout.PaddingValues | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.test.assertHasClickAction | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.assertIsEnabled | ||
import androidx.compose.ui.test.assertIsOff | ||
import androidx.compose.ui.test.assertIsOn | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import com.example.speechbuddy.compose.settings.BackupSettings | ||
import com.example.speechbuddy.ui.SpeechBuddyTheme | ||
import dagger.hilt.android.testing.HiltAndroidRule | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
@HiltAndroidTest | ||
class BackupSettingsScreenTest { | ||
private val androidTestUtil = AndroidTestUtil() | ||
|
||
@get:Rule(order = 0) | ||
val hiltRule = HiltAndroidRule(this) | ||
|
||
@get:Rule(order = 1) | ||
val composeTestRule = androidTestUtil.createAndroidIntentComposeRule<HomeActivity> { | ||
Intent(it, HomeActivity::class.java).apply { | ||
putExtra("isTest", true) | ||
} | ||
} | ||
|
||
@Before | ||
fun setUp() { | ||
hiltRule.inject() | ||
composeTestRule.activity.setContent { | ||
SpeechBuddyTheme( | ||
settingsRepository = composeTestRule.activity.settingsRepository, | ||
initialDarkMode = false | ||
) { | ||
BackupSettings( | ||
paddingValues = PaddingValues() | ||
) | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun should_display_all_elements_when_account_settings_screen_appears() { | ||
composeTestRule.onNodeWithText(BACKUP_TO_SERVER).assertIsDisplayed() | ||
composeTestRule.onNodeWithText(LAST_BACKUP_DATE).assertIsDisplayed() | ||
composeTestRule.onNodeWithText(ENABLE_AUTO_BACKUP).assertIsDisplayed() | ||
composeTestRule.onNodeWithText(BACKUP_NOW).assertIsDisplayed().assertIsEnabled().assertHasClickAction() | ||
composeTestRule.onNodeWithTag("auto_backup").assertIsDisplayed().assertIsEnabled() | ||
} | ||
|
||
@Test | ||
fun should_change_auto_backup_when_switch_is_clicked() { | ||
composeTestRule.onNodeWithTag("auto_backup").assertIsOn() | ||
composeTestRule.onNodeWithTag("auto_backup").performClick() | ||
composeTestRule.onNodeWithTag("auto_backup").assertIsOff() | ||
composeTestRule.onNodeWithTag("auto_backup").performClick() | ||
composeTestRule.onNodeWithTag("auto_backup").assertIsOn() | ||
} | ||
|
||
@Test | ||
fun should_show_loading_indicator_when_backup_is_clicked() { | ||
composeTestRule.onNodeWithText(BACKUP_NOW).performClick() | ||
composeTestRule.onNodeWithTag("backup_loading").assertIsDisplayed() | ||
} | ||
|
||
companion object { | ||
const val BACKUP_TO_SERVER = "서버에 백업하기" | ||
const val LAST_BACKUP_DATE = "마지막 백업 날짜" | ||
const val ENABLE_AUTO_BACKUP = "자동 백업 활성화" | ||
const val BACKUP_NOW = "지금 백업하기" | ||
|
||
val LIGHT_COLOR = Color(0xFF000000) | ||
val DARK_COLOR = Color(0xFFFFFFFF) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters