Skip to content
This repository was archived by the owner on Nov 14, 2018. It is now read-only.

Commit 7158a52

Browse files
committed
ClipData: extend test for invalid case (#497)
ClipData cannot be created with types of ClipData.Item other than Uri, CharSequence and Intent. Test that IllegalArgumentException is thrown by clipDataOf.
1 parent 9ef31b0 commit 7158a52

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/androidTest/java/androidx/core/content/ClipDataTest.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class ClipDataTest {
127127
assertThat(items).containsExactly("", "item1", "item2")
128128
}
129129

130-
@Test fun clipDataOf() {
130+
@Test fun clipDataOfValid() {
131131
clip.addItem(ClipData.Item("item1"))
132132
clip.addItem(ClipData.Item("item2"))
133133

@@ -150,4 +150,10 @@ class ClipDataTest {
150150
val iI = cI.map { item -> item.intent }
151151
assertThat(iI).containsExactlyElementsIn(intents)
152152
}
153+
154+
@Test fun clipDataOfInvalid() {
155+
assertThrows<IllegalArgumentException> {
156+
clipDataOf(listOf(1, 2, 3), "ints")
157+
}.hasMessageThat().isEqualTo("Illegal type: java.lang.Integer")
158+
}
153159
}

0 commit comments

Comments
 (0)