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

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

Issue 10513006: Fix indexeddb_3_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/html.status ('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('IndexedDB3Test'); 1 #library('IndexedDB3Test');
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 // Read with cursor. 6 // Read with cursor.
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 IDBRequest cursorRequest = objectStore.openCursor(); 63 IDBRequest cursorRequest = objectStore.openCursor();
64 int itemCount = 0; 64 int itemCount = 0;
65 int sumKeys = 0; 65 int sumKeys = 0;
66 int lastKey = null; 66 int lastKey = null;
67 cursorRequest.on.success.add(expectAsync1((e) { 67 cursorRequest.on.success.add(expectAsync1((e) {
68 var cursor = e.target.result; 68 var cursor = e.target.result;
69 if (cursor != null) { 69 if (cursor != null) {
70 lastKey = cursor.key; 70 lastKey = cursor.key;
71 itemCount += 1; 71 itemCount += 1;
72 sumKeys += cursor.key; 72 sumKeys += cursor.key;
73 Expect.equals('Item ${cursor.key.toStringAsFixed(0)}', cursor.value); 73 Expect.equals('Item ${cursor.key}', cursor.value);
74 cursor.continueFunction(); 74 cursor.continueFunction();
75 } else { 75 } else {
76 // Done 76 // Done
77 Expect.equals(99, lastKey); 77 Expect.equals(99, lastKey);
78 Expect.equals(100, itemCount); 78 Expect.equals(100, itemCount);
79 Expect.equals((100 * 99) ~/ 2, sumKeys); 79 Expect.equals((100 * 99) ~/ 2, sumKeys);
80 } 80 }
81 }, count:101)); 81 }, count:101));
82 cursorRequest.on.error.add(fail('openCursor')); 82 cursorRequest.on.error.add(fail('openCursor'));
83 } 83 }
84 84
85 readAllReversedViaCursor() { 85 readAllReversedViaCursor() {
86 IDBTransaction txn = db.transaction(STORE_NAME, IDBTransaction.READ_ONLY); 86 IDBTransaction txn = db.transaction(STORE_NAME, 'readonly');
87 IDBObjectStore objectStore = txn.objectStore(STORE_NAME); 87 IDBObjectStore objectStore = txn.objectStore(STORE_NAME);
88 // TODO: create a IDBKeyRange(0,100) 88 IDBRequest cursorRequest = objectStore.openCursor(new IDBKeyRange.bound(0, 1 00), 'prev');
89 IDBRequest cursorRequest = objectStore.openCursor(null, IDBCursor.PREV);
90 int itemCount = 0; 89 int itemCount = 0;
91 int sumKeys = 0; 90 int sumKeys = 0;
92 int lastKey = null; 91 int lastKey = null;
93 cursorRequest.on.success.add(expectAsync1((e) { 92 cursorRequest.on.success.add(expectAsync1((e) {
94 var cursor = e.target.result; 93 var cursor = e.target.result;
95 if (cursor != null) { 94 if (cursor != null) {
96 lastKey = cursor.key; 95 lastKey = cursor.key;
97 itemCount += 1; 96 itemCount += 1;
98 sumKeys += cursor.key; 97 sumKeys += cursor.key;
99 Expect.equals('Item ${cursor.key}', cursor.value); 98 Expect.equals('Item ${cursor.key}', cursor.value);
(...skipping 10 matching lines...) Expand all
110 } 109 }
111 110
112 main() { 111 main() {
113 useHtmlConfiguration(); 112 useHtmlConfiguration();
114 113
115 var test_ = new Test(); 114 var test_ = new Test();
116 test('prepare', test_.start); 115 test('prepare', test_.start);
117 test('readAll1', test_.readAllViaCursor); 116 test('readAll1', test_.readAllViaCursor);
118 test('readAll2', test_.readAllReversedViaCursor); 117 test('readAll2', test_.readAllReversedViaCursor);
119 } 118 }
OLDNEW
« no previous file with comments | « tests/html/html.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698