-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a unit test to the imageviewer example. (#3527)
* Add a unit test to the imageviewer example. * Fix android build of imageviewer
- Loading branch information
Showing
9 changed files
with
70 additions
and
23 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
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
3 changes: 2 additions & 1 deletion
3
...viewer/shared/src/androidMain/kotlin/example/imageviewer/view/ScrollableColumn.android.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package example.imageviewer.view | ||
|
||
import androidx.compose.foundation.layout.ColumnScope | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
|
||
@Composable | ||
actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) = | ||
actual fun ScrollableColumn(modifier: Modifier, content: @Composable ColumnScope.() -> Unit) = | ||
TouchScrollableColumn(modifier, content) |
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
5 changes: 3 additions & 2 deletions
5
...geviewer/shared/src/commonMain/kotlin/example/imageviewer/view/ScrollableColumn.common.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
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
39 changes: 39 additions & 0 deletions
39
examples/imageviewer/shared/src/desktopTest/kotlin/ImageViewerTest.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,39 @@ | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performClick | ||
import example.imageviewer.* | ||
import example.imageviewer.filter.PlatformContext | ||
import example.imageviewer.model.PictureData | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ImageViewerTest { | ||
@get:Rule | ||
val rule = createComposeRule() | ||
|
||
private val dependencies = object : Dependencies() { | ||
override val notification: Notification = object : PopupNotification(localization) { | ||
override fun showPopUpMessage(text: String) { | ||
} | ||
} | ||
override val imageStorage: DesktopImageStorage = DesktopImageStorage(pictures, CoroutineScope(Dispatchers.Main)) | ||
override val sharePicture: SharePicture = object : SharePicture { | ||
override fun share(context: PlatformContext, picture: PictureData) { } | ||
} | ||
} | ||
|
||
@Test | ||
fun testToggleGalleryStyleButton() { | ||
rule.setContent { | ||
ImageViewerCommon(dependencies) | ||
} | ||
|
||
rule.onNodeWithTag("squaresGalleryView").assertExists() | ||
rule.onNodeWithTag("listGalleryView").assertDoesNotExist() | ||
rule.onNodeWithTag("toggleGalleryStyleButton").performClick() | ||
rule.onNodeWithTag("squaresGalleryView").assertDoesNotExist() | ||
rule.onNodeWithTag("listGalleryView").assertExists() | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...es/imageviewer/shared/src/iosMain/kotlin/example/imageviewer/view/ScrollableColumn.ios.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package example.imageviewer.view | ||
|
||
import androidx.compose.foundation.layout.ColumnScope | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
|
||
@Composable | ||
actual fun ScrollableColumn(modifier: Modifier, content: @Composable () -> Unit) = | ||
actual fun ScrollableColumn(modifier: Modifier, content: @Composable ColumnScope.() -> Unit) = | ||
TouchScrollableColumn(modifier, content) |