| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 db.close(); | 98 db.close(); |
| 99 expect(object, matcher); | 99 expect(object, matcher); |
| 100 }).whenComplete(() { | 100 }).whenComplete(() { |
| 101 if (db != null) { | 101 if (db != null) { |
| 102 db.close(); | 102 db.close(); |
| 103 } | 103 } |
| 104 return html.window.indexedDB.deleteDatabase(dbName); | 104 return html.window.indexedDB.deleteDatabase(dbName); |
| 105 }); | 105 }); |
| 106 }; | 106 }; |
| 107 | 107 |
| 108 tests_dynamic() { | 108 void testTypes(testFunction) { |
| 109 test('test1', testReadWrite(123, 'Hoot!', equals('Hoot!'))); | 109 test('String', testFunction(123, 'Hoot!', equals('Hoot!'))); |
| 110 test('test2', testReadWrite(123, 12345, equals(12345))); | 110 test('int', testFunction(123, 12345, equals(12345))); |
| 111 test('test3', testReadWrite(123, [1, 2, 3], equals([1, 2, 3]))); | 111 test('List', testFunction(123, [1, 2, 3], equals([1, 2, 3]))); |
| 112 test('test4', testReadWrite(123, [2, 3, 4], equals([2, 3, 4]))); | 112 test('List 2', testFunction(123, [2, 3, 4], equals([2, 3, 4]))); |
| 113 test('test4', testReadWrite(123, false, equals(false))); | 113 test('bool', testFunction(123, [true, false], equals([true, false]))); |
| 114 } | 114 var now = new DateTime.now(); |
| 115 | 115 test('DateTime', testFunction(123, now, |
| 116 tests_typed() { | 116 predicate((date) => |
| 117 test('test1', testReadWriteTyped(123, 'Hoot!', equals('Hoot!'))); | 117 date.millisecondsSinceEpoch == now.millisecondsSinceEpoch))); |
| 118 test('test2', testReadWriteTyped(123, 12345, equals(12345))); | |
| 119 test('test3', testReadWriteTyped(123, [1, 2, 3], equals([1, 2, 3]))); | |
| 120 test('test4', testReadWriteTyped(123, [2, 3, 4], equals([2, 3, 4]))); | |
| 121 test('test4', testReadWriteTyped(123, false, equals(false))); | |
| 122 } | 118 } |
| 123 | 119 |
| 124 main() { | 120 main() { |
| 125 useHtmlIndividualConfiguration(); | 121 useHtmlIndividualConfiguration(); |
| 126 | 122 |
| 127 // Test that indexed_db is properly flagged as supported or not. | 123 // Test that indexed_db is properly flagged as supported or not. |
| 128 // Note that the rest of the indexed_db tests assume that this has been | 124 // Note that the rest of the indexed_db tests assume that this has been |
| 129 // checked. | 125 // checked. |
| 130 group('supported', () { | 126 group('supported', () { |
| 131 test('supported', () { | 127 test('supported', () { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 145 | 141 |
| 146 expect(() { | 142 expect(() { |
| 147 var db = html.window.indexedDB; | 143 var db = html.window.indexedDB; |
| 148 db.open('random_db'); | 144 db.open('random_db'); |
| 149 }, expectation); | 145 }, expectation); |
| 150 }); | 146 }); |
| 151 | 147 |
| 152 // Don't bother with these tests if it's unsupported. | 148 // Don't bother with these tests if it's unsupported. |
| 153 if (idb.IdbFactory.supported) { | 149 if (idb.IdbFactory.supported) { |
| 154 test('upgrade', testUpgrade); | 150 test('upgrade', testUpgrade); |
| 155 tests_dynamic(); | 151 group('dynamic', () { |
| 156 tests_typed(); | 152 testTypes(testReadWrite); |
| 153 }); |
| 154 group('typed', () { |
| 155 testTypes(testReadWriteTyped); |
| 156 }); |
| 157 } | 157 } |
| 158 }); | 158 }); |
| 159 } | 159 } |
| OLD | NEW |