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

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

Issue 10448075: Fix indexeddb_4_test. (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/indexeddb_3_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #library('IndexedDB4Test'); 1 #library('IndexedDB4Test');
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 // Test for IDBKeyRange and IDBCursor. 6 // Test for IDBKeyRange and IDBCursor.
7 7
8 final String DB_NAME = 'Test'; 8 final String DB_NAME = 'Test';
9 final String STORE_NAME = 'TEST'; 9 final String STORE_NAME = 'TEST';
10 final String VERSION = '1'; 10 final String VERSION = '1';
(...skipping 22 matching lines...) Expand all
33 } catch (IDBDatabaseException e) { } 33 } catch (IDBDatabaseException e) { }
34 db.createObjectStore(STORE_NAME); 34 db.createObjectStore(STORE_NAME);
35 writeItems(0); 35 writeItems(0);
36 }) 36 })
37 ); 37 );
38 request.on.error.add(fail('setVersion error')); 38 request.on.error.add(fail('setVersion error'));
39 } 39 }
40 40
41 writeItems(int index) { 41 writeItems(int index) {
42 if (index < 100) { 42 if (index < 100) {
43 var transaction = db.transaction([STORE_NAME], IDBTransaction.READ_WRITE); 43 var transaction = db.transaction([STORE_NAME], 'readwrite');
44 var request = transaction.objectStore(STORE_NAME) 44 var request = transaction.objectStore(STORE_NAME)
45 .put('Item $index', index); 45 .put('Item $index', index);
46 request.on.success.add( 46 request.on.success.add(
47 expectAsync1((e) { 47 expectAsync1((e) {
48 writeItems(index + 1); 48 writeItems(index + 1);
49 }) 49 })
50 ); 50 );
51 request.on.error.add(fail('put')); 51 request.on.error.add(fail('put'));
52 } 52 }
53 } 53 }
54 54
55 fail(message) => (e) { 55 fail(message) => (e) {
56 guardAsync(() { 56 guardAsync(() {
57 Expect.fail('IndexedDB failure: $message'); 57 Expect.fail('IndexedDB failure: $message');
58 }); 58 });
59 }; 59 };
60 60
61 testRange(range, expectedFirst, expectedLast) { 61 testRange(range, expectedFirst, expectedLast) {
62 IDBTransaction txn = db.transaction(STORE_NAME, IDBTransaction.READ_ONLY); 62 IDBTransaction txn = db.transaction(STORE_NAME, 'readonly');
63 IDBObjectStore objectStore = txn.objectStore(STORE_NAME); 63 IDBObjectStore objectStore = txn.objectStore(STORE_NAME);
64 IDBRequest cursorRequest = objectStore.openCursor(range); 64 IDBRequest cursorRequest = objectStore.openCursor(range);
65 int itemCount = 0; 65 int itemCount = 0;
66 int firstKey = null; 66 num firstKey = null;
67 int lastKey = null; 67 num lastKey = null;
68 cursorRequest.on.success.add(expectAsync1((e) { 68 cursorRequest.on.success.add(expectAsync1((e) {
69 var cursor = e.target.result; 69 var cursor = e.target.result;
70 if (cursor != null) { 70 if (cursor != null) {
71 if (firstKey == null) firstKey = cursor.key; 71 if (firstKey == null) firstKey = cursor.key;
72 lastKey = cursor.key; 72 lastKey = cursor.key;
73 itemCount += 1; 73 itemCount += 1;
74 Expect.equals('Item ${cursor.key}', cursor.value); 74 Expect.equals('Item ${cursor.key.toStringAsFixed(0)}', cursor.value);
sra1 2012/05/31 15:34:38 It still bothers me a lot that the keys that were
podivilov 2012/05/31 17:08:24 Filed a bug: http://code.google.com/p/dart/issues/
75 cursor.continueFunction(); 75 cursor.continueFunction();
76 } else { 76 } else {
77 // Done 77 // Done
78 Expect.equals(expectedFirst, firstKey); 78 Expect.equals(expectedFirst, firstKey);
79 Expect.equals(expectedLast, lastKey); 79 Expect.equals(expectedLast, lastKey);
80 if (expectedFirst == null) { 80 if (expectedFirst == null) {
81 Expect.equals(0, itemCount); 81 Expect.equals(0, itemCount);
82 } else { 82 } else {
83 Expect.equals(expectedLast - expectedFirst + 1, itemCount); 83 Expect.equals(expectedLast - expectedFirst + 1, itemCount);
84 } 84 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 test('upper1', test_.upper1); 136 test('upper1', test_.upper1);
137 test('upper2', test_.upper2); 137 test('upper2', test_.upper2);
138 test('upper3', test_.upper3); 138 test('upper3', test_.upper3);
139 139
140 test('bound1', test_.bound1); 140 test('bound1', test_.bound1);
141 test('bound2', test_.bound2); 141 test('bound2', test_.bound2);
142 test('bound3', test_.bound3); 142 test('bound3', test_.bound3);
143 test('bound4', test_.bound4); 143 test('bound4', test_.bound4);
144 test('bound5', test_.bound5); 144 test('bound5', test_.bound5);
145
146 } 145 }
OLDNEW
« no previous file with comments | « tests/html/indexeddb_3_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698