11package net .zetetic .database .sqlcipher_cts ;
22
3+ import static org .junit .Assert .assertEquals ;
4+
35import android .content .Context ;
6+
47import androidx .annotation .CallSuper ;
58import androidx .annotation .NonNull ;
69import androidx .sqlite .db .SupportSQLiteDatabase ;
710import androidx .sqlite .db .SupportSQLiteOpenHelper ;
811import androidx .test .ext .junit .runners .AndroidJUnit4 ;
912import androidx .test .platform .app .InstrumentationRegistry ;
13+
1014import net .zetetic .database .sqlcipher .SupportHelper ;
15+
1116import org .junit .Before ;
1217import org .junit .Test ;
1318import org .junit .runner .RunWith ;
1419
15- import static org .junit .Assert .assertEquals ;
16-
1720@ RunWith (AndroidJUnit4 .class )
1821public class SupportHelperTest {
1922
2023 private static final String DATABASE_NAME = "DB-Test.db" ;
2124 private static final int CREATION_INDEX = 0 ;
22- private static final int UPGRADE_INDEX = 0 ;
25+ private static final int UPGRADE_INDEX = 1 ;
2326
2427 @ Before
2528 public void setup () {
2629 Context context = InstrumentationRegistry .getInstrumentation ().getTargetContext ();
30+ System .loadLibrary ("sqlcipher" );
2731 for (String databaseName : context .databaseList ()) {
2832 context .deleteDatabase (databaseName );
2933 }
@@ -40,7 +44,7 @@ public void shouldCreateDatabaseNormallyWithInitialVersion() {
4044 helper .close ();
4145
4246 assertEquals (1 , callbackWrapper .callbackCount [CREATION_INDEX ]);
43- assertEquals (1 , callbackWrapper .callbackCount [UPGRADE_INDEX ]);
47+ assertEquals (0 , callbackWrapper .callbackCount [UPGRADE_INDEX ]);
4448 }
4549
4650 @ Test
@@ -52,6 +56,9 @@ public void shouldRunUpgradeFromVersion1ToVersion2() {
5256 initialHelper .getWritableDatabase ();
5357 initialHelper .close ();
5458
59+ assertEquals (1 , initialCallback .callbackCount [CREATION_INDEX ]);
60+ assertEquals (0 , initialCallback .callbackCount [UPGRADE_INDEX ]);
61+
5562 FakeCallback callbackWrapper = new FakeCallback (2 );
5663
5764 // minSupportedVersion = 1
0 commit comments