Chromium Code Reviews| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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, 'readonly'); | 86 IDBTransaction txn = db.transaction(STORE_NAME, 'readonly'); |
| 87 IDBObjectStore objectStore = txn.objectStore(STORE_NAME); | 87 IDBObjectStore objectStore = txn.objectStore(STORE_NAME); |
| 88 IDBRequest cursorRequest = objectStore.openCursor(new IDBKeyRange.bound(0, 1 00), 'prev'); | 88 // TODO: create a IDBKeyRange(0,100) |
| 89 IDBRequest cursorRequest = objectStore.openCursor(null, 'prev'); | |
|
podivilov
2012/06/06 13:26:08
Reverted to initial state.
| |
| 89 int itemCount = 0; | 90 int itemCount = 0; |
| 90 int sumKeys = 0; | 91 int sumKeys = 0; |
| 91 int lastKey = null; | 92 int lastKey = null; |
| 92 cursorRequest.on.success.add(expectAsync1((e) { | 93 cursorRequest.on.success.add(expectAsync1((e) { |
| 93 var cursor = e.target.result; | 94 var cursor = e.target.result; |
| 94 if (cursor != null) { | 95 if (cursor != null) { |
| 95 lastKey = cursor.key; | 96 lastKey = cursor.key; |
| 96 itemCount += 1; | 97 itemCount += 1; |
| 97 sumKeys += cursor.key; | 98 sumKeys += cursor.key; |
| 98 Expect.equals('Item ${cursor.key}', cursor.value); | 99 Expect.equals('Item ${cursor.key}', cursor.value); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 109 } | 110 } |
| 110 | 111 |
| 111 main() { | 112 main() { |
| 112 useHtmlConfiguration(); | 113 useHtmlConfiguration(); |
| 113 | 114 |
| 114 var test_ = new Test(); | 115 var test_ = new Test(); |
| 115 test('prepare', test_.start); | 116 test('prepare', test_.start); |
| 116 test('readAll1', test_.readAllViaCursor); | 117 test('readAll1', test_.readAllViaCursor); |
| 117 test('readAll2', test_.readAllReversedViaCursor); | 118 test('readAll2', test_.readAllReversedViaCursor); |
| 118 } | 119 } |
| OLD | NEW |