Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: tests/html/indexeddb_1_test.dart

Issue 10544208: Fix indexeddb tests to implement proper setVersion semantics. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/html/html.status ('k') | tests/html/indexeddb_2_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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() { 37 step1([e]) {
sra1 2012/06/18 16:48:32 This is a bit odd...
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 step1(); 54
55 var transaction = e.target.result;
56 transaction.on.complete.add(expectAsync1(step1));
sra1 2012/06/18 16:48:32 ... instead use (e) => step1()
57 transaction.on.error.add(fail);
55 }) 58 })
56 ); 59 );
57 request.on.error.add(fail); 60 request.on.error.add(fail);
58 } else { 61 } else {
59 step1(); 62 step1();
60 } 63 }
61 } 64 }
62 65
63 var request = window.indexedDB.open(dbName); 66 var request = window.indexedDB.open(dbName);
64 Expect.isNotNull(request); 67 Expect.isNotNull(request);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 test('test4', 140 test('test4',
138 testReadWriteTyped(123, const [2, 3, 4], Expect.listEquals)); 141 testReadWriteTyped(123, const [2, 3, 4], Expect.listEquals));
139 } 142 }
140 143
141 main() { 144 main() {
142 useHtmlConfiguration(); 145 useHtmlConfiguration();
143 146
144 tests_dynamic(); 147 tests_dynamic();
145 tests_typed(); 148 tests_typed();
146 } 149 }
OLDNEW
« no previous file with comments | « tests/html/html.status ('k') | tests/html/indexeddb_2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698