diff --git a/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png b/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png index 292055b97a..9884cc52d7 100644 Binary files a/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png and b/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png differ diff --git a/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png b/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png index 2374bda165..fad93f3cfb 100644 Binary files a/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png and b/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png differ diff --git a/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png b/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png index f5491fd3b3..ddf703c071 100644 Binary files a/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png and b/app/screenshots/default/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png differ diff --git a/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png b/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png index b518a01670..b63035e5e4 100644 Binary files a/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png and b/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png differ diff --git a/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png b/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png index 36a0be8984..2e3438c225 100644 Binary files a/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png and b/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png differ diff --git a/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png b/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png index 7b5c3b2215..0b5bac2b38 100644 Binary files a/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png and b/app/screenshots/dm/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png differ diff --git a/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png b/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png index 7b59e5a149..84c885124e 100644 Binary files a/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png and b/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png differ diff --git a/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png b/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png index 392b854b6b..f21546f6bc 100644 Binary files a/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png and b/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png differ diff --git a/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png b/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png index 16a44b7c49..5289e0a57c 100644 Binary files a/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png and b/app/screenshots/rtl/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png differ diff --git a/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png b/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png index 9875ec4978..89f5dc1540 100644 Binary files a/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png and b/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestCalendarWithSingleDaySelected.png differ diff --git a/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png b/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png index 51504d919f..40cbd31b19 100644 Binary files a/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png and b/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestCalendarWithStartAndEndDateSelected.png differ diff --git a/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png b/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png index cca6801af6..07e628d7dc 100644 Binary files a/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png and b/app/screenshots/themed/calendar2.BpkCalendarTest_screenshotTestColoredCalendarWithStartAndEndDateSelected.png differ diff --git a/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_DefaultWithAction.png b/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_DefaultWithAction.png index 28966cb0a8..c4d0e76ccd 100644 Binary files a/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_DefaultWithAction.png and b/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_DefaultWithAction.png differ diff --git a/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withIcon.png b/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withIcon.png index 62be652aea..cd405d0a67 100644 Binary files a/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withIcon.png and b/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withIcon.png differ diff --git a/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withTitle.png b/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withTitle.png index c88ea5ac53..32649fc875 100644 Binary files a/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withTitle.png and b/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withTitle.png differ diff --git a/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withTitleAndIcon.png b/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withTitleAndIcon.png index 4e221cd65a..1e680a6448 100644 Binary files a/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withTitleAndIcon.png and b/app/screenshots/themed/snackbar.BpkSnackbarTests_screenshotTestSnackbar_withTitleAndIcon.png differ diff --git a/app/src/androidTest/java/net/skyscanner/backpack/BpkSnapshotTest.kt b/app/src/androidTest/java/net/skyscanner/backpack/BpkSnapshotTest.kt index 53c47c6ab2..54006efbfc 100644 --- a/app/src/androidTest/java/net/skyscanner/backpack/BpkSnapshotTest.kt +++ b/app/src/androidTest/java/net/skyscanner/backpack/BpkSnapshotTest.kt @@ -27,11 +27,13 @@ import androidx.activity.compose.setContent import androidx.annotation.ColorRes import androidx.annotation.Dimension import androidx.annotation.Dimension.DP +import androidx.appcompat.app.AppCompatActivity import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable import androidx.compose.runtime.ProvidedValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.unit.IntSize import androidx.compose.ui.unit.dp import androidx.test.core.app.ActivityScenario @@ -39,7 +41,6 @@ import androidx.test.platform.app.InstrumentationRegistry import com.facebook.testing.screenshot.Screenshot import com.facebook.testing.screenshot.ViewHelpers import com.facebook.testing.screenshot.internal.TestNameDetector -import net.skyscanner.backpack.demo.MainActivity import net.skyscanner.backpack.demo.compose.BackpackPreview import org.hamcrest.Matchers import org.junit.Assume @@ -109,7 +110,7 @@ open class BpkSnapshotTest { tags.joinToString(separator = "_", prefix = getScreenshotName() + ".") { it.toString() } } - ActivityScenario.launch(MainActivity::class.java).use { scenario -> + ActivityScenario.launch(AppCompatActivity::class.java).use { scenario -> scenario.onActivity { activity -> with(activity) { setContent { @@ -121,7 +122,7 @@ open class BpkSnapshotTest { ) } - val view = (window.decorView as ViewGroup).getChildAt(0) + val view = window.decorView.findComposeView() ViewHelpers.setupView(view) .setExactWidthDp(size.width) @@ -136,6 +137,22 @@ open class BpkSnapshotTest { } } + private fun View.findComposeView(): ComposeView? { + if (this !is ViewGroup) return null + for (i in 0..childCount) { + val child = getChildAt(i) + if (child is ComposeView) { + return child + } else if (child is ViewGroup) { + val view = child.findComposeView() + if (view != null) { + return view + } + } + } + return null + } + inner class AsyncSnapshot(private val testClass: String, private val testName: String) { fun record(view: View) { Screenshot.snap(wrapMeasuredViewWithBackground(view)) diff --git a/app/src/androidTest/java/net/skyscanner/backpack/calendar/BpkCalendarTest.kt b/app/src/androidTest/java/net/skyscanner/backpack/calendar/BpkCalendarTest.kt index c797194cec..64c3489989 100644 --- a/app/src/androidTest/java/net/skyscanner/backpack/calendar/BpkCalendarTest.kt +++ b/app/src/androidTest/java/net/skyscanner/backpack/calendar/BpkCalendarTest.kt @@ -38,7 +38,6 @@ import net.skyscanner.backpack.calendar.presenter.CurrentDateProvider import net.skyscanner.backpack.calendar.presenter.HighlightedDaysAdapter import net.skyscanner.backpack.calendar.presenter.MonthFooterAdapter import net.skyscanner.backpack.calendar.presenter.SelectionType -import net.skyscanner.backpack.demo.MainActivity import net.skyscanner.backpack.demo.data.multiColoredExampleCalendarColoring import org.hamcrest.CoreMatchers import org.junit.Before @@ -85,8 +84,8 @@ class BpkCalendarTest : BpkSnapshotTest() { private lateinit var activity: AppCompatActivity @get:Rule - var activityRule: ActivityTestRule = - ActivityTestRule(MainActivity::class.java) + var activityRule: ActivityTestRule = + ActivityTestRule(AppCompatActivity::class.java) @Before fun setup() { diff --git a/app/src/androidTest/java/net/skyscanner/backpack/calendar2/BpkCalendarTest.kt b/app/src/androidTest/java/net/skyscanner/backpack/calendar2/BpkCalendarTest.kt index 0467285190..9ae9c30c9c 100644 --- a/app/src/androidTest/java/net/skyscanner/backpack/calendar2/BpkCalendarTest.kt +++ b/app/src/androidTest/java/net/skyscanner/backpack/calendar2/BpkCalendarTest.kt @@ -34,7 +34,6 @@ import kotlinx.coroutines.test.TestCoroutineDispatcher import net.skyscanner.backpack.BpkSnapshotTest import net.skyscanner.backpack.calendar2.data.CalendarDispatchers import net.skyscanner.backpack.calendar2.extension.toIterable -import net.skyscanner.backpack.demo.MainActivity import net.skyscanner.backpack.demo.R import net.skyscanner.backpack.util.InternalBackpackApi import org.junit.Before @@ -56,8 +55,8 @@ class BpkCalendarTest : BpkSnapshotTest() { private lateinit var activity: AppCompatActivity @get:Rule - var activityRule: ActivityTestRule = - ActivityTestRule(MainActivity::class.java) + var activityRule: ActivityTestRule = + ActivityTestRule(AppCompatActivity::class.java) @OptIn(InternalBackpackApi::class, ExperimentalCoroutinesApi::class) @Before diff --git a/app/src/androidTest/java/net/skyscanner/backpack/snackbar/BpkSnackbarTests.kt b/app/src/androidTest/java/net/skyscanner/backpack/snackbar/BpkSnackbarTests.kt index a5a63021ea..b7d850fe66 100644 --- a/app/src/androidTest/java/net/skyscanner/backpack/snackbar/BpkSnackbarTests.kt +++ b/app/src/androidTest/java/net/skyscanner/backpack/snackbar/BpkSnackbarTests.kt @@ -30,7 +30,6 @@ import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.rule.ActivityTestRule import net.skyscanner.backpack.BpkSnapshotTest -import net.skyscanner.backpack.demo.MainActivity import net.skyscanner.backpack.demo.R import net.skyscanner.backpack.util.unsafeLazy import org.hamcrest.Matcher @@ -45,8 +44,8 @@ class BpkSnackbarTests : BpkSnapshotTest() { private lateinit var activity: AppCompatActivity @get:Rule - var activityRule: ActivityTestRule = - ActivityTestRule(MainActivity::class.java) + var activityRule: ActivityTestRule = + ActivityTestRule(AppCompatActivity::class.java) @Before fun setUp() {