Skip to content

Commit 5368f7c

Browse files
Removing the async task for now as it was causing issues with multiple tests at play
1 parent d172f25 commit 5368f7c

File tree

9 files changed

+131
-106
lines changed

9 files changed

+131
-106
lines changed
0 Bytes
Binary file not shown.

libs/sqlcipher.jar

1.32 KB
Binary file not shown.

net.zetetic.sqlcipher.test.iws

Lines changed: 107 additions & 74 deletions
Large diffs are not rendered by default.

src/main/java/net/zetetic/ZeteticApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public Activity getCurrentActivity(){
3131
}
3232

3333
public SQLiteDatabase createDatabase(){
34-
File databaseFile = getDatabasePath(ZeteticApplication.DATABASE_NAME);
34+
File databaseFile = getDatabasePath(DATABASE_NAME);
3535
databaseFile.mkdirs();
3636
databaseFile.delete();
3737
return SQLiteDatabase.openOrCreateDatabase(databaseFile, DATABASE_PASSWORD, null);

src/main/java/net/zetetic/ZeteticContentProvider.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public class ZeteticContentProvider extends ContentProvider {
1717
public ZeteticContentProvider() {
1818
SQLiteDatabase.loadLibs(ZeteticApplication.getInstance());
1919
database = ZeteticApplication.getInstance().createDatabase();
20-
database.execSQL("create table t1(a, b);");
21-
database.execSQL("insert into t1(a, b) values('one for the money', 'two for the show');");
2220
}
2321

2422
@Override
@@ -28,7 +26,7 @@ public boolean onCreate() {
2826

2927
@Override
3028
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
31-
//return database.rawQuery("select * from t1", null);
29+
createDatabaseWithData(database);
3230
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
3331
builder.setTables("t1");
3432
return builder.query(database, new String[]{"a", "b"}, null, null, null, null, null);
@@ -53,4 +51,9 @@ public int delete(Uri uri, String s, String[] strings) {
5351
public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
5452
return 0;
5553
}
54+
55+
private void createDatabaseWithData(SQLiteDatabase database) {
56+
database.execSQL("create table if not exists t1(a, b);");
57+
database.execSQL("insert into t1(a, b) values('one for the money', 'two for the show');");
58+
}
5659
}

src/main/java/net/zetetic/tests/CrossProcessCursorQueryTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,26 @@
77
import net.zetetic.ZeteticContentProvider;
88

99
public class CrossProcessCursorQueryTest extends SQLCipherTest {
10+
1011
@Override
1112
public boolean execute(SQLiteDatabase database) {
1213

1314
Activity activity = ZeteticApplication.getInstance().getCurrentActivity();
1415
Uri providerUri = ZeteticContentProvider.CONTENT_URI;
1516
android.database.Cursor cursor = activity.managedQuery(providerUri, null, null, null, null);
1617
StringBuilder buffer = new StringBuilder();
17-
while(cursor.moveToNext()){
18+
while (cursor.moveToNext()) {
1819
buffer.append(cursor.getString(0));
1920
buffer.append(cursor.getString(1));
2021
}
22+
cursor.close();
2123
return buffer.toString().length() > 0;
2224
}
23-
25+
26+
27+
2428
@Override
2529
public String getName() {
26-
return "Cross Process Cursor";
30+
return "Cross Process Cursor Test";
2731
}
2832
}

src/main/java/net/zetetic/tests/SQLCipherTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ protected void setUp() {
1616
}
1717

1818
public TestResult run() {
19-
19+
2020
TestResult result = new TestResult(getName(), false);
2121
try {
2222
setUp();
2323
result.setResult(execute(database));
24+
tearDown();
2425
} catch (Exception e) {
2526
Log.v(ZeteticApplication.TAG, e.toString());
2627
}
2728
return result;
2829
}
30+
31+
private void tearDown(){
32+
database.close();
33+
SQLiteDatabase.releaseMemory();
34+
}
2935
}

src/main/java/net/zetetic/tests/TestSuiteRunner.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.zetetic.tests;
22

3+
import android.util.Log;
34
import info.guardianproject.database.sqlcipher.SQLiteDatabase;
45
import net.zetetic.ZeteticApplication;
56

@@ -18,7 +19,8 @@ public void runSuite(){
1819

1920
SQLiteDatabase.loadLibs(ZeteticApplication.getInstance());
2021
for(SQLCipherTest test : getTestsToRun()){
21-
new TestTask(notifier).execute(test);
22+
Log.i(ZeteticApplication.TAG, "Running test:" + test.getName());
23+
notifier.send(test.run());
2224
}
2325
}
2426

src/main/java/net/zetetic/tests/TestTask.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)