| OLD | NEW |
| 1 #library('IndexedDB1Test'); | 1 #library('IndexedDB1Test'); |
| 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 final String DB_NAME = 'Test'; | 6 final String DB_NAME = 'Test'; |
| 7 final String STORE_NAME = 'TEST'; | 7 final String STORE_NAME = 'TEST'; |
| 8 final String VERSION = '1'; | 8 final String VERSION = '1'; |
| 9 | 9 |
| 10 testReadWrite(key, value, check, | 10 testReadWrite(key, value, check, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 step2(e) { | 27 step2(e) { |
| 28 var transaction = db.transaction(storeName, 'readonly'); | 28 var transaction = db.transaction(storeName, 'readonly'); |
| 29 var request = transaction.objectStore(storeName).getObject(key); | 29 var request = transaction.objectStore(storeName).getObject(key); |
| 30 request.on.success.add(expectAsync1((e) { | 30 request.on.success.add(expectAsync1((e) { |
| 31 var object = e.target.result; | 31 var object = e.target.result; |
| 32 check(value, object); | 32 check(value, object); |
| 33 })); | 33 })); |
| 34 request.on.error.add(fail); | 34 request.on.error.add(fail); |
| 35 } | 35 } |
| 36 | 36 |
| 37 step1([e]) { | 37 step1() { |
| 38 var transaction = db.transaction([storeName], 'readwrite'); | 38 var transaction = db.transaction([storeName], 'readwrite'); |
| 39 var request = transaction.objectStore(storeName).put(value, key); | 39 var request = transaction.objectStore(storeName).put(value, key); |
| 40 request.on.success.add(expectAsync1(step2)); | 40 request.on.success.add(expectAsync1(step2)); |
| 41 request.on.error.add(fail); | 41 request.on.error.add(fail); |
| 42 } | 42 } |
| 43 | 43 |
| 44 initDb(e) { | 44 initDb(e) { |
| 45 db = e.target.result; | 45 db = e.target.result; |
| 46 if (version != db.version) { | 46 if (version != db.version) { |
| 47 // TODO. Some browsers do this the w3 way - passing the version to the | 47 // TODO. Some browsers do this the w3 way - passing the version to the |
| 48 // open call and listening to onversionchange. Can we feature-detect the | 48 // open call and listening to onversionchange. Can we feature-detect the |
| 49 // difference and make it work? | 49 // difference and make it work? |
| 50 var request = db.setVersion(version); | 50 var request = db.setVersion(version); |
| 51 request.on.success.add( | 51 request.on.success.add( |
| 52 expectAsync1((e) { | 52 expectAsync1((e) { |
| 53 createObjectStore(); | 53 createObjectStore(); |
| 54 | 54 |
| 55 var transaction = e.target.result; | 55 var transaction = e.target.result; |
| 56 transaction.on.complete.add(expectAsync1(step1)); | 56 transaction.on.complete.add(expectAsync1((e) => step1())); |
| 57 transaction.on.error.add(fail); | 57 transaction.on.error.add(fail); |
| 58 }) | 58 }) |
| 59 ); | 59 ); |
| 60 request.on.error.add(fail); | 60 request.on.error.add(fail); |
| 61 } else { | 61 } else { |
| 62 step1(); | 62 step1(); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 | 65 |
| 66 var request = window.indexedDB.open(dbName); | 66 var request = window.indexedDB.open(dbName); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 test('test4', | 140 test('test4', |
| 141 testReadWriteTyped(123, const [2, 3, 4], Expect.listEquals)); | 141 testReadWriteTyped(123, const [2, 3, 4], Expect.listEquals)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 main() { | 144 main() { |
| 145 useHtmlConfiguration(); | 145 useHtmlConfiguration(); |
| 146 | 146 |
| 147 tests_dynamic(); | 147 tests_dynamic(); |
| 148 tests_typed(); | 148 tests_typed(); |
| 149 } | 149 } |
| OLD | NEW |