| OLD | NEW |
| 1 library IndexedDB1Test; | 1 library IndexedDB1Test; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_individual_config.dart'; | 3 import '../../pkg/unittest/lib/html_individual_config.dart'; |
| 4 import 'dart:html' as html; | 4 import 'dart:html' as html; |
| 5 import 'dart:indexed_db' as idb; | 5 import 'dart:indexed_db' as idb; |
| 6 | 6 |
| 7 const String DB_NAME = 'Test'; | 7 const String DB_NAME = 'Test'; |
| 8 const String STORE_NAME = 'TEST'; | 8 const String STORE_NAME = 'TEST'; |
| 9 const int VERSION = 1; | 9 const int VERSION = 1; |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 var object = e.target.result; | 32 var object = e.target.result; |
| 33 db.close(); | 33 db.close(); |
| 34 expect(object, matcher); | 34 expect(object, matcher); |
| 35 })); | 35 })); |
| 36 request.onError.listen(fail); | 36 request.onError.listen(fail); |
| 37 } | 37 } |
| 38 | 38 |
| 39 step1() { | 39 step1() { |
| 40 var transaction = db.transaction([storeName], 'readwrite'); | 40 var transaction = db.transaction([storeName], 'readwrite'); |
| 41 var request = transaction.objectStore(storeName).put(value, key); | 41 var request = transaction.objectStore(storeName).put(value, key); |
| 42 request.onSuccess.listen(expectAsync1(step2)); | |
| 43 request.onError.listen(fail); | 42 request.onError.listen(fail); |
| 43 |
| 44 transaction.onComplete.listen(expectAsync1(step2)); |
| 44 } | 45 } |
| 45 | 46 |
| 46 initDb(e) { | 47 initDb(e) { |
| 47 db = e.target.result; | 48 db = e.target.result; |
| 48 if (version != db.version) { | 49 if (version != db.version) { |
| 49 // Legacy 'setVersion' upgrade protocol. Chrome 23 and earlier. | 50 // Legacy 'setVersion' upgrade protocol. Chrome 23 and earlier. |
| 50 var request = db.setVersion('$version'); | 51 var request = db.setVersion('$version'); |
| 51 request.onSuccess.listen( | 52 request.onSuccess.listen( |
| 52 expectAsync1((e) { | 53 expectAsync1((e) { |
| 53 createObjectStore(db); | 54 createObjectStore(db); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 var object = e.target.result; | 109 var object = e.target.result; |
| 109 db.close(); | 110 db.close(); |
| 110 expect(object, matcher); | 111 expect(object, matcher); |
| 111 })); | 112 })); |
| 112 request.onError.listen(fail); | 113 request.onError.listen(fail); |
| 113 } | 114 } |
| 114 | 115 |
| 115 step1() { | 116 step1() { |
| 116 idb.Transaction transaction = db.transaction([storeName], 'readwrite'); | 117 idb.Transaction transaction = db.transaction([storeName], 'readwrite'); |
| 117 idb.Request request = transaction.objectStore(storeName).put(value, key); | 118 idb.Request request = transaction.objectStore(storeName).put(value, key); |
| 118 request.onSuccess.listen(expectAsync1(step2)); | |
| 119 request.onError.listen(fail); | 119 request.onError.listen(fail); |
| 120 |
| 121 transaction.onComplete.listen(expectAsync1(step2)); |
| 120 } | 122 } |
| 121 | 123 |
| 122 initDb(e) { | 124 initDb(e) { |
| 123 db = e.target.result; | 125 db = e.target.result; |
| 124 if (version != db.version) { | 126 if (version != db.version) { |
| 125 // Legacy 'setVersion' upgrade protocol. | 127 // Legacy 'setVersion' upgrade protocol. |
| 126 idb.Request request = db.setVersion('$version'); | 128 idb.Request request = db.setVersion('$version'); |
| 127 request.onSuccess.listen( | 129 request.onSuccess.listen( |
| 128 expectAsync1((e) { | 130 expectAsync1((e) { |
| 129 createObjectStore(db); | 131 createObjectStore(db); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 var db = html.window.indexedDB; | 197 var db = html.window.indexedDB; |
| 196 }, expectation); | 198 }, expectation); |
| 197 }); | 199 }); |
| 198 | 200 |
| 199 // Don't bother with these tests if it's unsupported. | 201 // Don't bother with these tests if it's unsupported. |
| 200 if (idb.IdbFactory.supported) { | 202 if (idb.IdbFactory.supported) { |
| 201 tests_dynamic(); | 203 tests_dynamic(); |
| 202 tests_typed(); | 204 tests_typed(); |
| 203 } | 205 } |
| 204 } | 206 } |
| OLD | NEW |