Skip to content

Commit

Permalink
Add Android Compose Screenshot Testing, remove Paparazzi
Browse files Browse the repository at this point in the history
  • Loading branch information
illarionov committed May 16, 2024
1 parent 8b09077 commit ac123a9
Show file tree
Hide file tree
Showing 73 changed files with 468 additions and 543 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Assemble debug build, run tests
run: >
./gradlew -Pkotlin.daemon.jvmargs="${{ env.KOTLIN_DAEMON_JVMARGS }}"
assembleDebug test verifyPaparazzi --scan --stacktrace
assembleDebug test validateScreenshotTest --scan --stacktrace
- name: Cleanup secrets
if: ${{ always() }}
Expand Down
5 changes: 5 additions & 0 deletions config/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,8 @@ formatting:
active: true
autoCorrect: true
useTrailingCommaOnDeclarationSite: true

Compose:
# Disabled to use public @Preview functions in screenshot tests
PreviewPublic:
active: false
2 changes: 1 addition & 1 deletion feature/calendar/public/calendar-public.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
plugins {
id("ru.pixnews.gradle.android.library")
id("ru.pixnews.gradle.android.test-paparazzi")
id("ru.pixnews.gradle.android.test.compose.screenshot")
id("ru.pixnews.gradle.di.anvil-factories")
id("kotlin-parcelize")
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2024, the Pixnews project authors and contributors. Please see the AUTHORS file for details.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/

@file:Suppress("PREVIEW_ANNOTATION")

package ru.pixnews.feature.calendar.ui

import androidx.compose.runtime.Composable
import ru.pixnews.foundation.ui.theme.PixnewsTheme
import ru.pixnews.library.ui.tooling.ScreenshotTestPreview

class InitialLoadingPlaceholderScreenshotTest {
@Composable
@ScreenshotTestPreview
fun InitialLoadingPlaceholderTest() {
PixnewsTheme(useDynamicColor = false) {
InitialLoadingPlaceholder()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2024, the Pixnews project authors and contributors. Please see the AUTHORS file for details.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/

@file:Suppress("PREVIEW_ANNOTATION")

package ru.pixnews.feature.calendar.ui.failure

import androidx.compose.runtime.Composable
import ru.pixnews.foundation.ui.theme.PixnewsTheme
import ru.pixnews.library.ui.tooling.ScreenshotTestPreview

class NoInternetScreenshotTest {
@Composable
@ScreenshotTestPreview
fun NoInternetTest() {
PixnewsTheme(useDynamicColor = false) {
NoInternet()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2024, the Pixnews project authors and contributors. Please see the AUTHORS file for details.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/

@file:Suppress("PREVIEW_ANNOTATION")

package ru.pixnews.feature.calendar.ui.failure

import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import ru.pixnews.foundation.ui.theme.PixnewsTheme
import ru.pixnews.library.ui.tooling.ScreenshotTestPreview

class OtherNetworkErrorScreenshotTest {
@Composable
@ScreenshotTestPreview
fun OtherNetworkErrorTest(
@PreviewParameter(RefreshActiveProvider::class) refreshActive: Boolean,
) {
PixnewsTheme(useDynamicColor = false) {
OtherNetworkError(
onRefreshClicked = { },
refreshActive = { refreshActive },
)
}
}

class RefreshActiveProvider : PreviewParameterProvider<Boolean> {
override val values: Sequence<Boolean> = sequenceOf(false, true)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, the Pixnews project authors and contributors. Please see the AUTHORS file for details.
* Copyright (c) 2024, the Pixnews project authors and contributors. Please see the AUTHORS file for details.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2024, the Pixnews project authors and contributors. Please see the AUTHORS file for details.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/

@file:Suppress("PREVIEW_ANNOTATION")

package ru.pixnews.feature.calendar.ui.header

import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import kotlinx.collections.immutable.toImmutableList
import ru.pixnews.feature.calendar.model.GameListViewMode.GRID
import ru.pixnews.foundation.ui.theme.PixnewsTheme
import ru.pixnews.library.ui.tooling.ScreenshotTestPreview

class CalendarScreenHeaderScreenshotTest {
@Composable
@ScreenshotTestPreview
fun CalendarScreenHeaderTest() {
PixnewsTheme(useDynamicColor = false) {
CalendarScreenHeader(
onSearch = {},
onDaySelectionClick = {},
onYearMonthSelectionClick = {},
onOpenFilterClick = {},
onViewModeClick = {},
onFilterChipClick = {},
activeDate = remember { mutableStateOf(CalendarHeaderTestFixtures.activeDate) },
games = CalendarHeaderTestFixtures.gamesSummaryOnActiveDate,
chips = CalendarHeaderTestFixtures.chips.toImmutableList(),
viewMode = remember { mutableStateOf(GRID) },
)
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion feature/root/public/root-public.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
plugins {
id("ru.pixnews.gradle.android.library")
id("ru.pixnews.gradle.android.test-paparazzi")
id("ru.pixnews.gradle.android.test.compose.screenshot")
id("ru.pixnews.gradle.di.anvil-factories")
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ac123a9

Please sign in to comment.