File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
sentry-android-replay/src
main/java/io/sentry/android/replay/util
test/java/io/sentry/android/replay/util Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -245,4 +245,4 @@ internal fun View?.removeOnPreDrawListenerSafe(listener: ViewTreeObserver.OnPreD
245245 }
246246}
247247
248- internal fun View.hasSize (): Boolean = width != 0 && height != 0
248+ internal fun View.hasSize (): Boolean = width > 0 && height > 0
Original file line number Diff line number Diff line change 1+ package io.sentry.android.replay.util
2+
3+ import android.view.View
4+ import android.view.ViewGroup
5+ import androidx.test.core.app.ApplicationProvider
6+ import androidx.test.ext.junit.runners.AndroidJUnit4
7+ import org.junit.runner.RunWith
8+ import kotlin.test.Test
9+ import kotlin.test.assertFalse
10+ import kotlin.test.assertTrue
11+
12+ @RunWith(AndroidJUnit4 ::class )
13+ class ViewsTest {
14+ @Test
15+ fun `hasSize returns true for positive values` () {
16+ val view = View (ApplicationProvider .getApplicationContext())
17+ view.right = 100
18+ view.bottom = 100
19+ assertTrue(view.hasSize())
20+ }
21+
22+ @Test
23+ fun `hasSize returns false for null values` () {
24+ val view = View (ApplicationProvider .getApplicationContext())
25+ view.right = 0
26+ view.bottom = 0
27+ assertFalse(view.hasSize())
28+ }
29+
30+ @Test
31+ fun `hasSize returns false for negative values` () {
32+ val view = View (ApplicationProvider .getApplicationContext())
33+ view.right = - 1
34+ view.bottom = - 1
35+ assertFalse(view.hasSize())
36+ }
37+ }
You can’t perform that action at this time.
0 commit comments