Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 library IndexedDB4Test; | 1 library IndexedDB4Test; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_config.dart'; | 3 import '../../pkg/unittest/lib/html_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'; | 6 import 'dart:indexed_db'; |
| 7 import 'utils.dart'; | 7 import 'utils.dart'; |
|
Emily Fortuna
2013/03/04 22:48:37
we probably don't need this import in these files
blois
2013/03/05 01:11:37
Done.
| |
| 8 | 8 |
| 9 // Test for KeyRange and Cursor. | 9 // Test for KeyRange and Cursor. |
| 10 | 10 |
| 11 const String DB_NAME = 'Test'; | 11 const String DB_NAME = 'Test'; |
| 12 const String STORE_NAME = 'TEST'; | 12 const String STORE_NAME = 'TEST'; |
| 13 const int VERSION = 1; | 13 const int VERSION = 1; |
| 14 | 14 |
| 15 Future<Database> createAndOpenDb() { | 15 Future<Database> createAndOpenDb() { |
| 16 return html.window.indexedDB.deleteDatabase(DB_NAME).then((_) { | 16 return html.window.indexedDB.deleteDatabase(DB_NAME).then((_) { |
| 17 return html.window.indexedDB.open(DB_NAME, version: VERSION, | 17 return html.window.indexedDB.open(DB_NAME, version: VERSION, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 }); | 75 }); |
| 76 } | 76 } |
| 77 | 77 |
| 78 main() { | 78 main() { |
| 79 useHtmlConfiguration(); | 79 useHtmlConfiguration(); |
| 80 | 80 |
| 81 // Don't bother with these tests if it's unsupported. | 81 // Don't bother with these tests if it's unsupported. |
| 82 // Support is tested in indexeddb_1_test | 82 // Support is tested in indexeddb_1_test |
| 83 if (IdbFactory.supported) { | 83 if (IdbFactory.supported) { |
| 84 var db; | 84 var db; |
| 85 futureTest('prepare', () { | 85 test('prepare', () { |
| 86 return setupDb().then((result) { | 86 return setupDb().then((result) { |
| 87 db = result; | 87 db = result; |
| 88 }); | 88 }); |
| 89 }); | 89 }); |
| 90 | 90 |
| 91 futureTest('only1', () => testRange(db, new KeyRange.only(55), 55, 55)); | 91 test('only1', () => testRange(db, new KeyRange.only(55), 55, 55)); |
| 92 | 92 |
| 93 futureTest('only1', () => testRange(db, new KeyRange.only(55), 55, 55)); | 93 test('only1', () => testRange(db, new KeyRange.only(55), 55, 55)); |
| 94 futureTest('only2', () => testRange(db, new KeyRange.only(100), null, null)) ; | 94 test('only2', () => testRange(db, new KeyRange.only(100), null, null)); |
| 95 futureTest('only3', () => testRange(db, new KeyRange.only(-1), null, null)); | 95 test('only3', () => testRange(db, new KeyRange.only(-1), null, null)); |
| 96 | 96 |
| 97 futureTest('lower1', () => | 97 test('lower1', () => |
| 98 testRange(db, new KeyRange.lowerBound(40), 40, 99)); | 98 testRange(db, new KeyRange.lowerBound(40), 40, 99)); |
| 99 // OPTIONALS lower2() => testRange(db, new KeyRange.lowerBound(40, open: tru e), 41, 99); | 99 // OPTIONALS lower2() => testRange(db, new KeyRange.lowerBound(40, open: tru e), 41, 99); |
| 100 futureTest('lower2', () => | 100 test('lower2', () => |
| 101 testRange(db, new KeyRange.lowerBound(40, true), 41, 99)); | 101 testRange(db, new KeyRange.lowerBound(40, true), 41, 99)); |
| 102 // OPTIONALS lower3() => testRange(db, new KeyRange.lowerBound(40, open: fal se), 40, 99); | 102 // OPTIONALS lower3() => testRange(db, new KeyRange.lowerBound(40, open: fal se), 40, 99); |
| 103 futureTest('lower3', () => | 103 test('lower3', () => |
| 104 testRange(db, new KeyRange.lowerBound(40, false), 40, 99)); | 104 testRange(db, new KeyRange.lowerBound(40, false), 40, 99)); |
| 105 | 105 |
| 106 futureTest('upper1', () => | 106 test('upper1', () => |
| 107 testRange(db, new KeyRange.upperBound(40), 0, 40)); | 107 testRange(db, new KeyRange.upperBound(40), 0, 40)); |
| 108 // OPTIONALS upper2() => testRange(db, new KeyRange.upperBound(40, open: tru e), 0, 39); | 108 // OPTIONALS upper2() => testRange(db, new KeyRange.upperBound(40, open: tru e), 0, 39); |
| 109 futureTest('upper2', () => | 109 test('upper2', () => |
| 110 testRange(db, new KeyRange.upperBound(40, true), 0, 39)); | 110 testRange(db, new KeyRange.upperBound(40, true), 0, 39)); |
| 111 // upper3() => testRange(db, new KeyRange.upperBound(40, open: false), 0, 40 ); | 111 // upper3() => testRange(db, new KeyRange.upperBound(40, open: false), 0, 40 ); |
| 112 futureTest('upper3', () => | 112 test('upper3', () => |
| 113 testRange(db, new KeyRange.upperBound(40, false), 0, 40)); | 113 testRange(db, new KeyRange.upperBound(40, false), 0, 40)); |
| 114 | 114 |
| 115 futureTest('bound1', () => | 115 test('bound1', () => |
| 116 testRange(db, new KeyRange.bound(20, 30), 20, 30)); | 116 testRange(db, new KeyRange.bound(20, 30), 20, 30)); |
| 117 | 117 |
| 118 futureTest('bound2', () => | 118 test('bound2', () => |
| 119 testRange(db, new KeyRange.bound(-100, 200), 0, 99)); | 119 testRange(db, new KeyRange.bound(-100, 200), 0, 99)); |
| 120 | 120 |
| 121 bound3() => | 121 bound3() => |
| 122 // OPTIONALS testRange(db, new KeyRange.bound(20, 30, upperOpen: true), | 122 // OPTIONALS testRange(db, new KeyRange.bound(20, 30, upperOpen: true), |
| 123 testRange(db, new KeyRange.bound(20, 30, false, true), 20, 29); | 123 testRange(db, new KeyRange.bound(20, 30, false, true), 20, 29); |
| 124 | 124 |
| 125 bound4() => | 125 bound4() => |
| 126 // OPTIONALS testRange(db, new KeyRange.bound(20, 30, lowerOpen: true), | 126 // OPTIONALS testRange(db, new KeyRange.bound(20, 30, lowerOpen: true), |
| 127 testRange(db, new KeyRange.bound(20, 30, true), 21, 30); | 127 testRange(db, new KeyRange.bound(20, 30, true), 21, 30); |
| 128 | 128 |
| 129 bound5() => | 129 bound5() => |
| 130 // OPTIONALS testRange(db, new KeyRange.bound(20, 30, lowerOpen: true, u pperOpen: true), | 130 // OPTIONALS testRange(db, new KeyRange.bound(20, 30, lowerOpen: true, u pperOpen: true), |
| 131 testRange(db, new KeyRange.bound(20, 30, true, true), 21, 29); | 131 testRange(db, new KeyRange.bound(20, 30, true, true), 21, 29); |
| 132 } | 132 } |
| 133 } | 133 } |
| OLD | NEW |