Adding tests for CursorWindowAllocationException.
Tag: #feature
Test: manual
Bug: 211851706
Change-Id: Ibe17d99c791699f9e39ab87e11b91409faa0c0e1
diff --git a/tests/tests/database/src/android/database/cts/CursorWindowTest.java b/tests/tests/database/src/android/database/cts/CursorWindowTest.java
index cae9d51..5d3b7bb 100644
--- a/tests/tests/database/src/android/database/cts/CursorWindowTest.java
+++ b/tests/tests/database/src/android/database/cts/CursorWindowTest.java
@@ -25,6 +25,7 @@
import android.database.CharArrayBuffer;
import android.database.CursorWindow;
+import android.database.CursorWindowAllocationException;
import android.database.MatrixCursor;
import android.database.sqlite.SQLiteException;
import android.os.Parcel;
@@ -438,15 +439,11 @@
Exception actual = null;
try {
new CursorWindow("test", -1);
- } catch (RuntimeException caught) {
+ } catch (IllegalArgumentException caught) {
Log.i(TAG, "Received: " + caught);
- actual = caught;
- // CursorWindowAllocationException is hidden, so let's just check the message.
- if (actual.getMessage().contains("Could not allocate CursorWindow")) {
- return;
- }
+ return;
}
- fail("Didn't catch CursorWindowAllocationException: actual=" + actual);
+ fail("Didn't catch IllegalArgumentException: actual=" + actual);
}
@Test
@@ -454,13 +451,9 @@
Exception actual = null;
try {
CursorWindow.CREATOR.createFromParcel(Parcel.obtain());
- } catch (RuntimeException caught) {
+ } catch (CursorWindowAllocationException caught) {
Log.i(TAG, "Received: " + caught);
- actual = caught;
- // CursorWindowAllocationException is hidden, so let's just check the message.
- if (actual.getMessage().contains("Could not create CursorWindow")) {
- return;
- }
+ return;
}
fail("Didn't catch CursorWindowAllocationException: actual=" + actual);
}