Skip to content

Commit 5c8205c

Browse files
authored
Merge pull request #222 from ndtp/215-version_catalog
215: Upgrade libraries to version catalog
2 parents 78f038b + e003d3c commit 5c8205c

File tree

93 files changed

+247
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+247
-174
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## 3.0.0
44

5+
- https://github.com/ndtp/android-testify/pull/224 - Upgrade to Kotlin 1.9.24 and Compose to 2024.05.00
6+
- Fix several warnings
7+
- Upgrade dependencies on sample apps
8+
- Warning: The January '24 update to Compose introduces changes to the default font padding which impacts any Compose-base tests that use text. https://android-developers.googleblog.com/2024/01/whats-new-in-jetpack-compose-january-24-release.html
59
- https://github.com/ndtp/android-testify/pull/219 - Upgrade to Gradle 8.6 and AGP 8.4.1
610
- Define namespace in build.gradle for library projects
711
- jvmTarget, sourceCompatibility and targetCompatibility set to Java 17

Ext/Accessibility/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ android {
7272
dependencies {
7373
implementation project(":Library")
7474

75-
implementation "androidx.core:core-ktx:${versions.androidx.core}"
76-
implementation "androidx.test.espresso:espresso-accessibility:${versions.androidx.test.a11y}"
77-
implementation "androidx.test:monitor:${versions.androidx.test.monitor}"
78-
implementation "androidx.test:rules:${versions.androidx.test.rules}"
79-
implementation "com.google.code.gson:gson:${versions.gson}"
80-
implementation "com.google.guava:guava:${versions.guava}"
75+
implementation libs.androidx.espresso.accessibility
76+
implementation libs.androidx.monitor
77+
implementation libs.androidx.rules
78+
implementation libs.core.ktx
79+
implementation libs.gson
80+
implementation libs.guava
8181
}
8282

8383
publishing {

Ext/Accessibility/src/main/java/dev/testify/accessibility/AssertAccessibility.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import dev.testify.accessibility.internal.AccessibilityScreenshotLifecycleObserv
4242
* collects various accessibility-related checks on [View] objects as well as AccessibilityNodeInfo objects (which the
4343
* Android framework derives from Views and sends to AccessibilityServices).
4444
*
45-
* @see https://developer.android.com/training/testing/espresso/accessibility-checking
45+
* @see "https://developer.android.com/training/testing/espresso/accessibility-checking"
4646
*
4747
* All elements within the hierarchy defined by [android.R.id.content] will be available to the check.
4848
*

Ext/Accessibility/src/main/java/dev/testify/accessibility/internal/CheckResults.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import java.io.Reader
2929

3030
internal class CheckResults(other: List<CheckResult>) : ArrayList<CheckResult>(other) {
3131

32-
val hasErrors: Boolean
32+
private val hasErrors: Boolean
3333
get() {
3434
return this.any { it.type == "ERROR" }
3535
}

Ext/Compose/build.gradle

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,24 @@ android {
7474
targetCompatibility JavaVersion.VERSION_17
7575
}
7676
composeOptions {
77-
kotlinCompilerExtensionVersion "${versions.compose.compilerExt}"
77+
kotlinCompilerExtensionVersion "1.5.14"
7878
}
7979

8080
dependencies {
8181
implementation project(":Library")
8282

83-
implementation "androidx.activity:activity-compose:${versions.androidx.activityCompose}"
84-
implementation "androidx.appcompat:appcompat:${versions.androidx.appCompat}"
85-
implementation "androidx.compose.material:material:${versions.compose.material}"
86-
implementation "androidx.compose.ui:ui-test-junit4:${versions.compose.ui}"
87-
implementation "androidx.compose.ui:ui-tooling-preview:${versions.compose.ui}"
88-
implementation "androidx.compose.ui:ui:${versions.compose.ui}"
89-
implementation "androidx.lifecycle:lifecycle-runtime-ktx:${versions.androidx.lifecycleKtx}"
90-
implementation "androidx.test.espresso:espresso-core:${versions.androidx.test.espresso}"
91-
implementation "androidx.test:rules:${versions.androidx.test.rules}"
92-
implementation "androidx.test:runner:${versions.androidx.test.runner}"
93-
implementation "androidx.test:core-ktx:${versions.androidx.test.coreKtx}"
83+
implementation(platform(libs.androidx.compose.bom))
84+
implementation libs.androidx.activity.compose
85+
implementation libs.androidx.appcompat
86+
implementation libs.androidx.core.ktx
87+
implementation libs.androidx.espresso.core
88+
implementation libs.androidx.lifecycle.runtime.ktx
89+
implementation libs.androidx.material
90+
implementation libs.androidx.rules
91+
implementation libs.androidx.runner
92+
implementation libs.androidx.ui
93+
implementation libs.androidx.ui.test.junit4
94+
implementation libs.androidx.ui.tooling.preview
9495
}
9596

9697
publishing {

Ext/Compose/src/main/java/dev/testify/compose/scenario/LaunchComposableTestActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ package dev.testify.compose.scenario
2525

2626
import android.content.Intent
2727
import android.os.Bundle
28+
import androidx.compose.runtime.Composable
2829
import androidx.test.core.app.ActivityScenario
2930
import androidx.test.core.app.launchActivity
3031
import dev.testify.ComposableTestActivity

Ext/Fullscreen/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ android {
7272
dependencies {
7373
implementation project(":Library")
7474

75-
implementation "androidx.core:core-ktx:${versions.androidx.core}"
76-
implementation "androidx.test.uiautomator:uiautomator:${versions.androidx.test.uiautomator}"
77-
implementation "androidx.test:monitor:${versions.androidx.test.monitor}"
78-
implementation "androidx.test:rules:${versions.androidx.test.rules}"
75+
implementation libs.androidx.monitor
76+
implementation libs.androidx.rules
77+
implementation libs.androidx.uiautomator
78+
implementation libs.core.ktx
7979
}
8080

8181
publishing {

Ext/Fullscreen/src/main/java/dev/testify/capture/fullscreen/FullscreenCaptureMethod.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import android.view.View
3030
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
3131
import androidx.test.uiautomator.UiDevice
3232
import dev.testify.ScreenshotRule
33+
import dev.testify.capture.fullscreen.provider.excludeNavigationBar
34+
import dev.testify.capture.fullscreen.provider.excludeStatusBar
3335
import dev.testify.core.DEFAULT_NAME_FORMAT
3436
import dev.testify.core.DeviceStringFormatter
3537
import dev.testify.core.TestifyConfigurable
@@ -47,8 +49,8 @@ import dev.testify.testDescription
4749
* The bitmap will be generated from a PNG at 1:1 scale and 100% quality. The bitmap's size will match the full
4850
* device resolution and include all system UI such as the status bar and navigation bar.
4951
*
50-
* As the system UI content is highly variable, you can use [ScreenshotRule.excludeStatusBar] and/or
51-
* [ScreenshotRule.excludeNavigationBar] to ignore the status bar and navigation bar, respectively.
52+
* As the system UI content is highly variable, you can use [excludeStatusBar] and/or
53+
* [excludeNavigationBar] to ignore the status bar and navigation bar, respectively.
5254
*
5355
* Though the PNG is intended to be lossless, some compression artifacts or GPU-related variance can occur. As such,
5456
* it is recommended to use a small tolerance when capturing fullscreen images.
@@ -80,7 +82,7 @@ fun fullscreenCapture(activity: Activity, targetView: View?): Bitmap {
8082
if (!device.takeScreenshot(file, 1f, 100)) throw FailedToCaptureFullscreenBitmapException()
8183

8284
/**
83-
* The screenshot is written as a PNG to [file] on the emulator. We can use [loadBitmapFromFile]
85+
* The screenshot is written as a PNG to the [Destination] file on the emulator. We can use [loadBitmapFromFile]
8486
* to load it from a file into memory as a [Bitmap].
8587
*/
8688

Ext/Fullscreen/src/main/java/dev/testify/capture/fullscreen/provider/NavigationBarExclusionRectProvider.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ val navigationBarExclusionRectProvider: ExclusionRectProvider = { rootView, excl
6060
* Extension method for [TestifyConfiguration] that will add the rectangle covering the system navigation bar to the
6161
* exclusion area.
6262
*/
63+
@Suppress("unused")
6364
fun TestifyConfiguration.excludeNavigationBar() {
6465
defineExclusionRects(navigationBarExclusionRectProvider)
6566
}

Ext/Fullscreen/src/main/java/dev/testify/capture/fullscreen/provider/StatusBarExclusionRectProvider.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ val statusBarExclusionRectProvider: ExclusionRectProvider = { rootView, exclusio
6161
* Extension method for [TestifyConfiguration] that will add the rectangle covering the system status bar to the
6262
* exclusion area.
6363
*/
64+
@Suppress("unused")
6465
fun TestifyConfiguration.excludeStatusBar() {
6566
defineExclusionRects(statusBarExclusionRectProvider)
6667
}

Library/build.gradle

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,28 @@ android {
6565
}
6666

6767
dependencies {
68-
implementation "androidx.lifecycle:lifecycle-runtime-ktx:${versions.androidx.lifecycleKtx}"
69-
implementation "androidx.test.espresso:espresso-core:${versions.androidx.test.espresso}"
70-
implementation "androidx.test:rules:${versions.androidx.test.rules}"
71-
implementation "androidx.test:runner:${versions.androidx.test.runner}"
72-
implementation "com.github.ajalt:colormath:${versions.colormath}"
73-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.kotlinx}") {
74-
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
75-
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk7'
76-
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib'
77-
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-common'
78-
}
79-
implementation "androidx.test:core-ktx:${versions.androidx.test.coreKtx}"
80-
81-
testImplementation "io.mockk:mockk:${versions.mockk}"
82-
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:${versions.kotlinx}"
83-
testImplementation "org.slf4j:slf4j-jdk14:${versions.slf4j}"
84-
testImplementation "com.google.truth:truth:${versions.truth}"
85-
86-
androidTestImplementation "androidx.test.ext:junit:${versions.androidx.test.junit}"
87-
androidTestImplementation "androidx.test:runner:${versions.androidx.test.runner}"
88-
androidTestImplementation "androidx.test:rules:${versions.androidx.test.rules}"
89-
androidTestImplementation "androidx.test.espresso:espresso-core:${versions.androidx.test.espresso}"
90-
androidTestImplementation "androidx.test.espresso:espresso-contrib:${versions.androidx.test.espresso}"
91-
androidTestImplementation "com.google.android.material:material:${versions.material}"
92-
androidTestImplementation "androidx.appcompat:appcompat:${versions.androidx.appCompat}"
93-
androidTestImplementation "androidx.multidex:multidex:2.0.1"
94-
androidTestImplementation "io.mockk:mockk-android:${versions.mockk}"
68+
implementation libs.androidx.core.ktx
69+
implementation libs.androidx.espresso.core
70+
implementation libs.androidx.lifecycle.runtime.ktx
71+
implementation libs.androidx.rules
72+
implementation libs.androidx.runner
73+
implementation libs.colormath
74+
implementation libs.kotlinx.coroutines.android
75+
76+
testImplementation libs.kotlinx.coroutines.test
77+
testImplementation libs.mockk
78+
testImplementation libs.slf4j.jdk14
79+
testImplementation libs.truth
80+
81+
androidTestImplementation libs.androidx.appcompat
82+
androidTestImplementation libs.androidx.espresso.contrib
83+
androidTestImplementation libs.androidx.espresso.core
84+
androidTestImplementation libs.androidx.junit
85+
androidTestImplementation libs.androidx.multidex
86+
androidTestImplementation libs.androidx.rules
87+
androidTestImplementation libs.androidx.runner
88+
androidTestImplementation libs.material
89+
androidTestImplementation libs.mockk.android
9590
}
9691
lint {
9792
abortOnError true

Library/src/androidTest/java/dev/testify/ScreenshotLifecycleTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ScreenshotLifecycleTest {
5959

6060
try {
6161
rule.assertSame()
62-
} catch (e: ScreenshotBaselineNotDefinedException) {
62+
} catch (_: ScreenshotBaselineNotDefinedException) {
6363
}
6464

6565
assertEquals(6, observer.log.size)

Library/src/androidTest/java/dev/testify/scenario/ScreenshotScenarioLifecycleTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class ScreenshotScenarioLifecycleTest {
6666

6767
try {
6868
rule.assertSame()
69-
} catch (e: ScreenshotBaselineNotDefinedException) {
69+
} catch (_: ScreenshotBaselineNotDefinedException) {
7070
}
7171

7272
assertEquals(6, observer.log.size)

Library/src/main/java/dev/testify/ScreenshotRule.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ package dev.testify
2828

2929
import android.annotation.SuppressLint
3030
import android.app.Activity
31+
import android.app.Instrumentation
3132
import android.content.Intent
3233
import android.os.Bundle
3334
import android.view.View.NO_ID
@@ -37,6 +38,7 @@ import androidx.annotation.LayoutRes
3738
import androidx.annotation.VisibleForTesting
3839
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
3940
import androidx.test.rule.ActivityTestRule
41+
import dev.testify.annotation.ScreenshotInstrumentation
4042
import dev.testify.annotation.TestifyLayout
4143
import dev.testify.annotation.findAnnotation
4244
import dev.testify.annotation.getScreenshotAnnotationName
@@ -247,7 +249,7 @@ open class ScreenshotRule<T : Activity> @JvmOverloads constructor(
247249
/**
248250
* Set the Espresso actions to run on the Activity under test before taking a screenshot.
249251
*
250-
* @see https://developer.android.com/training/testing/espresso
252+
* @see "https://developer.android.com/training/testing/espresso"
251253
*
252254
* @ScreenshotInstrumentation
253255
* @Test
@@ -519,7 +521,7 @@ open class ScreenshotRule<T : Activity> @JvmOverloads constructor(
519521
* This override of ActivityTestRule.getActivityIntent() allows Testify to set up a custom Intent as if supplied to
520522
* android.content.Context.startActivity.
521523
*/
522-
public final override fun getActivityIntent(): Intent? {
524+
public final override fun getActivityIntent(): Intent {
523525
var intent: Intent? = super.getActivityIntent()
524526
if (intent == null) {
525527
intent = getIntent()
@@ -635,7 +637,7 @@ open class ScreenshotRule<T : Activity> @JvmOverloads constructor(
635637
/**
636638
* Represents one or more actions to be taken at runtime in the course of running a JUnit test suite.
637639
*/
638-
private inner class ScreenshotStatement constructor(private val base: Statement) : Statement() {
640+
private inner class ScreenshotStatement(private val base: Statement) : Statement() {
639641

640642
override fun evaluate() {
641643
try {

Library/src/main/java/dev/testify/ScreenshotUtility.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import dev.testify.output.getDestination
4242
import dev.testify.output.getFileRelativeToRoot
4343
import java.util.concurrent.CountDownLatch
4444
import java.util.concurrent.TimeUnit
45+
import java.io.File
4546

4647
/**
4748
* The default, preferred [BitmapFactory.Options] to use when decoding a [Bitmap].
@@ -62,7 +63,7 @@ val preferredBitmapOptions: BitmapFactory.Options
6263
* @param bitmap The [Bitmap] to write to disk. If null, this function will return false.
6364
* @param destination The [Destination] to write the bitmap to.
6465
*
65-
* @throws DestinationNotFoundException if the destination cannot be found.
66+
* @throws Exception if the destination cannot be found.
6667
*
6768
* @return true if the bitmap was successfully written to the destination, false otherwise.
6869
*/

Library/src/main/java/dev/testify/core/ConfigurationBuilder.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ package dev.testify.core
2828
import android.app.Activity
2929
import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
3030
import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
31+
import android.graphics.Bitmap
32+
import android.graphics.Rect
3133
import android.view.View
3234
import androidx.annotation.IdRes
3335
import androidx.annotation.VisibleForTesting

Library/src/main/java/dev/testify/core/DeviceIdentifier.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ import java.util.Locale
3535
/**
3636
* A typealias for the test class and test name.
3737
*
38-
* @param first - The test class name
39-
* @param second - The test method name
38+
* @param `first` - The test class name
39+
* @param `second` - The test method name
4040
*/
4141
typealias TestName = Pair<String, String>
4242

@@ -70,7 +70,7 @@ fun getDeviceDescription(context: Context): String {
7070
/**
7171
* Returns a string representing the device description.
7272
*
73-
* @param testName - The name of the currently running test
73+
* @param formatter - Utility class for formatting device description strings
7474
* @param format - The format of the device description string
7575
* The following values will be substituted:
7676
* a: API level (ex. 21)

Library/src/main/java/dev/testify/core/TestifyConfiguration.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ package dev.testify.core
2727
import android.app.Activity
2828
import android.content.pm.ActivityInfo
2929
import android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
30+
import android.graphics.Bitmap
3031
import android.graphics.Rect
3132
import android.view.View
3233
import android.view.ViewGroup
@@ -279,7 +280,7 @@ data class TestifyConfiguration(
279280
/**
280281
* Returns true if the test has defined any exclusion rects.
281282
*/
282-
internal fun hasExclusionRect() = exclusionRects.isNotEmpty()
283+
private fun hasExclusionRect() = exclusionRects.isNotEmpty()
283284

284285
/**
285286
* Get the CaptureMethod that should be used to capture the bitmap.

Library/src/main/java/dev/testify/core/exception/ActivityMustImplementResourceOverrideException.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
package dev.testify.core.exception
2626

27+
import dev.testify.resources.TestifyResourcesOverride
28+
2729
/**
2830
* Exception thrown when an activity is missing the [TestifyResourcesOverride] interface.
2931
*

Library/src/main/java/dev/testify/core/exception/FinalizeDestinationException.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
package dev.testify.core.exception
2525

26+
import dev.testify.output.Destination
27+
2628
/**
2729
* Exception thrown when the [Destination] could not be finalized.
2830
*/

Library/src/main/java/dev/testify/core/exception/MissingScreenshotInstrumentationAnnotationException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
package dev.testify.core.exception
2626

2727
/**
28-
* Exception thrown when [annotationName] annotation is missing.
28+
* Exception thrown when `annotationName` annotation is missing.
2929
*
3030
* Use of the Gradle plugin requires the specified annotation.
3131
*/

Library/src/main/java/dev/testify/core/exception/ScenarioRequiredException.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
*/
2424
package dev.testify.core.exception
2525

26+
import dev.testify.scenario.ScreenshotScenarioRule
27+
2628
/**
2729
* Exception thrown when no ActivityScenario instance is provided to the ScreenshotScenarioRule.
2830
* The ActivityScenario instance is required to take screenshots.

Library/src/main/java/dev/testify/core/processor/ParallelPixelProcessor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ typealias AnalyzePixelFunction = (baselinePixel: Int, currentPixel: Int, positio
4040
* A class that allows for parallel processing of pixels in a bitmap.
4141
*
4242
* Uses coroutines to process pixels in two [Bitmap] objects in parallel.
43-
* Used by [BitmapComparator] to compare two bitmaps in parallel.
44-
* Used by [BitmapTransformer] to transform two bitmaps in parallel.
43+
* [analyze] is used to compare two bitmaps in parallel.
44+
* [transform] is used to transform two bitmaps in parallel.
4545
*/
4646
class ParallelPixelProcessor private constructor(
4747
private val configuration: ParallelProcessorConfiguration

Library/src/main/java/dev/testify/core/processor/compare/colorspace/DeltaE.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import kotlin.math.sqrt
5858
* @param b2 second colour's b component
5959
* @return the CIE 2000 colour difference
6060
*/
61+
@Suppress("LocalVariableName")
6162
fun calculateDeltaE(L1: Double, a1: Double, b1: Double, L2: Double, a2: Double, b2: Double): Double {
6263
val lMean = (L1 + L2) / 2.0
6364
val c1 = sqrt(a1 * a1 + b1 * b1)

0 commit comments

Comments
 (0)