Skip to content

Commit 2c56846

Browse files
EmilioBejasaclaude
andauthored
Remove redundant custom file saves from screenshot tests (#28)
* Add reusable test infrastructure base classes Adds base classes that apps can extend for screenshot testing: - BaseScreenshotTestRunner: Configures screenshot directory - BaseStoryManifestTest: Generates story manifest for discovery - BaseStoryScreenshotTest: Auto-discovers and screenshots all stories Apps only need to extend these classes and provide their Activity class. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Remove redundant custom file saves from screenshot tests The screenshot-tests-for-android library already handles saving screenshots properly. The custom file saves to /sdcard/Download/ were redundant and problematic on Android 13+ due to scoped storage. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Remove BaseStoryManifestTest and BaseStoryScreenshotTest These base test classes are not currently used by TestApp tests and can be added in a separate PR when needed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c1dd1fe commit 2c56846

File tree

1 file changed

+0
-72
lines changed

1 file changed

+0
-72
lines changed

android/app/src/androidTest/java/com/testapp/ScreenshotTest.kt

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,6 @@ class ScreenshotTest {
7878
timerView.measure(widthSpec, heightSpec)
7979
timerView.layout(0, 0, timerView.measuredWidth, timerView.measuredHeight)
8080

81-
// Log the dimensions for verification
82-
android.util.Log.d("ScreenshotTest", "Timer view dimensions: ${timerView.measuredWidth} x ${timerView.measuredHeight}")
83-
84-
// Also save to external storage for easier access
85-
val bitmap = android.graphics.Bitmap.createBitmap(
86-
timerView.measuredWidth,
87-
timerView.measuredHeight,
88-
android.graphics.Bitmap.Config.ARGB_8888
89-
)
90-
val canvas = android.graphics.Canvas(bitmap)
91-
timerView.draw(canvas)
92-
93-
val file = java.io.File("/sdcard/Download/timer_paused_full.png")
94-
java.io.FileOutputStream(file).use { out ->
95-
bitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, out)
96-
}
97-
android.util.Log.d("ScreenshotTest", "Screenshot saved to: ${file.absolutePath}")
98-
9981
Screenshot.snap(timerView)
10082
.setName("timer_paused")
10183
.record()
@@ -115,24 +97,6 @@ class ScreenshotTest {
11597
coinFlipView.measure(widthSpec, heightSpec)
11698
coinFlipView.layout(0, 0, coinFlipView.measuredWidth, coinFlipView.measuredHeight)
11799

118-
// Log the dimensions for verification
119-
android.util.Log.d("ScreenshotTest", "CoinFlip view dimensions: ${coinFlipView.measuredWidth} x ${coinFlipView.measuredHeight}")
120-
121-
// Save to external storage
122-
val bitmap = android.graphics.Bitmap.createBitmap(
123-
coinFlipView.measuredWidth,
124-
coinFlipView.measuredHeight,
125-
android.graphics.Bitmap.Config.ARGB_8888
126-
)
127-
val canvas = android.graphics.Canvas(bitmap)
128-
coinFlipView.draw(canvas)
129-
130-
val file = java.io.File("/sdcard/Download/coin_flip_heads.png")
131-
java.io.FileOutputStream(file).use { out ->
132-
bitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, out)
133-
}
134-
android.util.Log.d("ScreenshotTest", "Screenshot saved to: ${file.absolutePath}")
135-
136100
Screenshot.snap(coinFlipView)
137101
.setName("coin_flip_heads")
138102
.record()
@@ -151,24 +115,6 @@ class ScreenshotTest {
151115
myFeatureView.measure(widthSpec, heightSpec)
152116
myFeatureView.layout(0, 0, myFeatureView.measuredWidth, myFeatureView.measuredHeight)
153117

154-
// Log the dimensions for verification
155-
android.util.Log.d("ScreenshotTest", "MyFeature view dimensions: ${myFeatureView.measuredWidth} x ${myFeatureView.measuredHeight}")
156-
157-
// Save to external storage
158-
val bitmap = android.graphics.Bitmap.createBitmap(
159-
myFeatureView.measuredWidth,
160-
myFeatureView.measuredHeight,
161-
android.graphics.Bitmap.Config.ARGB_8888
162-
)
163-
val canvas = android.graphics.Canvas(bitmap)
164-
myFeatureView.draw(canvas)
165-
166-
val file = java.io.File("/sdcard/Download/my_feature.png")
167-
java.io.FileOutputStream(file).use { out ->
168-
bitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, out)
169-
}
170-
android.util.Log.d("ScreenshotTest", "Screenshot saved to: ${file.absolutePath}")
171-
172118
Screenshot.snap(myFeatureView)
173119
.setName("my_feature")
174120
.record()
@@ -187,24 +133,6 @@ class ScreenshotTest {
187133
switchFeatureView.measure(widthSpec, heightSpec)
188134
switchFeatureView.layout(0, 0, switchFeatureView.measuredWidth, switchFeatureView.measuredHeight)
189135

190-
// Log the dimensions for verification
191-
android.util.Log.d("ScreenshotTest", "SwitchFeature view dimensions: ${switchFeatureView.measuredWidth} x ${switchFeatureView.measuredHeight}")
192-
193-
// Save to external storage
194-
val bitmap = android.graphics.Bitmap.createBitmap(
195-
switchFeatureView.measuredWidth,
196-
switchFeatureView.measuredHeight,
197-
android.graphics.Bitmap.Config.ARGB_8888
198-
)
199-
val canvas = android.graphics.Canvas(bitmap)
200-
switchFeatureView.draw(canvas)
201-
202-
val file = java.io.File("/sdcard/Download/switch_feature_enabled.png")
203-
java.io.FileOutputStream(file).use { out ->
204-
bitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, out)
205-
}
206-
android.util.Log.d("ScreenshotTest", "Screenshot saved to: ${file.absolutePath}")
207-
208136
Screenshot.snap(switchFeatureView)
209137
.setName("switch_feature_enabled")
210138
.record()

0 commit comments

Comments
 (0)