| OLD | NEW |
| 1 #library('IndexedDB4Test'); | 1 #library('IndexedDB4Test'); |
| 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 // Test for IDBKeyRange and IDBCursor. | 6 // Test for IDBKeyRange and IDBCursor. |
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 guardAsync(() { | 56 guardAsync(() { |
| 57 Expect.fail('IndexedDB failure: $message'); | 57 Expect.fail('IndexedDB failure: $message'); |
| 58 }); | 58 }); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 testRange(range, expectedFirst, expectedLast) { | 61 testRange(range, expectedFirst, expectedLast) { |
| 62 IDBTransaction txn = db.transaction(STORE_NAME, 'readonly'); | 62 IDBTransaction txn = db.transaction(STORE_NAME, 'readonly'); |
| 63 IDBObjectStore objectStore = txn.objectStore(STORE_NAME); | 63 IDBObjectStore objectStore = txn.objectStore(STORE_NAME); |
| 64 IDBRequest cursorRequest = objectStore.openCursor(range); | 64 IDBRequest cursorRequest = objectStore.openCursor(range); |
| 65 int itemCount = 0; | 65 int itemCount = 0; |
| 66 num firstKey = null; | 66 int firstKey = null; |
| 67 num lastKey = null; | 67 int lastKey = null; |
| 68 cursorRequest.on.success.add(expectAsync1((e) { | 68 cursorRequest.on.success.add(expectAsync1((e) { |
| 69 var cursor = e.target.result; | 69 var cursor = e.target.result; |
| 70 if (cursor != null) { | 70 if (cursor != null) { |
| 71 if (firstKey == null) firstKey = cursor.key; | 71 if (firstKey == null) firstKey = cursor.key; |
| 72 lastKey = cursor.key; | 72 lastKey = cursor.key; |
| 73 itemCount += 1; | 73 itemCount += 1; |
| 74 Expect.equals('Item ${cursor.key.toStringAsFixed(0)}', cursor.value); | 74 Expect.equals('Item ${cursor.key}', cursor.value); |
| 75 cursor.continueFunction(); | 75 cursor.continueFunction(); |
| 76 } else { | 76 } else { |
| 77 // Done | 77 // Done |
| 78 Expect.equals(expectedFirst, firstKey); | 78 Expect.equals(expectedFirst, firstKey); |
| 79 Expect.equals(expectedLast, lastKey); | 79 Expect.equals(expectedLast, lastKey); |
| 80 if (expectedFirst == null) { | 80 if (expectedFirst == null) { |
| 81 Expect.equals(0, itemCount); | 81 Expect.equals(0, itemCount); |
| 82 } else { | 82 } else { |
| 83 Expect.equals(expectedLast - expectedFirst + 1, itemCount); | 83 Expect.equals(expectedLast - expectedFirst + 1, itemCount); |
| 84 } | 84 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 test('upper1', test_.upper1); | 136 test('upper1', test_.upper1); |
| 137 test('upper2', test_.upper2); | 137 test('upper2', test_.upper2); |
| 138 test('upper3', test_.upper3); | 138 test('upper3', test_.upper3); |
| 139 | 139 |
| 140 test('bound1', test_.bound1); | 140 test('bound1', test_.bound1); |
| 141 test('bound2', test_.bound2); | 141 test('bound2', test_.bound2); |
| 142 test('bound3', test_.bound3); | 142 test('bound3', test_.bound3); |
| 143 test('bound4', test_.bound4); | 143 test('bound4', test_.bound4); |
| 144 test('bound5', test_.bound5); | 144 test('bound5', test_.bound5); |
| 145 } | 145 } |
| OLD | NEW |