-
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.
* Built Read summary feature * Tests for FileDownloaderTest, ReadSummaryViewModelTest, TextScaleFactorTest * Tests for MarkdownParserTest, MarkdownTextTest, ReadFontScaleChooser, ReadSummaryScreen * Fixing detekt and ktlint issues * Removed graphics, Fixing detekt and ktlint issues * Removed GifImage.kt * Fixing Detekt issues * Adding missing tests
- Loading branch information
Showing
60 changed files
with
2,316 additions
and
86 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
44 changes: 44 additions & 0 deletions
44
app/src/androidTest/java/app/books/tanga/read/ReadFontScaleChooserTest.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,44 @@ | ||
package app.books.tanga.read | ||
|
||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performTouchInput | ||
import androidx.compose.ui.test.swipeRight | ||
import app.books.tanga.feature.read.components.ReadFontScaleChooser | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ReadFontScaleChooserTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun readFontScaleChooser_renders_correctly() { | ||
var scale = 0f | ||
composeTestRule.setContent { | ||
ReadFontScaleChooser( | ||
initialValue = scale, | ||
onFontScaleChange = { scale = it } | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithTag("font_size_min").assertExists() | ||
composeTestRule.onNodeWithTag("font_size_max").assertExists() | ||
} | ||
|
||
@Test | ||
fun readFontScaleChooser_updates_scale_on_slider_interaction() { | ||
var scale = 0f | ||
composeTestRule.setContent { | ||
ReadFontScaleChooser( | ||
initialValue = scale, | ||
onFontScaleChange = { scale = it } | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithTag("slider").performTouchInput { swipeRight() } | ||
|
||
assert(scale > 0f) | ||
} | ||
} |
155 changes: 155 additions & 0 deletions
155
app/src/androidTest/java/app/books/tanga/read/ReadSummaryScreenTest.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,155 @@ | ||
package app.books.tanga.read | ||
|
||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import app.books.tanga.common.ui.ProgressState | ||
import app.books.tanga.feature.read.ReadSummaryScreen | ||
import app.books.tanga.feature.read.ReadSummaryUiState | ||
import app.books.tanga.feature.summary.SummaryContentState | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ReadSummaryScreenTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun readSummaryScreenRendersCorrectly() { | ||
val state = ReadSummaryUiState( | ||
summaryContentState = SummaryContentState( | ||
isFavorite = false, | ||
favoriteProgressState = ProgressState.Hide | ||
), | ||
summaryTextContent = "Test content", | ||
progressState = ProgressState.Hide | ||
) | ||
|
||
composeTestRule.setContent { | ||
ReadSummaryScreen( | ||
state = state, | ||
onNavigateToPreviousScreen = {}, | ||
onToggleFavorite = {}, | ||
onNavigateToAudioPlayer = {}, | ||
onFontSizeClick = {}, | ||
onFontScaleChange = {} | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithTag("back_button", useUnmergedTree = true).assertExists() | ||
composeTestRule.onNodeWithTag("font_size", useUnmergedTree = true).assertExists() | ||
} | ||
|
||
@Test | ||
fun readSummaryScreenDisplaysMarkdownTextContent() { | ||
val markdownTextContent = "## Test Markdown Content" | ||
val state = ReadSummaryUiState( | ||
summaryContentState = SummaryContentState( | ||
isFavorite = false, | ||
favoriteProgressState = ProgressState.Hide | ||
), | ||
summaryTextContent = markdownTextContent, | ||
progressState = ProgressState.Hide | ||
) | ||
|
||
composeTestRule.setContent { | ||
ReadSummaryScreen( | ||
state = state, | ||
onNavigateToPreviousScreen = {}, | ||
onToggleFavorite = {}, | ||
onNavigateToAudioPlayer = {}, | ||
onFontSizeClick = {}, | ||
onFontScaleChange = {} | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithText("Test Markdown Content").assertExists() | ||
composeTestRule.onNodeWithText(markdownTextContent).assertDoesNotExist() | ||
} | ||
|
||
@Test | ||
fun readSummaryScreenTriggersOnBackClick() { | ||
var backClicked = false | ||
val state = ReadSummaryUiState( | ||
summaryContentState = SummaryContentState( | ||
isFavorite = false, | ||
favoriteProgressState = ProgressState.Hide | ||
), | ||
summaryTextContent = "Test content", | ||
progressState = ProgressState.Hide | ||
) | ||
|
||
composeTestRule.setContent { | ||
ReadSummaryScreen( | ||
state = state, | ||
onNavigateToPreviousScreen = { backClicked = true }, | ||
onToggleFavorite = {}, | ||
onNavigateToAudioPlayer = {}, | ||
onFontSizeClick = {}, | ||
onFontScaleChange = {} | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithTag("back_button", useUnmergedTree = true).performClick() | ||
|
||
assert(backClicked) | ||
} | ||
|
||
@Test | ||
fun readSummaryScreenTriggersOnFontSizeClick() { | ||
var fontSizeClicked = false | ||
val state = ReadSummaryUiState( | ||
summaryContentState = SummaryContentState( | ||
isFavorite = false, | ||
favoriteProgressState = ProgressState.Hide | ||
), | ||
summaryTextContent = "Test content", | ||
progressState = ProgressState.Hide | ||
) | ||
|
||
composeTestRule.setContent { | ||
ReadSummaryScreen( | ||
state = state, | ||
onNavigateToPreviousScreen = {}, | ||
onToggleFavorite = {}, | ||
onNavigateToAudioPlayer = {}, | ||
onFontSizeClick = { fontSizeClicked = true }, | ||
onFontScaleChange = {} | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithTag("font_size", useUnmergedTree = true).performClick() | ||
|
||
assert(fontSizeClicked) | ||
} | ||
|
||
@Test | ||
fun readSummaryScreenTriggersOnToggleFavorite() { | ||
var favoriteToggled = false | ||
val state = ReadSummaryUiState( | ||
summaryContentState = SummaryContentState( | ||
isFavorite = false, | ||
favoriteProgressState = ProgressState.Hide | ||
), | ||
summaryTextContent = "Test content", | ||
progressState = ProgressState.Hide | ||
) | ||
|
||
composeTestRule.setContent { | ||
ReadSummaryScreen( | ||
state = state, | ||
onNavigateToPreviousScreen = {}, | ||
onToggleFavorite = { favoriteToggled = true }, | ||
onNavigateToAudioPlayer = {}, | ||
onFontSizeClick = {}, | ||
onFontScaleChange = {} | ||
) | ||
} | ||
|
||
composeTestRule.onNodeWithTag("save_favorite").performClick() | ||
|
||
assert(favoriteToggled) | ||
} | ||
} |
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
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
Oops, something went wrong.