Skip to content

Commit 44ab784

Browse files
committed
Move tests to Ktx
1 parent e1a3956 commit 44ab784

File tree

12 files changed

+98
-12
lines changed

12 files changed

+98
-12
lines changed

Ext/Ktx/build.gradle

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,33 @@ android {
7777
implementation libs.androidx.uiautomator
7878
implementation libs.core.ktx
7979
implementation libs.androidx.test.storage
80-
}
8180

81+
// TODO: trim this list down
82+
testImplementation libs.kotlinx.coroutines.test
83+
testImplementation libs.mockk
84+
testImplementation libs.slf4j.jdk14
85+
testImplementation libs.truth
86+
87+
// TODO: trim this list down
88+
androidTestImplementation libs.androidx.appcompat
89+
androidTestImplementation libs.androidx.espresso.contrib
90+
androidTestImplementation libs.androidx.espresso.core
91+
androidTestImplementation libs.androidx.junit
92+
androidTestImplementation libs.androidx.multidex
93+
androidTestImplementation libs.androidx.rules
94+
androidTestImplementation libs.androidx.runner
95+
androidTestImplementation libs.material
96+
androidTestImplementation libs.mockk.android
97+
}
98+
packagingOptions {
99+
resources {
100+
excludes += [
101+
'MANIFEST.MF',
102+
'META-INF/LICENSE.md',
103+
'META-INF/LICENSE-notice.md'
104+
]
105+
}
106+
}
82107
publishing {
83108
singleVariant("release") {
84109
// if you don't want sources/javadoc, remove these lines
21 KB
Loading

Library/src/androidTest/java/dev/testify/ScreenshotUtilityTest.kt renamed to Ext/Ktx/src/androidTest/java/dev/testify/ScreenshotUtilityTest.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Modified work copyright (c) 2022 ndtp
4+
* Modified work copyright (c) 2022-2025 ndtp
55
* Original work copyright (c) 2019 Shopify Inc.
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -26,11 +26,12 @@
2626

2727
package dev.testify
2828

29+
import android.app.Activity
30+
import android.graphics.Bitmap
2931
import android.view.View
3032
import androidx.test.ext.junit.runners.AndroidJUnit4
3133
import androidx.test.platform.app.InstrumentationRegistry
3234
import androidx.test.rule.ActivityTestRule
33-
import dev.testify.core.processor.capture.createBitmapFromDrawingCache
3435
import dev.testify.output.getDestination
3536
import org.junit.Assert.assertFalse
3637
import org.junit.Assert.assertNotNull
@@ -61,14 +62,17 @@ class ScreenshotUtilityTest {
6162
@Test
6263
fun createBitmapFromActivity() {
6364
val activity = testActivityRule.activity
64-
val rootView = activity.findViewById<View>(R.id.test_root_view)
65+
val rootView = activity.findViewById<View>(android.R.id.content)
6566
val destination = getDestination(context = activity, fileName = "testing")
6667
val bitmapFile = destination.file
6768

6869
val capturedBitmap = createBitmapFromActivity(
6970
activity = activity,
7071
fileName = "testing",
71-
captureMethod = ::createBitmapFromDrawingCache,
72+
captureMethod = { activity: Activity, view: View? ->
73+
val view: View = view ?: activity.window.decorView
74+
Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
75+
},
7276
screenshotView = rootView
7377
)
7478
assertNotNull(capturedBitmap)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools">
4+
5+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
6+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7+
8+
<uses-sdk tools:overrideLibrary="io.mockk, io.mockk.proxy.android" />
9+
10+
<application android:theme="@style/Theme.MaterialComponents.Light.DarkActionBar">
11+
<activity android:name="dev.testify.TestActivity" />
12+
</application>
13+
14+
</manifest>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Modified work copyright (c) 2022 ndtp
5+
* Original work copyright (c) 2019 Shopify Inc.
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package dev.testify
26+
27+
import android.app.Activity
28+
import android.os.Bundle
29+
30+
/**
31+
* This is a test Activity that is used to test the Testify library.
32+
*/
33+
class TestActivity : Activity() {
34+
35+
override fun onCreate(savedInstanceState: Bundle?) {
36+
super.onCreate(savedInstanceState)
37+
}
38+
}

Ext/Ktx/src/main/java/dev/testify/annotation/AnnotationExtensions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* THE SOFTWARE.
2323
*/
2424
@file:JvmName("AnnotationExtensionsKtx")
25+
2526
package dev.testify.annotation
2627

2728
/**

Library/src/main/java/dev/testify/core/processor/capture/CanvasCapture.kt renamed to Ext/Ktx/src/main/java/dev/testify/core/processor/capture/CanvasCapture.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Modified work copyright (c) 2022 ndtp
4+
* Modified work copyright (c) 2022-2025 ndtp
55
* Original work copyright (c) 2019 Shopify Inc.
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy

Library/src/main/java/dev/testify/core/processor/capture/DrawingCacheCapture.kt renamed to Ext/Ktx/src/main/java/dev/testify/core/processor/capture/DrawingCacheCapture.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Modified work copyright (c) 2022 ndtp
4+
* Modified work copyright (c) 2022-2025 ndtp
55
* Original work copyright (c) 2019 Shopify Inc.
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy

Library/src/main/java/dev/testify/core/processor/capture/PixelCopyCapture.kt renamed to Ext/Ktx/src/main/java/dev/testify/core/processor/capture/PixelCopyCapture.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Modified work copyright (c) 2022 ndtp
4+
* Modified work copyright (c) 2022-2025 ndtp
55
* Original work copyright (c) 2019 Shopify Inc.
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy

Ext/Ktx/src/main/java/dev/testify/extensions/InstrumentationRegistryExtensions.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ fun instrumentationPrintln(str: String) {
5454
*/
5555
@ExcludeFromJacocoGeneratedReport
5656
fun getModuleName(instrumentationRegistryArguments: Bundle): String {
57-
val name = if (instrumentationRegistryArguments.containsKey("moduleName")) instrumentationRegistryArguments.getString(
58-
"moduleName"
59-
)!! + ":" else ""
57+
val name = if (instrumentationRegistryArguments.containsKey("moduleName")) {
58+
instrumentationRegistryArguments.getString(
59+
"moduleName"
60+
)!! + ":"
61+
} else {
62+
""
63+
}
6064
return name.ifEmpty { ManifestPlaceholder.Module.getMetaDataValue() ?: "" }
6165
}
6266

0 commit comments

Comments
 (0)