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

Unified Diff: tests/html/indexeddb_4_test.dart

Issue 10412015: aChange all asyncTest/callbackDone style tests to use the new expectAsync/ (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: tests/html/indexeddb_4_test.dart
===================================================================
--- tests/html/indexeddb_4_test.dart (revision 7823)
+++ tests/html/indexeddb_4_test.dart (working copy)
@@ -15,7 +15,7 @@
start() {
var request = window.webkitIndexedDB.open(DB_NAME);
Expect.isNotNull(request);
- request.on.success.add(initDb);
+ request.on.success.add(expectAsync1(initDb));
request.on.error.add(fail('open'));
}
@@ -25,14 +25,16 @@
// open call and listening to onversionchange. Can we feature-detect the
// difference and make it work?
var request = db.setVersion(VERSION);
- request.on.success.add((e) {
+ request.on.success.add(
+ expectAsync1((e) {
try {
// Nuke object store if it already exists.
db.deleteObjectStore(STORE_NAME);
} catch (IDBDatabaseException e) { }
db.createObjectStore(STORE_NAME);
writeItems(0);
- });
+ })
+ );
request.on.error.add(fail('setVersion error'));
}
@@ -41,19 +43,23 @@
var transaction = db.transaction([STORE_NAME], IDBTransaction.READ_WRITE);
var request = transaction.objectStore(STORE_NAME)
.put('Item $index', index);
- request.on.success.add((e) { writeItems(index + 1); });
+ request.on.success.add(
+ expectAsync1((e) {
+ writeItems(index + 1);
+ })
+ );
request.on.error.add(fail('put'));
- } else {
- callbackDone();
}
}
fail(message) => (e) {
- callbackDone();
- Expect.fail('IndexedDB failure: $message');
+ guardAsync(() {
+ Expect.fail('IndexedDB failure: $message');
+ });
};
testRange(range, expectedFirst, expectedLast) {
+ var doneCallback = expectAsync0((){});
Siggi Cherem (dart-lang) 2012/05/21 22:20:47 ditto
gram 2012/05/22 17:36:36 Done.
IDBTransaction txn = db.transaction(STORE_NAME, IDBTransaction.READ_ONLY);
IDBObjectStore objectStore = txn.objectStore(STORE_NAME);
IDBRequest cursorRequest = objectStore.openCursor(range);
@@ -61,6 +67,7 @@
int firstKey = null;
int lastKey = null;
cursorRequest.on.success.add((e) {
+ guardAsync(() {
var cursor = e.target.result;
if (cursor != null) {
if (firstKey == null) firstKey = cursor.key;
@@ -77,9 +84,10 @@
} else {
Expect.equals(expectedLast - expectedFirst + 1, itemCount);
}
- callbackDone();
+ doneCallback();
}
});
+ });
cursorRequest.on.error.add(fail('openCursor'));
}
@@ -116,25 +124,25 @@
main() {
useHtmlConfiguration();
- var test = new Test();
- asyncTest('prepare', 1, test.start);
+ var test_ = new Test();
+ test('prepare', test_.start);
- asyncTest('only1', 1, test.only1);
- asyncTest('only2', 1, test.only2);
- asyncTest('only3', 1, test.only3);
+ test('only1', test_.only1);
+ test('only2', test_.only2);
+ test('only3', test_.only3);
- asyncTest('lower1', 1, test.lower1);
- asyncTest('lower2', 1, test.lower2);
- asyncTest('lower3', 1, test.lower3);
+ test('lower1', test_.lower1);
+ test('lower2', test_.lower2);
+ test('lower3', test_.lower3);
- asyncTest('upper1', 1, test.upper1);
- asyncTest('upper2', 1, test.upper2);
- asyncTest('upper3', 1, test.upper3);
+ test('upper1', test_.upper1);
+ test('upper2', test_.upper2);
+ test('upper3', test_.upper3);
- asyncTest('bound1', 1, test.bound1);
- asyncTest('bound2', 1, test.bound2);
- asyncTest('bound3', 1, test.bound3);
- asyncTest('bound4', 1, test.bound4);
- asyncTest('bound5', 1, test.bound5);
+ test('bound1', test_.bound1);
+ test('bound2', test_.bound2);
+ test('bound3', test_.bound3);
+ test('bound4', test_.bound4);
+ test('bound5', test_.bound5);
}

Powered by Google App Engine
This is Rietveld 408576698