Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[*.{kt,kts}]
disabled_rules=import-ordering
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
indent_size=4
insert_final_newline=true
max_line_length=120
trim_trailing_whitespace=true
end_of_line=lf
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## 4.0.0

- https://github.com/ndtp/android-testify/pull/266 Updated to Kotlin 2.2
- https://github.com/ndtp/android-testify/pull/266 Major version updates to all core dependencies. This will require the following changes to your projects:
- Compose 2025.08.01 updates require:
- kotlinCompilerExtensionVersion --> 1.9.0
- androidx.compose.material:material --> 1.9.0
- androidx.compose.ui:ui-tooling-preview -> 1.9.0
- androidx.compose.ui:ui --> 1.9.0
- Java 21 requires you to update your app to use Java 21
- Compile 35+ requires you to target 35+
- Minimum SDK raised to 26

---

# Testify Change Log

## 3.2.3
Expand Down
4 changes: 2 additions & 2 deletions Ext/Accessibility/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For more information about _Accessibility Checking_, please see https://develope

```groovy
plugins {
id("dev.testify") version "3.2.3" apply false
id("dev.testify") version "4.0.0" apply false
}
```

Expand All @@ -29,7 +29,7 @@ Ensure that `mavenCentral()` is available to both `pluginManagement` and `depend
**Application build.gradle**
```groovy
dependencies {
androidTestImplementation "dev.testify:testify-accessibility:3.2.3"
androidTestImplementation "dev.testify:testify-accessibility:4.0.0"
}
```

Expand Down
4 changes: 2 additions & 2 deletions Ext/Accessibility/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'maven-publish'
id 'signing'
}

ext {
Expand Down Expand Up @@ -92,5 +94,3 @@ android {
afterEvaluate {
apply from: "../../publish.build.gradle"
}

apply from: '../../ktlint.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ internal class CheckResults(other: List<CheckResult>) : ArrayList<CheckResult>(o
return if (this.any { it.type == type }) " * $type:\n${this.prettyPrint(type)}" else ""
}

private fun List<CheckResult>.prettyPrint(filter: String): String {
return if (this.isEmpty())
" * - [NONE]"
else
filter { it.type == filter }.joinToString(separator = "\n * -", prefix = " * -") {
"${it.check}: [${it.elementClass}/${it.resourceName}] - ${it.message}"
}
}
private fun List<CheckResult>.prettyPrint(filter: String) =
prettyPrintEmpty().takeIf { isEmpty() } ?: prettyPrintNotEmpty(filter)

private fun prettyPrintEmpty() = " * - [NONE]"

private fun List<CheckResult>.prettyPrintNotEmpty(filter: String) = filter { it.type == filter }
.joinToString(
separator = "\n * -",
prefix = " * -"
) {
"${it.check}: [${it.elementClass}/${it.resourceName}] - ${it.message}"
}

companion object {
fun fromJson(json: Reader): CheckResults {
Expand Down
4 changes: 2 additions & 2 deletions Ext/Compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Easily create screenshot tests for `@Composable` functions.

```groovy
plugins {
id("dev.testify") version "3.2.3" apply false
id("dev.testify") version "4.0.0" apply false
}
```

Expand All @@ -24,7 +24,7 @@ Ensure that `mavenCentral()` is available to both `pluginManagement` and `depend
**Application build.gradle**
```groovy
dependencies {
androidTestImplementation "dev.testify:testify-compose:3.2.3"
androidTestImplementation "dev.testify:testify-compose:4.0.0"
androidTestImplementation "androidx.test:rules:1.5.0"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.4.3"
}
Expand Down
22 changes: 13 additions & 9 deletions Ext/Compose/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'maven-publish'
id 'signing'
alias(libs.plugins.compose.compiler)
}

ext {
Expand Down Expand Up @@ -66,15 +71,16 @@ android {
compose true
}

kotlinOptions {
jvmTarget = '17'
kotlin {
compilerOptions {
allWarningsAsErrors.set(true)
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.addAll("-Xcontext-parameters")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
composeOptions {
kotlinCompilerExtensionVersion "1.5.14"
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}

dependencies {
Expand Down Expand Up @@ -106,5 +112,3 @@ android {
afterEvaluate {
apply from: "../../publish.build.gradle"
}

apply from: '../../ktlint.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,12 @@ open class ComposableScreenshotRule(
*/
override fun beforeScreenshot(activity: Activity) {
val targetView = activity.findRootView(rootViewId).getChildAt(0)
if (targetView.width == 0 && targetView.height == 0)
if (targetView.width == 0 && targetView.height == 0) {
throw IllegalStateException(
"Target view has 0 size. " +
"Verify if you have provided a ComposeTestRule instance to ComposableScreenshotRule."
)
}

super.beforeScreenshot(activity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2024 ndtp
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2024 ndtp
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
Expand Down Expand Up @@ -206,12 +206,12 @@ open class ComposableScreenshotScenarioRule(
*/
override fun beforeScreenshot(activity: Activity) {
val targetView = activity.findRootView(rootViewId).getChildAt(0)
if (targetView.width == 0 && targetView.height == 0)
if (targetView.width == 0 && targetView.height == 0) {
throw IllegalStateException(
"Target view has 0 size. " +
"Target view has 0 size." +
"Verify if you have provided a ComposeTestRule instance to ComposableScreenshotRule."
)

}
super.beforeScreenshot(activity)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2024 ndtp
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
Expand Down
4 changes: 2 additions & 2 deletions Ext/Fullscreen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You can set a comparison tolerance using [ScreenshotRule.setExactness](../../Lib

```groovy
plugins {
id("dev.testify") version "3.2.3" apply false
id("dev.testify") version "4.0.0" apply false
}
```

Expand All @@ -31,7 +31,7 @@ Ensure that `mavenCentral()` is available to both `pluginManagement` and `depend
**Application build.gradle**
```groovy
dependencies {
androidTestImplementation "dev.testify:testify-fullscreen:3.2.3"
androidTestImplementation "dev.testify:testify-fullscreen:4.0.0"
}
```

