1616
1717package android .database ;
1818
19- import android .database .AbstractCursor ;
2019import android .test .suitebuilder .annotation .SmallTest ;
21- import com .android .common .ArrayListCursor ;
2220import android .database .CursorWindow ;
2321import android .test .PerformanceTestCase ;
2422
25- import com .google .android .collect .Lists ;
26-
27- import java .util .ArrayList ;
2823import java .util .Arrays ;
29- import java .util .Random ;
3024
3125import junit .framework .TestCase ;
3226
@@ -40,48 +34,6 @@ public int startPerformance(Intermediates intermediates) {
4034 return 1 ;
4135 }
4236
43- @ SmallTest
44- public void testWriteCursorToWindow () throws Exception {
45- // create cursor
46- String [] colNames = new String []{"name" , "number" , "profit" };
47- int colsize = colNames .length ;
48- ArrayList <ArrayList > list = createTestList (10 , colsize );
49- AbstractCursor cursor = new ArrayListCursor (colNames , (ArrayList <ArrayList >) list );
50-
51- // fill window
52- CursorWindow window = new CursorWindow (false );
53- cursor .fillWindow (0 , window );
54-
55- // read from cursor window
56- for (int i = 0 ; i < list .size (); i ++) {
57- ArrayList <Integer > col = list .get (i );
58- for (int j = 0 ; j < colsize ; j ++) {
59- String s = window .getString (i , j );
60- int r2 = col .get (j );
61- int r1 = Integer .parseInt (s );
62- assertEquals (r2 , r1 );
63- }
64- }
65-
66- // test cursor window handle startpos != 0
67- window .clear ();
68- cursor .fillWindow (1 , window );
69- // read from cursor from window
70- for (int i = 1 ; i < list .size (); i ++) {
71- ArrayList <Integer > col = list .get (i );
72- for (int j = 0 ; j < colsize ; j ++) {
73- String s = window .getString (i , j );
74- int r2 = col .get (j );
75- int r1 = Integer .parseInt (s );
76- assertEquals (r2 , r1 );
77- }
78- }
79-
80- // Clear the window and make sure it's empty
81- window .clear ();
82- assertEquals (0 , window .getNumRows ());
83- }
84-
8537 @ SmallTest
8638 public void testValuesLocalWindow () {
8739 doTestValues (new CursorWindow (true ));
@@ -124,50 +76,4 @@ private void doTestValues(CursorWindow window) {
12476 assertTrue (window .putBlob (blob , 0 , 6 ));
12577 assertTrue (Arrays .equals (blob , window .getBlob (0 , 6 )));
12678 }
127-
128- @ SmallTest
129- public void testNull () {
130- CursorWindow window = getOneByOneWindow ();
131-
132- // Put in a null value and read it back as various types
133- assertTrue (window .putNull (0 , 0 ));
134- assertNull (window .getString (0 , 0 ));
135- assertEquals (0 , window .getLong (0 , 0 ));
136- assertEquals (0.0 , window .getDouble (0 , 0 ));
137- assertNull (window .getBlob (0 , 0 ));
138- }
139-
140- @ SmallTest
141- public void testEmptyString () {
142- CursorWindow window = getOneByOneWindow ();
143-
144- // put size 0 string and read it back as various types
145- assertTrue (window .putString ("" , 0 , 0 ));
146- assertEquals ("" , window .getString (0 , 0 ));
147- assertEquals (0 , window .getLong (0 , 0 ));
148- assertEquals (0.0 , window .getDouble (0 , 0 ));
149- }
150-
151- private CursorWindow getOneByOneWindow () {
152- CursorWindow window = new CursorWindow (false );
153- assertTrue (window .setNumColumns (1 ));
154- assertTrue (window .allocRow ());
155- return window ;
156- }
157-
158- private static ArrayList <ArrayList > createTestList (int rows , int cols ) {
159- ArrayList <ArrayList > list = Lists .newArrayList ();
160- Random generator = new Random ();
161-
162- for (int i = 0 ; i < rows ; i ++) {
163- ArrayList <Integer > col = Lists .newArrayList ();
164- list .add (col );
165- for (int j = 0 ; j < cols ; j ++) {
166- // generate random number
167- Integer r = generator .nextInt ();
168- col .add (r );
169- }
170- }
171- return list ;
172- }
17379}
0 commit comments