17
17
package net .zetetic .database .database_cts ;
18
18
19
19
import android .database .CharArrayBuffer ;
20
- import android .database .CursorWindow ;
21
- import android .database .MatrixCursor ;
22
20
import android .database .sqlite .SQLiteException ;
23
- import android .os .Parcel ;
24
21
import android .test .AndroidTestCase ;
25
22
23
+ import net .zetetic .database .CursorWindow ;
24
+ import net .zetetic .database .MatrixCursor ;
25
+
26
+ import org .junit .Before ;
27
+
26
28
import java .util .ArrayList ;
27
29
import java .util .Arrays ;
28
30
import java .util .Random ;
@@ -31,6 +33,11 @@ public class CursorWindowTest extends AndroidTestCase {
31
33
32
34
private static final String TEST_STRING = "Test String" ;
33
35
36
+ @ Before
37
+ public void setUp () {
38
+ System .loadLibrary ("sqlcipher" );
39
+ }
40
+
34
41
public void testWriteCursorToWindow () throws Exception {
35
42
// create cursor
36
43
String [] colNames = new String []{"_id" , "name" , "number" , "profit" };
@@ -42,7 +49,7 @@ public void testWriteCursorToWindow() throws Exception {
42
49
}
43
50
44
51
// fill window
45
- CursorWindow window = new CursorWindow (false );
52
+ CursorWindow window = new CursorWindow ("" );
46
53
cursor .fillWindow (0 , window );
47
54
48
55
// read from cursor window
@@ -97,34 +104,13 @@ public void testEmptyString() {
97
104
}
98
105
99
106
public void testConstructors () {
100
- int TEST_NUMBER = 5 ;
101
- CursorWindow cursorWindow ;
102
-
103
107
// Test constructor with 'true' input, and getStartPosition should return 0
104
- cursorWindow = new CursorWindow (true );
105
- assertEquals (0 , cursorWindow .getStartPosition ());
106
-
107
- // Test constructor with 'false' input
108
- cursorWindow = new CursorWindow (false );
108
+ CursorWindow cursorWindow = new CursorWindow ("" );
109
109
assertEquals (0 , cursorWindow .getStartPosition ());
110
-
111
- // Test newFromParcel
112
- Parcel parcel = Parcel .obtain ();
113
- cursorWindow = new CursorWindow (true );
114
- cursorWindow .setStartPosition (TEST_NUMBER );
115
- cursorWindow .setNumColumns (1 );
116
- cursorWindow .allocRow ();
117
- cursorWindow .putString (TEST_STRING , TEST_NUMBER , 0 );
118
- cursorWindow .writeToParcel (parcel , 0 );
119
-
120
- parcel .setDataPosition (0 );
121
- cursorWindow = CursorWindow .CREATOR .createFromParcel (parcel );
122
- assertEquals (TEST_NUMBER , cursorWindow .getStartPosition ());
123
- assertEquals (TEST_STRING , cursorWindow .getString (TEST_NUMBER , 0 ));
124
110
}
125
111
126
112
public void testDataStructureOperations () {
127
- CursorWindow cursorWindow = new CursorWindow (true );
113
+ CursorWindow cursorWindow = new CursorWindow ("" );
128
114
129
115
// Test with normal values
130
116
assertTrue (cursorWindow .setNumColumns (0 ));
@@ -145,7 +131,7 @@ public void testDataStructureOperations() {
145
131
cursorWindow .freeLastRow ();
146
132
assertEquals (0 , cursorWindow .getNumRows ());
147
133
148
- cursorWindow = new CursorWindow (true );
134
+ cursorWindow = new CursorWindow ("" );
149
135
assertTrue (cursorWindow .setNumColumns (6 ));
150
136
assertTrue (cursorWindow .allocRow ());
151
137
// Column number set to negative number, so now can put values.
@@ -190,7 +176,7 @@ public void testAccessDataValues() {
190
176
originalBlob [i ] = (byte ) i ;
191
177
}
192
178
193
- CursorWindow cursorWindow = new CursorWindow (true );
179
+ CursorWindow cursorWindow = new CursorWindow ("" );
194
180
cursorWindow .setNumColumns (5 );
195
181
cursorWindow .allocRow ();
196
182
@@ -280,15 +266,15 @@ public void testAccessDataValues() {
280
266
}
281
267
282
268
public void testCopyStringToBuffer () {
283
- int DEFAULT_ARRAY_LENGTH = 64 ;
269
+ int DEFAULT_ARRAY_LENGTH = 60 ;
284
270
String baseString = "0123456789" ;
285
271
String expectedString = "" ;
286
272
// Create a 60 characters string.
287
273
for (int i = 0 ; i < 6 ; i ++) {
288
274
expectedString += baseString ;
289
275
}
290
276
CharArrayBuffer charArrayBuffer = new CharArrayBuffer (null );
291
- CursorWindow cursorWindow = new CursorWindow (true );
277
+ CursorWindow cursorWindow = new CursorWindow ("" );
292
278
cursorWindow .setNumColumns (2 );
293
279
cursorWindow .allocRow ();
294
280
@@ -318,7 +304,7 @@ public void testAccessStartPosition() {
318
304
final int TEST_POSITION_1 = 0 ;
319
305
final int TEST_POSITION_2 = 3 ;
320
306
321
- CursorWindow cursorWindow = new CursorWindow (true );
307
+ CursorWindow cursorWindow = new CursorWindow ("" );
322
308
fillCursorTestContents (cursorWindow , 5 );
323
309
324
310
// Test setStartPosition
@@ -369,16 +355,11 @@ public void testClearAndOnAllReferencesReleased() {
369
355
assertTrue (cursorWindow .hasReleasedAllReferences ());
370
356
}
371
357
372
- public void testDescribeContents () {
373
- CursorWindow cursorWindow = new CursorWindow (true );
374
- assertEquals (0 , cursorWindow .describeContents ());
375
- }
376
-
377
358
private class MockCursorWindow extends CursorWindow {
378
359
private boolean mHasReleasedAllReferences = false ;
379
360
380
361
public MockCursorWindow (boolean localWindow ) {
381
- super (localWindow );
362
+ super ("" );
382
363
}
383
364
384
365
@ Override
@@ -426,7 +407,7 @@ private static ArrayList<ArrayList<Integer>> createTestList(int rows, int cols)
426
407
* The method comes from unit_test CursorWindowTest.
427
408
*/
428
409
private CursorWindow getOneByOneWindow () {
429
- CursorWindow window = new CursorWindow (false );
410
+ CursorWindow window = new CursorWindow ("" );
430
411
assertTrue (window .setNumColumns (1 ));
431
412
assertTrue (window .allocRow ());
432
413
return window ;
0 commit comments