Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,16 @@ jobs:
- name: Install Android SDK
uses: hannesa2/action-android/install-sdk@0.17.0
- name: Run tests
run: ./gradlew test
run: ./gradlew :chartLib:test
- name: Verify Roborazzi screenshots
run: ./gradlew :app:verifyRoborazziDebug
- name: Archive Roborazzi results
uses: actions/upload-artifact@v7
if: ${{ always() }}
with:
name: Chart-Roborazzi-report
path: app/build/reports/roborazzi
if-no-files-found: ignore
- name: Test jitpack publish command
run: ./gradlew :chartLib:publishToMavenLocal :chartLibCompose:publishToMavenLocal -PRELEASE_SIGNING_ENABLED=false
- name: Code checks
Expand Down
16 changes: 16 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.plugin.compose") version "2.4.10"
id("io.github.takahirom.roborazzi") version "1.70.0"
}

android {
Expand Down Expand Up @@ -45,6 +46,9 @@ android {
// https://stackoverflow.com/a/67635863/1079990
testOptions {
animationsDisabled = true
unitTests {
isIncludeAndroidResources = true
}
}
lint {
lintConfig = file("lint.xml")
Expand All @@ -58,6 +62,10 @@ android {
}
}

roborazzi {
outputDir.set(project.file("src/test/snapshots"))
}

dependencies {
lintChecks(project(":lint"))

Expand Down Expand Up @@ -91,4 +99,12 @@ dependencies {
androidTestUtil("androidx.test.services:test-services:1.6.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.7.0")
androidTestImplementation("androidx.test.espresso:espresso-intents:3.7.0")

val roborazziVersion = "1.70.0"
testImplementation("io.github.takahirom.roborazzi:roborazzi:$roborazziVersion")
testImplementation("io.github.takahirom.roborazzi:roborazzi-compose:$roborazziVersion")
testImplementation("org.robolectric:robolectric:4.16.1")
testImplementation("androidx.test.ext:junit:1.3.0")
testImplementation("androidx.test.espresso:espresso-core:3.7.0")
testImplementation("androidx.compose.ui:ui-test-junit4")
}
87 changes: 87 additions & 0 deletions app/src/test/kotlin/info/appdev/chartexample/RoborazziTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package info.appdev.chartexample

import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import com.github.takahirom.roborazzi.RoborazziOptions
import com.github.takahirom.roborazzi.captureRoboImage
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode

@RunWith(RobolectricTestRunner::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
@Config(sdk = [28], qualifiers = "w411dp-h891dp-420dpi")
class RoborazziTest {

// Cubic bezier path rendering produces minor sub-pixel differences between
// macOS and Linux JVMs, so allow a small tolerance for all comparisons.
private val options = RoborazziOptions(
compareOptions = RoborazziOptions.CompareOptions(changeThreshold = 0.01f)
)

@Test
fun barChart() {
ActivityScenario.launch(BarChartActivity::class.java).use {
onView(isRoot()).captureRoboImage(roborazziOptions = options)
}
}

@Test
fun lineChart() {
ActivityScenario.launch(LineChartActivity::class.java).use {
onView(isRoot()).captureRoboImage(roborazziOptions = options)
}
}

@Test
fun pieChart() {
ActivityScenario.launch(PieChartActivity::class.java).use {
onView(isRoot()).captureRoboImage(roborazziOptions = options)
}
}

@Test
fun horizontalBarChart() {
ActivityScenario.launch(HorizontalBarChartActivity::class.java).use {
onView(isRoot()).captureRoboImage(roborazziOptions = options)
}
}

@Test
fun bubbleChart() {
ActivityScenario.launch(BubbleChartActivity::class.java).use {
onView(isRoot()).captureRoboImage(roborazziOptions = options)
}
}

@Test
fun scatterChart() {
ActivityScenario.launch(ScatterChartActivity::class.java).use {
onView(isRoot()).captureRoboImage(roborazziOptions = options)
}
}

@Test
fun candleStickChart() {
ActivityScenario.launch(CandleStickChartActivity::class.java).use {
onView(isRoot()).captureRoboImage(roborazziOptions = options)
}
}

@Test
fun combinedChart() {
ActivityScenario.launch(CombinedChartActivity::class.java).use {
onView(isRoot()).captureRoboImage(roborazziOptions = options)
}
}

@Test
fun radarChart() {
ActivityScenario.launch(RadarChartActivity::class.java).use {
onView(isRoot()).captureRoboImage(roborazziOptions = options)
}
}
}
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.
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