Skip to content

Commit 4c90c69

Browse files
committed
Adds Preview Screenshot tool and basic tests + fixes build
Change-Id: I10e503afe53adef41eaa93e38ee9a96e171382c1
1 parent 3e2989f commit 4c90c69

File tree

15 files changed

+194
-3
lines changed

15 files changed

+194
-3
lines changed

core/network/src/main/AndroidManifest.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@
1717
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
1818
xmlns:tools="http://schemas.android.com/tools">
1919
<application>
20-
20+
<provider
21+
android:name="androidx.startup.InitializationProvider"
22+
android:authorities="${applicationId}.androidx-startup"
23+
android:exported="false"
24+
tools:node="merge">
25+
<!-- Core Firebase App Initialization -->
26+
<meta-data android:name="com.android.developers.androidify.startup.FirebaseAppInitializer"
27+
android:value="androidx.startup" />
28+
<!-- Other Firebase Initializers -->
29+
<meta-data android:name="com.android.developers.androidify.startup.FirebaseAppCheckInitializer"
30+
android:value="androidx.startup" />
31+
<meta-data android:name="com.android.developers.androidify.startup.FirebaseRemoteConfigInitializer"
32+
android:value="androidx.startup" />
33+
</provider>
2134
</application>
22-
</manifest>
35+
</manifest>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources xmlns:android="http://schemas.android.com/apk/res/android">
3+
<initializer
4+
android:name="com.android.developers.androidify.startup.FirebaseAppCheckInitializer" />
5+
<initializer
6+
android:name="com.android.developers.androidify.startup.FirebaseRemoteConfigInitializer" />
7+
</resources>

feature/camera/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ plugins {
1919
alias(libs.plugins.kotlin.compose)
2020
alias(libs.plugins.kotlin.ksp)
2121
alias(libs.plugins.hilt)
22+
alias(libs.plugins.composeScreenshot)
2223
}
2324

2425
android {
@@ -41,6 +42,8 @@ android {
4142
compose = true
4243
}
4344

45+
experimentalProperties["android.experimental.enableScreenshotTest"] = true
46+
4447
testOptions {
4548
targetSdk = 36
4649
}
@@ -82,4 +85,5 @@ dependencies {
8285
kspAndroidTest(libs.hilt.compiler)
8386

8487
debugImplementation(libs.androidx.ui.test.manifest)
88+
screenshotTestImplementation(libs.androidx.ui.tooling)
8589
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.android.developers.androidify.camera
17+
18+
import androidx.compose.foundation.layout.Box
19+
import androidx.compose.runtime.Composable
20+
import androidx.compose.ui.tooling.preview.Preview
21+
import com.android.developers.androidify.theme.AndroidifyTheme
22+
23+
class CameraScreenScreenshotTest {
24+
25+
@Preview(showBackground = true)
26+
@Composable
27+
fun CameraScreenScreenshot() {
28+
AndroidifyTheme {
29+
StatelessCameraPreviewContent(
30+
viewfinder = { modifier -> Box(modifier) },
31+
detectedPose = true,
32+
canFlipCamera = true,
33+
requestFlipCamera = {},
34+
defaultZoomOptions = listOf(1f),
35+
zoomLevel = { 1f },
36+
onChangeZoomLevel = {},
37+
requestCaptureImage = {}
38+
)
39+
}
40+
}
41+
}

feature/creation/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ plugins {
1919
alias(libs.plugins.kotlin.compose)
2020
alias(libs.plugins.kotlin.ksp)
2121
alias(libs.plugins.hilt)
22+
alias(libs.plugins.composeScreenshot)
2223
}
2324

2425
android {
@@ -42,6 +43,9 @@ android {
4243
buildFeatures {
4344
compose = true
4445
}
46+
47+
experimentalProperties["android.experimental.enableScreenshotTest"] = true
48+
4549
testOptions {
4650
unitTests {
4751
isIncludeAndroidResources = true

feature/creation/src/test/kotlin/com/android/developers/androidify/creation/CreationViewModelTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ import org.junit.Rule
3333
import org.junit.runner.RunWith
3434
import org.robolectric.RobolectricTestRunner
3535
import org.robolectric.RuntimeEnvironment
36+
import org.robolectric.annotation.Config
3637
import kotlin.test.Test
3738
import kotlin.test.assertEquals
3839
import kotlin.test.assertNotNull
3940

4041
@OptIn(ExperimentalCoroutinesApi::class)
4142
@RunWith(RobolectricTestRunner::class)
43+
@Config(sdk = [35])
4244
class CreationViewModelTest {
4345
@get:Rule
4446
val mainDispatcherRule = MainDispatcherRule()

feature/home/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ plugins {
1919
alias(libs.plugins.kotlin.compose)
2020
alias(libs.plugins.kotlin.ksp)
2121
alias(libs.plugins.hilt)
22+
alias(libs.plugins.composeScreenshot)
2223
}
2324

2425
android {
@@ -40,6 +41,8 @@ android {
4041
buildFeatures {
4142
compose = true
4243
}
44+
45+
experimentalProperties["android.experimental.enableScreenshotTest"] = true
4346
}
4447

4548
dependencies {
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.android.developers.androidify.home
17+
18+
import androidx.compose.runtime.Composable
19+
import androidx.compose.ui.tooling.preview.Preview
20+
import com.android.developers.androidify.theme.AndroidifyTheme
21+
import com.android.developers.androidify.theme.SharedElementContextPreview
22+
23+
class HomeScreenScreenshotTest {
24+
25+
@Preview(showBackground = true)
26+
@Composable
27+
fun HomeScreenScreenshot() {
28+
AndroidifyTheme {
29+
SharedElementContextPreview {
30+
HomeScreenContents(
31+
isMediumWindowSize = false,
32+
onClickLetsGo = { },
33+
onAboutClicked = {},
34+
videoLink = "",
35+
dancingBotLink = ""
36+
)
37+
}
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)