| 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:async'; | 4 import 'dart:async'; |
| 5 import 'dart:html' as html; | 5 import 'dart:html' as html; |
| 6 import 'dart:indexed_db' as idb; | 6 import 'dart:indexed_db' as idb; |
| 7 | 7 |
| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 var store = e.target.result.createObjectStore(storeName); | 45 var store = e.target.result.createObjectStore(storeName); |
| 46 expect(store, isNotNull); | 46 expect(store, isNotNull); |
| 47 } | 47 } |
| 48 | 48 |
| 49 var db; | 49 var db; |
| 50 return html.window.indexedDB.deleteDatabase(dbName).then((_) { | 50 return html.window.indexedDB.deleteDatabase(dbName).then((_) { |
| 51 return html.window.indexedDB.open(dbName, version: version, | 51 return html.window.indexedDB.open(dbName, version: version, |
| 52 onUpgradeNeeded: createObjectStore); | 52 onUpgradeNeeded: createObjectStore); |
| 53 }).then((result) { | 53 }).then((result) { |
| 54 db = result; | 54 db = result; |
| 55 var transaction = db.transactionList([storeName], 'readwrite'); | 55 var transaction = db.transaction([storeName], 'readwrite'); |
| 56 transaction.objectStore(storeName).put(value, key); | 56 transaction.objectStore(storeName).put(value, key); |
| 57 return transaction.completed; | 57 return transaction.completed; |
| 58 }).then((_) { | 58 }).then((_) { |
| 59 var transaction = db.transaction(storeName, 'readonly'); | 59 var transaction = db.transaction(storeName, 'readonly'); |
| 60 return transaction.objectStore(storeName).getObject(key); | 60 return transaction.objectStore(storeName).getObject(key); |
| 61 }).then((object) { | 61 }).then((object) { |
| 62 db.close(); | 62 db.close(); |
| 63 expect(object, matcher); | 63 expect(object, matcher); |
| 64 }).whenComplete(() { | 64 }).whenComplete(() { |
| 65 if (db != null) { | 65 if (db != null) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 79 expect(store, isNotNull); | 79 expect(store, isNotNull); |
| 80 } | 80 } |
| 81 | 81 |
| 82 idb.Database db; | 82 idb.Database db; |
| 83 // Delete any existing DBs. | 83 // Delete any existing DBs. |
| 84 return html.window.indexedDB.deleteDatabase(dbName).then((_) { | 84 return html.window.indexedDB.deleteDatabase(dbName).then((_) { |
| 85 return html.window.indexedDB.open(dbName, version: version, | 85 return html.window.indexedDB.open(dbName, version: version, |
| 86 onUpgradeNeeded: createObjectStore); | 86 onUpgradeNeeded: createObjectStore); |
| 87 }).then((idb.Database result) { | 87 }).then((idb.Database result) { |
| 88 db = result; | 88 db = result; |
| 89 idb.Transaction transaction = db.transactionList([storeName], 'readwrite')
; | 89 idb.Transaction transaction = db.transaction([storeName], 'readwrite'); |
| 90 transaction.objectStore(storeName).put(value, key); | 90 transaction.objectStore(storeName).put(value, key); |
| 91 | 91 |
| 92 return transaction.completed; | 92 return transaction.completed; |
| 93 }).then((idb.Database result) { | 93 }).then((idb.Database result) { |
| 94 idb.Transaction transaction = db.transaction(storeName, 'readonly'); | 94 idb.Transaction transaction = db.transaction(storeName, 'readonly'); |
| 95 return transaction.objectStore(storeName).getObject(key); | 95 return transaction.objectStore(storeName).getObject(key); |
| 96 }).then((object) { | 96 }).then((object) { |
| 97 db.close(); | 97 db.close(); |
| 98 expect(object, matcher); | 98 expect(object, matcher); |
| 99 }).whenComplete(() { | 99 }).whenComplete(() { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 test('upgrade', testUpgrade); | 149 test('upgrade', testUpgrade); |
| 150 group('dynamic', () { | 150 group('dynamic', () { |
| 151 testTypes(testReadWrite); | 151 testTypes(testReadWrite); |
| 152 }); | 152 }); |
| 153 group('typed', () { | 153 group('typed', () { |
| 154 testTypes(testReadWriteTyped); | 154 testTypes(testReadWriteTyped); |
| 155 }); | 155 }); |
| 156 } | 156 } |
| 157 }); | 157 }); |
| 158 } | 158 } |
| OLD | NEW |