Skip to content

Commit e0222f3

Browse files
Adjust default database handler tests to support SQLITE_HAS_CODEC behavior
1 parent d69badb commit e0222f3

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

sqlcipher/src/androidTest/java/net/zetetic/database/sqlcipher_android/DatabaseGeneralTest.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,11 @@ public void testDefaultDatabaseErrorHandler() {
961961
assertTrue(dbfile.exists());
962962
try {
963963
errorHandler.onCorruption(mDatabase);
964-
assertFalse(dbfile.exists());
964+
if(SQLiteDatabase.hasCodec()){
965+
assertTrue(dbfile.exists());
966+
} else {
967+
assertFalse(dbfile.exists());
968+
}
965969
} catch (Exception e) {
966970
fail("unexpected");
967971
}
@@ -984,7 +988,11 @@ public void testDefaultDatabaseErrorHandler() {
984988
assertTrue(dbObj.isOpen());
985989
try {
986990
errorHandler.onCorruption(dbObj);
987-
assertFalse(dbfile.exists());
991+
if(SQLiteDatabase.hasCodec()){
992+
assertTrue(dbfile.exists());
993+
} else{
994+
assertFalse(dbfile.exists());
995+
}
988996
} catch (Exception e) {
989997
fail("unexpected");
990998
}
@@ -1005,8 +1013,16 @@ public void testDefaultDatabaseErrorHandler() {
10051013
List<Pair<String, String>> attachedDbs = dbObj.getAttachedDbs();
10061014
try {
10071015
errorHandler.onCorruption(dbObj);
1008-
assertFalse(dbfile.exists());
1009-
assertFalse(new File(attachedDb1File).exists());
1016+
if(SQLiteDatabase.hasCodec()){
1017+
assertTrue(dbfile.exists());
1018+
} else {
1019+
assertFalse(dbfile.exists());
1020+
}
1021+
if(SQLiteDatabase.hasCodec()){
1022+
assertTrue(new File(attachedDb1File).exists());
1023+
} else {
1024+
assertFalse(new File(attachedDb1File).exists());
1025+
}
10101026
} catch (Exception e) {
10111027
fail("unexpected");
10121028
}
@@ -1032,9 +1048,17 @@ public void testDefaultDatabaseErrorHandler() {
10321048
attachedDbs = dbObj.getAttachedDbs();
10331049
try {
10341050
errorHandler.onCorruption(dbObj);
1035-
assertFalse(dbfile.exists());
1051+
if(SQLiteDatabase.hasCodec()){
1052+
assertTrue(dbfile.exists());
1053+
} else {
1054+
assertFalse(dbfile.exists());
1055+
}
10361056
for (int i = 0; i < N; i++) {
1037-
assertFalse(new File(attachedDbFiles.get(i)).exists());
1057+
if(SQLiteDatabase.hasCodec()){
1058+
assertTrue(new File(attachedDbFiles.get(i)).exists());
1059+
} else {
1060+
assertFalse(new File(attachedDbFiles.get(i)).exists());
1061+
}
10381062
}
10391063
} catch (Exception e) {
10401064
fail("unexpected");

0 commit comments

Comments
 (0)