Skip to content

Commit 987bf47

Browse files
Merge pull request #513 from JoseAlcerreca/composepreview
Adds Compose Preview Screenshot sample
2 parents a59d128 + 72bf339 commit 987bf47

36 files changed

+1317
-0
lines changed

.github/ci-gradle.properties

Whitespace-only changes.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Workflow name
2+
name: Compose Preview Screenshot
3+
on:
4+
# When it will be triggered
5+
# And in which branch
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set Up JDK
16+
uses: actions/setup-java@v3
17+
with:
18+
distribution: 'zulu' # See 'Supported distributions' for available options
19+
java-version: '17'
20+
cache: 'gradle'
21+
22+
- name: Build project and run screenshot tests
23+
working-directory: ./ui/PreviewScreenshot
24+
run: ./gradlew validateDebugScreenshotTest

ui/PreviewScreenshot/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties

ui/PreviewScreenshot/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Compose Preview Screenshot Testing tool
2+
3+
Experimental: Compose Preview Screenshot Testing is still in development. Its
4+
features and APIs are subject to change substantially during the alpha phase.
5+
Report any feedback and issues through the [issue tracker](https://d.android.com/studio/report-bugs).
6+
7+
See [Compose Preview Screenshot Testing](https://d.android.com/studio/preview/compose-screenshot-testing).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright (C) 2024 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+
* http://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+
17+
plugins {
18+
alias(libs.plugins.android.application)
19+
alias(libs.plugins.jetbrains.kotlin.android)
20+
alias(libs.plugins.screenshot)
21+
}
22+
23+
android {
24+
namespace = "com.example.compose.previewscreenshot"
25+
compileSdk = 34
26+
27+
defaultConfig {
28+
applicationId = "com.example.compose.previewscreenshot"
29+
minSdk = 24
30+
targetSdk = 34
31+
versionCode = 1
32+
versionName = "1.0"
33+
34+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
35+
vectorDrawables {
36+
useSupportLibrary = true
37+
}
38+
}
39+
40+
buildTypes {
41+
release {
42+
isMinifyEnabled = false
43+
proguardFiles(
44+
getDefaultProguardFile("proguard-android-optimize.txt"),
45+
"proguard-rules.pro"
46+
)
47+
}
48+
}
49+
compileOptions {
50+
sourceCompatibility = JavaVersion.VERSION_1_8
51+
targetCompatibility = JavaVersion.VERSION_1_8
52+
}
53+
kotlinOptions {
54+
jvmTarget = "1.8"
55+
}
56+
buildFeatures {
57+
compose = true
58+
}
59+
composeOptions {
60+
kotlinCompilerExtensionVersion = "1.5.13"
61+
}
62+
63+
experimentalProperties["android.experimental.enableScreenshotTest"] = true
64+
65+
packaging {
66+
resources {
67+
excludes += "/META-INF/{AL2.0,LGPL2.1}"
68+
}
69+
}
70+
}
71+
72+
dependencies {
73+
74+
implementation(libs.androidx.core.ktx)
75+
implementation(libs.androidx.lifecycle.runtime.ktx)
76+
implementation(libs.androidx.activity.compose)
77+
implementation(platform(libs.androidx.compose.bom))
78+
implementation(libs.androidx.ui)
79+
implementation(libs.androidx.ui.graphics)
80+
implementation(libs.androidx.ui.tooling.preview)
81+
implementation(libs.androidx.material3)
82+
testImplementation(libs.junit)
83+
androidTestImplementation(libs.androidx.junit)
84+
androidTestImplementation(libs.androidx.espresso.core)
85+
androidTestImplementation(platform(libs.androidx.compose.bom))
86+
androidTestImplementation(libs.androidx.ui.test.junit4)
87+
debugImplementation(libs.androidx.ui.tooling)
88+
debugImplementation(libs.androidx.ui.test.manifest)
89+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Loading
Loading
Loading

0 commit comments

Comments
 (0)