File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
main/kotlin/org/wordpress/aztec/spans
test/kotlin/org/wordpress/aztec Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class MarkSpan : CharacterStyle, IAztecInlineSpan {
2626 }
2727
2828 private fun safelyParseColor (colorString : String? ): Int? {
29- if (colorString == null ) {
29+ if (colorString.isNullOrBlank() ) {
3030 return null
3131 }
3232 return try {
Original file line number Diff line number Diff line change 1+ package org.wordpress.aztec
2+
3+ import org.junit.Assert
4+ import org.junit.Test
5+ import org.wordpress.aztec.spans.MarkSpan
6+
7+ class MarkSpanTest {
8+ /* *
9+ * Test used to confirm two crashes related are fixed.
10+ *
11+ * https://github.com/wordpress-mobile/WordPress-Android/issues/20738
12+ */
13+ @Test
14+ fun `Calling MarkSpan#safelyParseColor with empty string should not cause a crash` () {
15+ var error = false
16+ try {
17+ MarkSpan (colorString = " " )
18+ } catch (e: Exception ) {
19+ error = true
20+ }
21+ Assert .assertFalse(error)
22+ }
23+
24+ /* *
25+ * Test used to confirm two crashes related are fixed.
26+ *
27+ * https://github.com/wordpress-mobile/WordPress-Android/issues/20694
28+ */
29+ @Test
30+ fun `Calling MarkSpan#safelyParseColor with null string should not cause a crash` () {
31+ var error = false
32+ try {
33+ MarkSpan (colorString = null )
34+ } catch (e: Exception ) {
35+ error = true
36+ }
37+ Assert .assertFalse(error)
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments