| OLD | NEW |
| 1 library IndexedDB4Test; | 1 library IndexedDB4Test; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_config.dart'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 import 'dart:indexed_db'; | 5 import 'dart:indexed_db'; |
| 6 | 6 |
| 7 // Test for KeyRange and Cursor. | 7 // Test for KeyRange and Cursor. |
| 8 | 8 |
| 9 const String DB_NAME = 'Test'; | 9 const String DB_NAME = 'Test'; |
| 10 const String STORE_NAME = 'TEST'; | 10 const String STORE_NAME = 'TEST'; |
| 11 const int VERSION = 1; | 11 const int VERSION = 1; |
| 12 | 12 |
| 13 class Test { | 13 class Test { |
| 14 fail(message) => (e) { | 14 fail(message) => (e) { |
| 15 guardAsync(() { | 15 guardAsync(() { |
| 16 expect(false, isTrue, reason: 'IndexedDB failure: $message'); | 16 expect(false, isTrue, reason: 'IndexedDB failure: $message'); |
| 17 }); | 17 }); |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 _createObjectStore(db) { | 20 _createObjectStore(db) { |
| 21 try { | 21 try { |
| 22 // Nuke object store if it already exists. | 22 // Nuke object store if it already exists. |
| 23 db.deleteObjectStore(STORE_NAME); | 23 db.deleteObjectStore(STORE_NAME); |
| 24 } | 24 } |
| 25 on DatabaseException catch(e) { } // Chrome | 25 on DatabaseException catch(e) { } // Chrome |
| 26 on DOMException catch(e) { } // Firefox | 26 on DomException catch(e) { } // Firefox |
| 27 db.createObjectStore(STORE_NAME); | 27 db.createObjectStore(STORE_NAME); |
| 28 } | 28 } |
| 29 | 29 |
| 30 var db; | 30 var db; |
| 31 | 31 |
| 32 _openDb(afterOpen()) { | 32 _openDb(afterOpen()) { |
| 33 var request = window.indexedDB.open(DB_NAME, VERSION); | 33 var request = window.indexedDB.open(DB_NAME, VERSION); |
| 34 if (request is OpenDBRequest) { | 34 if (request is OpenDBRequest) { |
| 35 // New upgrade protocol. | 35 // New upgrade protocol. |
| 36 request.on.success.add(expectAsync1((e) { | 36 request.on.success.add(expectAsync1((e) { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 test('upper1', test_.upper1); | 172 test('upper1', test_.upper1); |
| 173 test('upper2', test_.upper2); | 173 test('upper2', test_.upper2); |
| 174 test('upper3', test_.upper3); | 174 test('upper3', test_.upper3); |
| 175 | 175 |
| 176 test('bound1', test_.bound1); | 176 test('bound1', test_.bound1); |
| 177 test('bound2', test_.bound2); | 177 test('bound2', test_.bound2); |
| 178 test('bound3', test_.bound3); | 178 test('bound3', test_.bound3); |
| 179 test('bound4', test_.bound4); | 179 test('bound4', test_.bound4); |
| 180 test('bound5', test_.bound5); | 180 test('bound5', test_.bound5); |
| 181 } | 181 } |
| OLD | NEW |