Browse Source
* Add a unit test to the imageviewer example. * Fix android build of imageviewerpull/3529/head
Alexander Maryanovsky
1 year ago
committed by
GitHub
9 changed files with 70 additions and 23 deletions
@ -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) |
||||
|
@ -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() |
||||
} |
||||
} |
@ -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) |
||||
|
Loading…
Reference in new issue