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

Unified Diff: tests/dom/indexeddb_1_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/dom/indexeddb_1_test.dart
===================================================================
--- tests/dom/indexeddb_1_test.dart (revision 7823)
+++ tests/dom/indexeddb_1_test.dart (working copy)
@@ -14,8 +14,9 @@
var db;
fail(e) {
- callbackDone();
- Expect.fail('IndexedDB failure');
+ guardAsync(() {
+ Expect.fail('IndexedDB failure');
+ });
}
createObjectStore() {
@@ -23,21 +24,22 @@
Expect.isNotNull(store);
}
- step2() {
+ step2(e) {
var transaction = db.transaction(storeName, IDBTransaction.READ_ONLY);
var request = transaction.objectStore(storeName).getObject(key);
- request.addEventListener('success', (e) {
+ request.addEventListener('success',
+ expectAsync1((e) {
var object = e.target.result;
check(value, object);
- callbackDone();
- });
+ })
+ );
request.addEventListener('error', fail);
}
step1() {
var transaction = db.transaction([storeName], IDBTransaction.READ_WRITE);
var request = transaction.objectStore(storeName).put(value, key);
- request.addEventListener('success', (e) { step2(); });
+ request.addEventListener('success', expectAsync1(step2));
request.addEventListener('error', fail);
}
@@ -49,7 +51,11 @@
// difference and make it work?
var request = db.setVersion(version);
request.addEventListener('success',
- (e) { createObjectStore(); step1(); });
+ expectAsync1((e) {
+ createObjectStore();
+ step1();
+ })
+ );
request.addEventListener('error', fail);
} else {
step1();
@@ -58,7 +64,7 @@
var request = window.webkitIndexedDB.open(dbName);
Expect.isNotNull(request);
- request.addEventListener('success', initDb);
+ request.addEventListener('success', expectAsync1(initDb));
request.addEventListener('error', fail);
};
@@ -69,8 +75,9 @@
IDBDatabase db;
fail(e) {
- callbackDone();
- Expect.fail('IndexedDB failure');
+ guardAsync(() {
+ Expect.fail('IndexedDB failure');
+ });
}
createObjectStore() {
@@ -78,15 +85,16 @@
Expect.isNotNull(store);
}
- step2() {
+ step2(e) {
IDBTransaction transaction =
- db.transaction(storeName, IDBTransaction.READ_ONLY);
+ db.transaction(storeName, IDBTransaction.READ_ONLY);
IDBRequest request = transaction.objectStore(storeName).getObject(key);
- request.addEventListener('success', (e) {
+ request.addEventListener('success',
+ expectAsync1((e) {
var object = e.target.result;
check(value, object);
- callbackDone();
- });
+ })
+ );
request.addEventListener('error', fail);
}
@@ -94,7 +102,7 @@
IDBTransaction transaction =
db.transaction([storeName], IDBTransaction.READ_WRITE);
IDBRequest request = transaction.objectStore(storeName).put(value, key);
- request.addEventListener('success', (e) { step2(); });
+ request.addEventListener('success', expectAsync1(step2));
request.addEventListener('error', fail);
}
@@ -103,7 +111,11 @@
if (version != db.version) {
IDBRequest request = db.setVersion(version);
request.addEventListener('success',
- (e) { createObjectStore(); step1(); });
+ expectAsync1((e) {
+ createObjectStore();
+ step1();
+ })
+ );
request.addEventListener('error', fail);
} else {
step1();
@@ -112,23 +124,22 @@
IDBRequest request = window.webkitIndexedDB.open(dbName);
Expect.isNotNull(request);
- request.addEventListener('success', initDb);
+ request.addEventListener('success', expectAsync1(initDb));
request.addEventListener('error', fail);
};
tests_dynamic() {
- asyncTest('test1', 1, testReadWrite(123, 'Hoot!', Expect.equals));
- asyncTest('test2', 1, testReadWrite(123, 12345, Expect.equals));
- asyncTest('test3', 1, testReadWrite(123, [1,2,3], Expect.listEquals));
- asyncTest('test4', 1, testReadWrite(123, const [2, 3, 4], Expect.listEquals));
+ test('test1', testReadWrite(123, 'Hoot!', Expect.equals));
+ test('test2', testReadWrite(123, 12345, Expect.equals));
+ test('test3', testReadWrite(123, [1,2,3], Expect.listEquals));
+ test('test4', testReadWrite(123, const [2, 3, 4], Expect.listEquals));
}
tests_typed() {
- asyncTest('test1', 1, testReadWriteTyped(123, 'Hoot!', Expect.equals));
- asyncTest('test2', 1, testReadWriteTyped(123, 12345, Expect.equals));
- asyncTest('test3', 1, testReadWriteTyped(123, [1,2,3], Expect.listEquals));
- asyncTest('test4', 1,
- testReadWriteTyped(123, const [2, 3, 4], Expect.listEquals));
+ test('test1', testReadWriteTyped(123, 'Hoot!', Expect.equals));
+ test('test2', testReadWriteTyped(123, 12345, Expect.equals));
+ test('test3', testReadWriteTyped(123, [1,2,3], Expect.listEquals));
+ test('test4', testReadWriteTyped(123, const [2, 3, 4], Expect.listEquals));
}
main() {

Powered by Google App Engine
This is Rietveld 408576698