Expand Down
4 changes: 2 additions & 2 deletions Ext/Fullscreen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'maven-publish'
id 'signing'
}

ext {
Expand Down Expand Up @@ -90,5 +92,3 @@ android {
afterEvaluate {
apply from: "../../publish.build.gradle"
}

apply from: '../../ktlint.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import dev.testify.testDescription
*/
@Suppress("UNUSED_PARAMETER")
fun fullscreenCapture(activity: Activity, targetView: View?): Bitmap {

val instrumentation = getInstrumentation()
val fileName = getFileName(instrumentation.context)
val destination = getDestination(activity, fileName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ val Context.realDisplaySize: Size
} else {
(getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay
}?.getRealSize(screenSize)
return if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT)
return if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
Size(screenSize.x, screenSize.y)
else
} else {
Size(screenSize.y, screenSize.x)
}
}
26 changes: 14 additions & 12 deletions Library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id 'com.android.library'
id 'kotlin-android'
id 'org.jetbrains.dokka'
id 'jacoco'
id 'maven-publish'
id 'signing'
}

ext {
Expand All @@ -26,23 +30,23 @@ archivesBaseName = pom.artifact
jacoco { toolVersion = "0.8.10" }

android {
kotlinOptions {
jvmTarget = '17'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}

defaultConfig {
compileSdk libs.versions.compileSdk.get().toInteger()
compileSdkVersion libs.versions.compileSdk.get().toInteger()
minSdkVersion libs.versions.minSdk.get().toInteger()
targetSdkVersion libs.versions.targetSdk.get().toInteger()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled = true
kotlinOptions {
allWarningsAsErrors = true
freeCompilerArgs = ["-Xcontext-receivers"]
kotlin {
compilerOptions {
allWarningsAsErrors.set(true)
jvmTarget.set(JvmTarget.JVM_21)
freeCompilerArgs.addAll("-Xcontext-parameters")
}
}
}

Expand Down Expand Up @@ -120,8 +124,6 @@ afterEvaluate {
apply from: "../publish.build.gradle"
}

apply from: '../ktlint.gradle'

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
Expand Down Expand Up @@ -156,4 +158,4 @@ project.afterEvaluate {
executionData(files("${project.buildDir}/jacoco/${testTaskName}.exec"))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2023 ndtp
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class BitmapCompareTest {

@Test
fun fuzzy() {
val similarBitmap = baselineBitmap.copy(baselineBitmap.config, true)!!
val similarBitmap = baselineBitmap.copy(baselineBitmap.config!!, true)!!
similarBitmap.setPixel(0, 0, similarBitmap.getPixel(0, 0) + 1)

assertFalse(FuzzyCompare(TestifyConfiguration(exactness = 1.0f)).compareBitmaps(similarBitmap, baselineBitmap))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class FuzzyCompareBitmapTest {
fun fuzzy() {
val baselineBitmap = loadBitmap("test")

val similarBitmap = baselineBitmap.copy(baselineBitmap.config, true)!!
val similarBitmap = baselineBitmap.copy(baselineBitmap.config!!, true)!!
similarBitmap.setPixel(0, 0, similarBitmap.getPixel(0, 0) + 1)

assertFalse(FuzzyCompare(TestifyConfiguration(exactness = 1.0f)).compareBitmaps(similarBitmap, baselineBitmap))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class RuleLifecycleTest {
}

@Suppress("DEPRECATION")
@get:Rule val thrown: ExpectedException = ExpectedException.none()
@get:Rule
val thrown: ExpectedException = ExpectedException.none()

@ScreenshotInstrumentation
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2024 ndtp
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2024 ndtp
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class ScenarioTestRuleLifecycleTest {
}

@Suppress("DEPRECATION")
@get:Rule val thrown: ExpectedException = ExpectedException.none()
@get:Rule
val thrown: ExpectedException = ExpectedException.none()

@ScreenshotInstrumentation
@Test
Expand Down
2 changes: 1 addition & 1 deletion Library/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<application android:largeHeap="true">
<activity android:name=".TestActivity" />
</application>

Expand Down
Loading