| OLD | NEW | 
|---|
| 1 #library('IndexedDB3Test'); | 1 #library('IndexedDB3Test'); | 
| 2 #import('../../lib/unittest/unittest.dart'); | 2 #import('../../lib/unittest/unittest.dart'); | 
| 3 #import('../../lib/unittest/html_config.dart'); | 3 #import('../../lib/unittest/html_config.dart'); | 
| 4 #import('dart:html'); | 4 #import('dart:html'); | 
| 5 | 5 | 
| 6 // Read with cursor. | 6 // Read with cursor. | 
| 7 | 7 | 
| 8 final String DB_NAME = 'Test'; | 8 final String DB_NAME = 'Test'; | 
| 9 final String STORE_NAME = 'TEST'; | 9 final String STORE_NAME = 'TEST'; | 
| 10 final String VERSION = '1'; | 10 final String VERSION = '1'; | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 63     IDBRequest cursorRequest = objectStore.openCursor(); | 63     IDBRequest cursorRequest = objectStore.openCursor(); | 
| 64     int itemCount = 0; | 64     int itemCount = 0; | 
| 65     int sumKeys = 0; | 65     int sumKeys = 0; | 
| 66     int lastKey = null; | 66     int lastKey = null; | 
| 67     cursorRequest.on.success.add(expectAsync1((e) { | 67     cursorRequest.on.success.add(expectAsync1((e) { | 
| 68       var cursor = e.target.result; | 68       var cursor = e.target.result; | 
| 69       if (cursor != null) { | 69       if (cursor != null) { | 
| 70         lastKey = cursor.key; | 70         lastKey = cursor.key; | 
| 71         itemCount += 1; | 71         itemCount += 1; | 
| 72         sumKeys += cursor.key; | 72         sumKeys += cursor.key; | 
| 73         Expect.equals('Item ${cursor.key.toStringAsFixed(0)}', cursor.value); | 73         Expect.equals('Item ${cursor.key}', cursor.value); | 
| 74         cursor.continueFunction(); | 74         cursor.continueFunction(); | 
| 75       } else { | 75       } else { | 
| 76         // Done | 76         // Done | 
| 77         Expect.equals(99, lastKey); | 77         Expect.equals(99, lastKey); | 
| 78         Expect.equals(100, itemCount); | 78         Expect.equals(100, itemCount); | 
| 79         Expect.equals((100 * 99) ~/ 2, sumKeys); | 79         Expect.equals((100 * 99) ~/ 2, sumKeys); | 
| 80       } | 80       } | 
| 81     }, count:101)); | 81     }, count:101)); | 
| 82     cursorRequest.on.error.add(fail('openCursor')); | 82     cursorRequest.on.error.add(fail('openCursor')); | 
| 83   } | 83   } | 
| 84 | 84 | 
| 85   readAllReversedViaCursor() { | 85   readAllReversedViaCursor() { | 
| 86     IDBTransaction txn = db.transaction(STORE_NAME, IDBTransaction.READ_ONLY); | 86     IDBTransaction txn = db.transaction(STORE_NAME, 'readonly'); | 
| 87     IDBObjectStore objectStore = txn.objectStore(STORE_NAME); | 87     IDBObjectStore objectStore = txn.objectStore(STORE_NAME); | 
| 88     // TODO: create a IDBKeyRange(0,100) | 88     IDBRequest cursorRequest = objectStore.openCursor(new IDBKeyRange.bound(0, 1
     00), 'prev'); | 
| 89     IDBRequest cursorRequest = objectStore.openCursor(null, IDBCursor.PREV); |  | 
| 90     int itemCount = 0; | 89     int itemCount = 0; | 
| 91     int sumKeys = 0; | 90     int sumKeys = 0; | 
| 92     int lastKey = null; | 91     int lastKey = null; | 
| 93     cursorRequest.on.success.add(expectAsync1((e) { | 92     cursorRequest.on.success.add(expectAsync1((e) { | 
| 94       var cursor = e.target.result; | 93       var cursor = e.target.result; | 
| 95       if (cursor != null) { | 94       if (cursor != null) { | 
| 96         lastKey = cursor.key; | 95         lastKey = cursor.key; | 
| 97         itemCount += 1; | 96         itemCount += 1; | 
| 98         sumKeys += cursor.key; | 97         sumKeys += cursor.key; | 
| 99         Expect.equals('Item ${cursor.key}', cursor.value); | 98         Expect.equals('Item ${cursor.key}', cursor.value); | 
| (...skipping 10 matching lines...) Expand all  Loading... | 
| 110 } | 109 } | 
| 111 | 110 | 
| 112 main() { | 111 main() { | 
| 113   useHtmlConfiguration(); | 112   useHtmlConfiguration(); | 
| 114 | 113 | 
| 115   var test_ = new Test(); | 114   var test_ = new Test(); | 
| 116   test('prepare', test_.start); | 115   test('prepare', test_.start); | 
| 117   test('readAll1', test_.readAllViaCursor); | 116   test('readAll1', test_.readAllViaCursor); | 
| 118   test('readAll2', test_.readAllReversedViaCursor); | 117   test('readAll2', test_.readAllReversedViaCursor); | 
| 119 } | 118 } | 
| OLD | NEW | 
|---|