Skip to content

Commit

Permalink
Update tests with the fix for #525
Browse files Browse the repository at this point in the history
  • Loading branch information
CampelloManuel committed Sep 12, 2024
1 parent f37d8f0 commit fc9344c
Showing 1 changed file with 14 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.net.Uri;
import android.os.SystemClock;

Expand Down Expand Up @@ -46,22 +47,10 @@ private void assertUriReturnsResult(final Uri uri, final String[] fields, final
final Cursor c = mResolver
.query(uri, fields, where, whereArgs, null);
assertNotNull(c);
if (count == 6 && c.getCount() == 7) {
// TODO sometimes tests on github (not on a fast PC) crash here. Investigate why
NnnLogger.debug(DBProviderTest.class, "cursor info:");
// will crash. Let's get more info
try {
NnnLogger.debug(DBProviderTest.class,
"Columns: " + String.join(",", c.getColumnNames()));
while (c.moveToNext()) {
for (int i = 0; i < c.getColumnCount(); i++) {
NnnLogger.debug(DBProviderTest.class, c.getString(i));
}
}
} catch (Exception e) {
NnnLogger.exception(e);
}
}

String READABLE_CURSOR_DUMP = DatabaseUtils.dumpCursorToString(c);
NnnLogger.debug(DBProviderTest.class, READABLE_CURSOR_DUMP);

final int cursorCount = c.getCount();
c.close();
if (count < 0) {
Expand Down Expand Up @@ -115,9 +104,15 @@ public void testTaskURIs() {
SystemClock.sleep(500);

// Sectioned Date query
assertUriReturnsResult(Task.URI_SECTIONED_BY_DATE, Task.Columns.FIELDS,
Task.Columns.DBLIST + " IS ?",
new String[] { Long.toString(list._id) }, taskCount + 1);
assertUriReturnsResult(
Task.URI_SECTIONED_BY_DATE,
Task.Columns.FIELDS,
// see issue #525: on some android devices, "dblist" is a column of type BLOB,
// but we expect it to always be INTEGER. On older devices this cast is redundant,
// but on newer OS versions it fixes the bug when selecting notes by due date
"CAST(" + Task.Columns.DBLIST + " AS INTEGER) IS ?",
new String[] { Long.toString(list._id) },
taskCount + 1);

// History query
Task t = tasks.get(0);
Expand Down

0 comments on commit fc9344c

Please sign in to comment.