Skip to content

Commit e003d3c

Browse files
authored
Merge pull request #223 from ndtp/220-minSdkVersion
220, 221: Raise minimum SDK to 21, target/compile SDK to 34
2 parents af5a245 + 88486e0 commit e003d3c

File tree

86 files changed

+101
-73
lines changed

Some content is hidden

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

86 files changed

+101
-73
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/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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,13 @@ android {
7474
targetCompatibility JavaVersion.VERSION_17
7575
}
7676
composeOptions {
77-
kotlinCompilerExtensionVersion "1.4.7"
77+
kotlinCompilerExtensionVersion "1.5.14"
7878
}
7979

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

83+
implementation(platform(libs.androidx.compose.bom))
8384
implementation libs.androidx.activity.compose
8485
implementation libs.androidx.appcompat
8586
implementation libs.androidx.core.ktx

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/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/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)

Library/src/main/java/dev/testify/internal/helpers/ManifestHelpers.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,28 @@ sealed class ManifestPlaceholder(val key: String) {
4242
*
4343
* For example, if the test is running in the `app` module, this will be `app`.
4444
*/
45-
object Module : ManifestPlaceholder(MANIFEST_MODULE_KEY)
45+
data object Module : ManifestPlaceholder(MANIFEST_MODULE_KEY)
4646

4747
/**
4848
* The name of the destination to use for the test.
4949
*
5050
* For example, this would be `sdcard` if the test output is to be saved to the SD card.
5151
*
5252
*/
53-
object Destination : ManifestPlaceholder(MANIFEST_DESTINATION_KEY)
53+
data object Destination : ManifestPlaceholder(MANIFEST_DESTINATION_KEY)
5454

5555
/**
5656
* Whether or not the test is running in record mode.
5757
*/
58-
object RecordMode : ManifestPlaceholder(MANIFEST_IS_RECORD_MODE)
58+
data object RecordMode : ManifestPlaceholder(MANIFEST_IS_RECORD_MODE)
5959

6060
/**
6161
* The requested number of parallel threads to use for the ParallelPixelProcessor.
6262
* Default, or if 0 is set, is equal to the number of CPU cores.
6363
* Minimum is 1.
6464
* Maximum is 4.
6565
*/
66-
object ParallelThreads : ManifestPlaceholder(MANIFEST_PARALLEL_THREADS)
66+
data object ParallelThreads : ManifestPlaceholder(MANIFEST_PARALLEL_THREADS)
6767
}
6868

6969
/**
@@ -77,7 +77,6 @@ internal fun getMetaDataBundle(context: Context): Bundle? {
7777
val applicationInfo = if (buildVersionSdkInt() >= android.os.Build.VERSION_CODES.TIRAMISU) {
7878
context.packageManager?.getApplicationInfo(context.packageName, PackageManager.ApplicationInfoFlags.of(0))
7979
} else {
80-
@Suppress("DEPRECATION")
8180
context.packageManager?.getApplicationInfo(context.packageName, PackageManager.GET_META_DATA)
8281
}
8382
return applicationInfo?.metaData

Library/src/main/java/dev/testify/internal/helpers/OrientationHelper.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ class OrientationHelper(
6767
*
6868
* If the activity was launched in a different orientation than the requested orientation, perform a rotation.
6969
*
70-
* @param activity The activity to change the orientation of.
71-
* @param requestedOrientation The orientation to change to.
72-
* The value must be one of [SCREEN_ORIENTATION_LANDSCAPE] or [SCREEN_ORIENTATION_PORTRAIT].
7370
*/
7471
fun afterActivityLaunched() {
7572
//

Library/src/main/java/dev/testify/internal/helpers/ResourceWrapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ object ResourceWrapper {
206206
* @param fontScale The font scale to override. If null, the font scale will not be overridden.
207207
* @param locale The locale to override. If null, the locale will not be overridden.
208208
*/
209-
fun <A : Activity> overrideResourceConfiguration(
209+
fun <@Suppress("unused") A : Activity> overrideResourceConfiguration(
210210
fontScale: Float? = null,
211211
locale: Locale? = null
212212
) {

Library/src/main/java/dev/testify/internal/helpers/WrappedFontScale.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import android.content.Context
3131
import android.content.res.Configuration
3232
import android.os.Build
3333
import androidx.annotation.VisibleForTesting
34+
import dev.testify.resources.TestifyResourcesOverride
3435

3536
/**
3637
* A wrapped resource that allows for overriding the font scale of the device.

Library/src/main/java/dev/testify/internal/helpers/WrappedLocale.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ package dev.testify.internal.helpers
2828
import android.app.Activity
2929
import android.content.Context
3030
import dev.testify.internal.extensions.updateLocale
31+
import dev.testify.resources.TestifyResourcesOverride
3132
import java.util.Locale
3233

3334
/**

Library/src/main/java/dev/testify/internal/modification/FocusModification.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import android.os.Looper
3030
import android.view.View
3131
import androidx.annotation.IdRes
3232
import androidx.annotation.WorkerThread
33+
import dev.testify.core.TestifyConfiguration
3334
import java.util.concurrent.CountDownLatch
3435
import java.util.concurrent.TimeUnit
3536

Library/src/main/java/dev/testify/internal/modification/HideCursorViewModification.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package dev.testify.internal.modification
2626

2727
import android.view.View
2828
import android.widget.EditText
29+
import dev.testify.core.TestifyConfiguration
2930

3031
/**
3132
* A [ViewModification] that hides the cursor on an [EditText].

Library/src/main/java/dev/testify/internal/modification/HidePasswordViewModification.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ package dev.testify.internal.modification
2727
import android.text.method.PasswordTransformationMethod
2828
import android.view.View
2929
import android.widget.EditText
30+
import dev.testify.core.TestifyConfiguration
3031

3132
/**
3233
* A [ViewModification] that hides the password on an [EditText].
@@ -35,7 +36,7 @@ import android.widget.EditText
3536
* dots. This is useful for hiding passwords in screenshots and ensures that screenshots do not accidentally capture
3637
* the characters mid-transformation.
3738
*
38-
* @see TestifyConfiguration.hidePassword
39+
* @see TestifyConfiguration.hidePasswords
3940
*/
4041
class HidePasswordViewModification : ViewModification() {
4142

Library/src/main/java/dev/testify/internal/modification/HideScrollbarsViewModification.kt

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

2727
import android.view.View
28+
import dev.testify.core.TestifyConfiguration
2829

2930
/**
3031
* A [ViewModification] that hides the scrollbars on a view.

0 commit comments

Comments
 (0)