| 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 #import('dart:coreimpl'); | 5 #import('dart:coreimpl'); |
| 6 #import('utils.dart'); | 6 #import('utils.dart'); |
| 7 | 7 |
| 8 // Write and re-read Maps: simple Maps; Maps with DAGs; Maps with cycles. | 8 // Write and re-read Maps: simple Maps; Maps with DAGs; Maps with cycles. |
| 9 | 9 |
| 10 final String DB_NAME = 'Test'; | 10 final String DB_NAME = 'Test'; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 var transaction = db.transaction(storeName, 'readonly'); | 32 var transaction = db.transaction(storeName, 'readonly'); |
| 33 var request = transaction.objectStore(storeName).getObject(key); | 33 var request = transaction.objectStore(storeName).getObject(key); |
| 34 request.on.success.add(expectAsync1((e) { | 34 request.on.success.add(expectAsync1((e) { |
| 35 var object = e.target.result; | 35 var object = e.target.result; |
| 36 check(value, object); | 36 check(value, object); |
| 37 }) | 37 }) |
| 38 ); | 38 ); |
| 39 request.on.error.add(fail); | 39 request.on.error.add(fail); |
| 40 } | 40 } |
| 41 | 41 |
| 42 step1() { | 42 step1([e]) { |
| 43 var transaction = db.transaction([storeName], 'readwrite'); | 43 var transaction = db.transaction([storeName], 'readwrite'); |
| 44 var request = transaction.objectStore(storeName).put(value, key); | 44 var request = transaction.objectStore(storeName).put(value, key); |
| 45 request.on.success.add(expectAsync1(step2)); | 45 request.on.success.add(expectAsync1(step2)); |
| 46 request.on.error.add(fail); | 46 request.on.error.add(fail); |
| 47 } | 47 } |
| 48 | 48 |
| 49 initDb(e) { | 49 initDb(e) { |
| 50 db = e.target.result; | 50 db = e.target.result; |
| 51 if (version != db.version) { | 51 if (version != db.version) { |
| 52 // TODO. Some browsers do this the w3 way - passing the version to the | 52 // TODO. Some browsers do this the w3 way - passing the version to the |
| 53 // open call and listening to onversionchange. Can we feature-detect the | 53 // open call and listening to onversionchange. Can we feature-detect the |
| 54 // difference and make it work? | 54 // difference and make it work? |
| 55 var request = db.setVersion(version); | 55 var request = db.setVersion(version); |
| 56 request.on.success.add( | 56 request.on.success.add( |
| 57 expectAsync1((e) { | 57 expectAsync1((e) { |
| 58 createObjectStore(); | 58 createObjectStore(); |
| 59 step1(); | 59 |
| 60 var transaction = e.target.result; |
| 61 transaction.on.complete.add(expectAsync1(step1)); |
| 62 transaction.on.error.add(fail); |
| 60 }) | 63 }) |
| 61 ); | 64 ); |
| 62 request.on.error.add(fail); | 65 request.on.error.add(fail); |
| 63 } else { | 66 } else { |
| 64 step1(); | 67 step1(); |
| 65 } | 68 } |
| 66 } | 69 } |
| 67 | 70 |
| 68 var request = window.indexedDB.open(dbName); | 71 var request = window.indexedDB.open(dbName); |
| 69 Expect.isNotNull(request); | 72 Expect.isNotNull(request); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 88 test('test_DAG', testReadWrite(123, obj2, verifyGraph)); | 91 test('test_DAG', testReadWrite(123, obj2, verifyGraph)); |
| 89 test('test_cycle', testReadWrite(123, obj3, verifyGraph)); | 92 test('test_cycle', testReadWrite(123, obj3, verifyGraph)); |
| 90 test('test_simple_splay', testReadWrite(123, obj4, verifyGraph)); | 93 test('test_simple_splay', testReadWrite(123, obj4, verifyGraph)); |
| 91 } | 94 } |
| 92 | 95 |
| 93 main() { | 96 main() { |
| 94 useHtmlConfiguration(); | 97 useHtmlConfiguration(); |
| 95 | 98 |
| 96 tests_dynamic(); | 99 tests_dynamic(); |
| 97 } | 100 } |
| OLD | NEW |