diff --git a/docusaurus/docs/Android/04-ui-components/06-ui-previews.mdx b/docusaurus/docs/Android/04-ui-components/06-ui-previews.mdx index 9334d4dac0..257a2711cb 100644 --- a/docusaurus/docs/Android/04-ui-components/06-ui-previews.mdx +++ b/docusaurus/docs/Android/04-ui-components/06-ui-previews.mdx @@ -33,11 +33,10 @@ Now, you can implement your preview composable like the example below: @Preview @Composable private fun CallContentPreview() { - StreamMockUtils.initializeStreamVideo(LocalContext.current) + StreamPreviewDataUtils.initializeStreamVideo(LocalContext.current) VideoTheme { CallContent( - modifier = Modifier.background(color = VideoTheme.colors.appBackground), - call = mockCall, + call = previewCall, ) } } @@ -49,17 +48,17 @@ After adding the above example to your project, you'll see the following preview You should follow the steps below to make your previews work well: -1. Initialize a mock `StreamVideo` with the following method: `StreamMockUtils.initializeStreamVideo`. +1. Initialize a mock `StreamVideo` with the following method: `StreamPreviewDataUtils.initializeStreamVideo`. 2. Wrap your composable with the `VideoTheme`. 3. Use the provided mock instances for Stream Video UI components. This library provides the following mocks: -- **mockCall**: Mock a `Call` that contains few of mock users. -- **mockParticipant**: Mock a `ParticipantState` instance. -- **mockParticipantList**: Mock a list of `ParticipantState` instances. -- **mockUsers**: Mock a list of `User` instances. -- **mockVideoMediaTrack**: Mock a new `MediaTrack` instance. +- **previewCall**: Mock a `Call` that contains few of mock users. +- **previewParticipant**: Mock a `ParticipantState` instance. +- **previewParticipantsList**: Mock a list of `ParticipantState` instances. +- **previewUsers**: Mock a list of `User` instances. +- **previewVideoMediaTrack**: Mock a new `MediaTrack` instance. For example, you can build a preview Composable for `ParticipantVideo` as in the example below: @@ -67,11 +66,11 @@ For example, you can build a preview Composable for `ParticipantVideo` as in the @Preview @Composable private fun ParticipantVideoPreview() { - StreamMockUtils.initializeStreamVideo(LocalContext.current) + StreamPreviewDataUtils.initializeStreamVideo(LocalContext.current) VideoTheme { ParticipantVideoRenderer( - call = mockCall, - participant = mockParticipant, + call = previewCall, + participant = previewParticipant, ) } } diff --git a/docusaurus/docs/Android/04-ui-components/07-ui-testing.mdx b/docusaurus/docs/Android/04-ui-components/07-ui-testing.mdx index 1f141e26f8..6abe8f6c8d 100644 --- a/docusaurus/docs/Android/04-ui-components/07-ui-testing.mdx +++ b/docusaurus/docs/Android/04-ui-components/07-ui-testing.mdx @@ -35,7 +35,7 @@ class ScreenTests { composable: @Composable () -> Unit ) { paparazzi.snapshot(name = name) { - StreamMockUtils.initializeStreamVideo(LocalContext.current) + StreamPreviewDataUtils.initializeStreamVideo(LocalContext.current) CompositionLocalProvider( LocalInspectionMode provides true, LocalAvatarPreviewPlaceholder provides @@ -49,7 +49,7 @@ class ScreenTests { @Test fun `snapshot CallContent component`() { snapshot(name = "CallContent") { - CallContent(call = mockCall) + CallContent(call = previewCall) } } @@ -58,7 +58,7 @@ class ScreenTests { snapshot(name = "CallLobby") { CallLobby( modifier = Modifier.fillMaxWidth(), - call = mockCall + call = previewCall ) } } @@ -70,7 +70,7 @@ Let's break the code down line by line. First, you should initialize Stream Video SDK with the `initializeStreamVideo()` method. You can learn more about our mock library on [UI Previews](07-ui-previews.mdx). ```kotlin -StreamMockUtils.initializeStreamVideo(LocalContext.current) +StreamPreviewDataUtils.initializeStreamVideo(LocalContext.current) ``` Next, you should enable `LocalInspectionMode` with the `CompositionLocalProvider` and allow Stream UI components to be rendered for the test environment. @@ -90,7 +90,7 @@ Finally, snapshot Stream Video components or your own Composable functions that @Test fun `snapshot CallContent component`() { snapshot(name = "CallContent") { - CallContent(call = mockCall) + CallContent(call = previewCall) } } ``` diff --git a/stream-video-android-previewdata/api/stream-video-android-previewdata.api b/stream-video-android-previewdata/api/stream-video-android-previewdata.api index 759b5a3510..daa4869105 100644 --- a/stream-video-android-previewdata/api/stream-video-android-previewdata.api +++ b/stream-video-android-previewdata/api/stream-video-android-previewdata.api @@ -7,7 +7,6 @@ public final class io/getstream/video/android/mock/StreamPreviewDataUtils { } public final class io/getstream/video/android/mock/StreamPreviewDataUtilsKt { - public static final fun getMockVideoMediaTrack ()Lio/getstream/video/android/core/model/MediaTrack; public static final fun getPreviewCall ()Lio/getstream/video/android/core/Call; public static final fun getPreviewMember ()Lio/getstream/video/android/core/MemberState; public static final fun getPreviewMemberListState ()Ljava/util/List; @@ -16,5 +15,6 @@ public final class io/getstream/video/android/mock/StreamPreviewDataUtilsKt { public static final fun getPreviewThreeMembers ()Ljava/util/List; public static final fun getPreviewTwoMembers ()Ljava/util/List; public static final fun getPreviewUsers ()Ljava/util/List; + public static final fun getPreviewVideoMediaTrack ()Lio/getstream/video/android/core/model/MediaTrack; } diff --git a/stream-video-android-previewdata/src/main/kotlin/io/getstream/video/android/mock/StreamPreviewDataUtils.kt b/stream-video-android-previewdata/src/main/kotlin/io/getstream/video/android/mock/StreamPreviewDataUtils.kt index ca2e5fad2f..2e0d44471c 100644 --- a/stream-video-android-previewdata/src/main/kotlin/io/getstream/video/android/mock/StreamPreviewDataUtils.kt +++ b/stream-video-android-previewdata/src/main/kotlin/io/getstream/video/android/mock/StreamPreviewDataUtils.kt @@ -56,7 +56,7 @@ public val previewCall: Call = Call( ).apply { val participants = previewUsers.take(2).map { user -> val sessionId = if (user == previewUsers.first()) { - sessionId ?: UUID.randomUUID().toString() + sessionId } else { UUID.randomUUID().toString() } @@ -70,7 +70,7 @@ public val previewCall: Call = Call( } /** Mock a new [MediaTrack]. */ -public val mockVideoMediaTrack: MediaTrack +public val previewVideoMediaTrack: MediaTrack inline get() = io.getstream.video.android.core.model.VideoTrack( UUID.randomUUID().toString(), VideoTrack(123), @@ -146,7 +146,7 @@ public val previewMemberListState: List previewCall.state.clearParticipants() previewUsers.forEach { user -> val sessionId = if (user == previewUsers.first()) { - previewCall.sessionId ?: UUID.randomUUID().toString() + previewCall.sessionId } else { UUID.randomUUID().toString() }