Skip to content

Commit 8d908fd

Browse files
Adjustments to TestAbstractCursor to get ignored tests to pass
- Report success in onMove to allow ignored tests to pass. The call to cursorFillWindow would call moveToPosition, but would never report a successful move which prevented the tests from passing. - Also requiring adding some guards to the getString implementation for invalid values.
1 parent 41f5cbf commit 8d908fd

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

‎sqlcipher/src/androidTest/java/net/zetetic/database/database_cts/AbstractCursorTest.java‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import static org.junit.Assert.assertTrue;
2424
import static org.junit.Assert.fail;
2525

26-
import android.annotation.SuppressLint;
2726
import android.content.Context;
2827
import android.database.CharArrayBuffer;
2928
import android.database.ContentObserver;
@@ -42,7 +41,6 @@
4241

4342
import org.junit.After;
4443
import org.junit.Before;
45-
import org.junit.Ignore;
4644
import org.junit.Test;
4745
import org.junit.runner.RunWith;
4846

@@ -193,8 +191,6 @@ public void testOnChange() throws InterruptedException {
193191
assertTrue(mock.hadCalledOnChange());
194192
}
195193

196-
@SuppressLint("IgnoreWithoutReason")
197-
@Ignore
198194
@Test
199195
public void testOnMove() {
200196
assertFalse(mTestAbstractCursor.getOnMoveRet());
@@ -209,8 +205,6 @@ public void testOnMove() {
209205
assertEquals(5, mTestAbstractCursor.getNewPos());
210206
}
211207

212-
@SuppressLint("IgnoreWithoutReason")
213-
@Ignore
214208
@Test
215209
public void testOnMove_samePosition() {
216210
mTestAbstractCursor.moveToFirst();
@@ -367,8 +361,6 @@ public void testDeactivate() {
367361
assertTrue(mock.hadCalledOnInvalid());
368362
}
369363

370-
@SuppressLint("IgnoreWithoutReason")
371-
@Ignore
372364
@Test
373365
public void testCopyStringToBuffer() {
374366
CharArrayBuffer ca = new CharArrayBuffer(1000);
@@ -384,8 +376,6 @@ public void testCopyStringToBuffer() {
384376
assertEquals(sb.toString(), new String(ca.data, 0, ca.sizeCopied));
385377
}
386378

387-
@SuppressLint("IgnoreWithoutReason")
388-
@Ignore
389379
@Test
390380
public void testCheckPosition() {
391381
// Test with position = -1.
@@ -527,6 +517,7 @@ public boolean onMove(int oldPosition, int newPosition) {
527517
mOldPosition = oldPosition;
528518
mNewPosition = newPosition;
529519
mRowsMovedSum += Math.abs(newPosition - oldPosition);
520+
mOnMoveReturnValue = true;
530521
return mOnMoveReturnValue;
531522
}
532523

@@ -542,7 +533,14 @@ public String[] getColumnNames() {
542533

543534
@Override
544535
public String getString(int columnIndex) {
545-
Object cell = mRows[mPos].get(columnIndex);
536+
if(mPos < 0){
537+
return null;
538+
}
539+
var row = mRows[mPos];
540+
if(row == null) {
541+
return null;
542+
}
543+
Object cell = row.get(columnIndex);
546544
return (cell == null) ? null : cell.toString();
547545
}
548546

@@ -583,7 +581,7 @@ public boolean isNull(int column) {
583581

584582
@Override
585583
public int getType(int column) {
586-
return 0;
584+
return FIELD_TYPE_STRING;
587585
}
588586

589587
public boolean hadCalledOnChange() {

0 commit comments

Comments
 (0)