-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathTestSuiteRunner.java
200 lines (182 loc) · 7.86 KB
/
TestSuiteRunner.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
package net.zetetic.tests;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
import android.view.WindowManager;
import net.sqlcipher.CursorWindow;
import net.sqlcipher.CursorWindowAllocation;
import net.zetetic.ZeteticApplication;
import java.util.ArrayList;
import java.util.List;
public class TestSuiteRunner extends AsyncTask<ResultNotifier, TestResult, Void> {
String TAG = getClass().getSimpleName();
private ResultNotifier notifier;
private Activity activity;
public TestSuiteRunner(Activity activity) {
this.activity = activity;
if (this.activity != null) {
this.activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
@Override
protected Void doInBackground(ResultNotifier... resultNotifiers) {
this.notifier = resultNotifiers[0];
Log.i(ZeteticApplication.TAG, String.format("Running test suite on %s platform", Build.CPU_ABI));
runSuite();
return null;
}
@Override
protected void onProgressUpdate(TestResult... values) {
notifier.send(values[0]);
}
@Override
protected void onPostExecute(Void aVoid) {
notifier.complete();
if (this.activity != null) {
this.activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
private void runSuite() {
CursorWindowAllocation defaultAllocation = CursorWindow.getCursorWindowAllocation();
for (SQLCipherTest test : getTestsToRun()) {
try {
CursorWindow.setCursorWindowAllocation(defaultAllocation);
Log.i(ZeteticApplication.TAG, "Running test:" + test.getName());
TestResult result = test.run();
publishProgress(result);
} catch (Throwable e) {
Log.i(ZeteticApplication.TAG, e.toString());
publishProgress(new TestResult(test.getName(), false, e.toString()));
}
finally {
CursorWindow.setCursorWindowAllocation(defaultAllocation);
}
}
}
private List<SQLCipherTest> getTestsToRun() {
List<SQLCipherTest> tests = new ArrayList<>();
tests.add(new SQLCompileStatementFinalizeTest(false));
tests.add(new SQLCompileStatementFinalizeTest(true));
tests.add(new SummingStepTest());
tests.add(new JsonCastTest());
tests.add(new SimpleQueryTest());
tests.add(new DefaultCursorWindowAllocationTest());
tests.add(new DeleteTableWithNullWhereArgsTest());
tests.add(new LoopingInsertTest());
tests.add(new FIPSTest());
tests.add(new PragmaCipherVersionTest());
tests.add(new VerifyCipherProviderTest());
tests.add(new VerifyCipherProviderVersionTest());
tests.add(new JavaClientLibraryVersionTest());
tests.add(new ReadWriteUserVersionTest());
tests.add(new QueryDataSizeTest());
tests.add(new FixedCursorWindowAllocationTest());
tests.add(new GrowingCursorWindowAllocationTest());
tests.add(new ReadWriteWriteAheadLoggingTest());
tests.add(new CreateOpenDatabaseWithByteArrayTest());
tests.add(new SQLiteOpenHelperWithByteArrayKeyTest());
tests.add(new SQLiteOpenHelperEnableWriteAheadLogBeforeGetDatabaseTest());
tests.add(new SQLiteOpenHelperEnableWriteAheadLogAfterGetDatabaseTest());
tests.add(new SQLiteOpenHelperGetNameTest());
tests.add(new SQLiteOpenHelperOnDowngradeTest());
tests.add(new SQLiteOpenHelperConfigureTest());
tests.add(new CheckIsDatabaseIntegrityOkTest());
tests.add(new GetAttachedDatabasesTest());
tests.add(new EnableForeignKeyConstraintsTest());
tests.add(new ForeignKeyConstraintsEnabledWithTransactionTest());
tests.add(new EnableWriteAheadLoggingTest());
tests.add(new DisableWriteAheadLoggingTest());
tests.add(new CheckIsWriteAheadLoggingEnabledTest());
tests.add(new WriteAheadLoggingWithTransactionTest());
tests.add(new WriteAheadLoggingWithInMemoryDatabaseTest());
tests.add(new WriteAheadLoggingWithAttachedDatabaseTest());
tests.add(new TransactionNonExclusiveTest());
tests.add(new TransactionWithListenerTest());
tests.add(new LargeDatabaseCursorAccessTest());
//// tests.add(new TimeLargeByteArrayQueryTest());
tests.add(new QueryLimitTest());
tests.add(new RTreeTest());
tests.add(new ReadWriteDatabaseToExternalStorageTest());
tests.add(new BeginTransactionTest());
tests.add(new QueryTenThousandDataTest());
tests.add(new CompileBeginTest());
tests.add(new TimeQueryExecutionTest());
tests.add(new UnicodeTest());
tests.add(new QueryIntegerToStringTest());
tests.add(new QueryFloatToStringTest());
tests.add(new ClosedDatabaseTest());
tests.add(new AttachDatabaseTest());
tests.add(new CipherMigrateTest());
tests.add(new GetTypeFromCrossProcessCursorWrapperTest());
tests.add(new InvalidPasswordTest());
tests.add(new NullQueryResultTest());
tests.add(new CrossProcessCursorQueryTest());
tests.add(new InterprocessBlobQueryTest());
tests.add(new LoopingQueryTest());
tests.add(new LoopingCountQueryTest());
tests.add(new AttachNewDatabaseTest());
tests.add(new AttachExistingDatabaseTest());
tests.add(new CanThrowSQLiteExceptionTest());
tests.add(new RawExecSQLTest());
tests.add(new RawExecSQLExceptionTest());
tests.add(new CompiledSQLUpdateTest());
tests.add(new AES128CipherTest());
tests.add(new MigrateDatabaseFrom1xFormatToCurrentFormat());
tests.add(new StatusMemoryUsedTest());
tests.add(new ImportUnencryptedDatabaseTest());
tests.add(new FullTextSearchTest());
tests.add(new ReadableDatabaseTest());
tests.add(new AutoVacuumOverReadTest());
tests.add(new ReadableWritableAccessTest());
tests.add(new CursorAccessTest());
tests.add(new VerifyOnUpgradeIsCalledTest());
tests.add(new MigrationUserVersion());
tests.add(new ExportToUnencryptedDatabase());
tests.add(new QueryNonEncryptedDatabaseTest());
tests.add(new EnableForeignKeySupportTest());
tests.add(new AverageOpenTimeTest());
tests.add(new NestedTransactionsTest());
tests.add(new ComputeKDFTest());
tests.add(new SoundexTest());
tests.add(new RawQueryTest());
tests.add(new OpenReadOnlyDatabaseTest());
tests.add(new RawRekeyTest());
tests.add(new CorruptDatabaseTest());
tests.add(new CustomCorruptionHandlerTest());
tests.add(new MultiThreadReadWriteTest());
tests.add(new VerifyUTF8EncodingForKeyTest());
tests.add(new TextAsIntegerTest());
tests.add(new TextAsDoubleTest());
tests.add(new TextAsLongTest());
tests.add(new CreateNonEncryptedDatabaseTest());
tests.add(new ChangePasswordTest());
tests.add(new ReadableWritableInvalidPasswordTest());
tests.add(new InvalidOpenArgumentTest());
tests.add(new CopyStringToBufferTestFloatSmallBuffer());
tests.add(new CopyStringToBufferTestFloatLargeBuffer());
tests.add(new CopyStringToBufferTestIntegerSmallBuffer());
tests.add(new CopyStringToBufferTestIntegerLargeBuffer());
tests.add(new CopyStringToBufferTestStringSmallBuffer());
tests.add(new CopyStringToBufferTestStringLargeBuffer());
tests.add(new CopyStringToBufferNullTest());
tests.add(new OpenSQLCipher3DatabaseTest());
tests.add(new MUTF8ToUTF8WithNullMigrationTest());
tests.add(new RawQuerySyntaxErrorMessageTest());
tests.add(new RawQueryNonsenseStatementErrorMessageTest());
tests.add(new RawQueryNoSuchFunctionErrorMessageTest());
tests.add(new CompileStatementSyntaxErrorMessageTest());
tests.add(new ExecuteInsertConstraintErrorMessageTest());
tests.add(new InsertWithOnConflictTest());
tests.add(new FTS5Test());
tests.add(new BindBooleanRawQueryTest());
tests.add(new BindStringRawQueryTest());
tests.add(new BindDoubleRawQueryTest());
tests.add(new BindLongRawQueryTest());
tests.add(new BindFloatRawQueryTest());
tests.add(new BindByteArrayRawQueryTest());
tests.add(new NullRawQueryTest());
tests.add(new ReadWriteDatabaseToExternalStorageTest());
return tests;
}
}