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

Unified Diff: client/tests/client/dom/IndexedDB3Test.dart

Issue 10191033: test renaming overhaul: step 4 client tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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
« no previous file with comments | « client/tests/client/dom/IndexedDB2Test.dart ('k') | client/tests/client/dom/IndexedDB4Test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/client/dom/IndexedDB3Test.dart
diff --git a/client/tests/client/dom/IndexedDB3Test.dart b/client/tests/client/dom/IndexedDB3Test.dart
deleted file mode 100644
index 63b86a811d389d72cc952fee6ad1729fdfa4e4b2..0000000000000000000000000000000000000000
--- a/client/tests/client/dom/IndexedDB3Test.dart
+++ /dev/null
@@ -1,119 +0,0 @@
-#library('IndexedDB3Test');
-#import('../../../../lib/unittest/unittest.dart');
-#import('../../../../lib/unittest/dom_config.dart');
-#import('dart:dom');
-#import('dart:coreimpl');
-
-// Read with cursor.
-
-final String DB_NAME = 'Test';
-final String STORE_NAME = 'TEST';
-final String VERSION = '1';
-
-class Test {
- var db;
-
- start() {
- var request = window.webkitIndexedDB.open(DB_NAME);
- Expect.isNotNull(request);
- request.addEventListener('success', initDb);
- request.addEventListener('error', fail('open'));
- }
-
- initDb(e) {
- db = e.target.result;
- // TODO. Some browsers do this the w3 way - passing the VERSION to the
- // open call and listening to onversionchange. Can we feature-detect the
- // difference and make it work?
- var request = db.setVersion(VERSION);
- request.addEventListener('success', (e) {
- try {
- // Nuke object store if it already exists.
- db.deleteObjectStore(STORE_NAME);
- } catch (IDBDatabaseException e) { }
- db.createObjectStore(STORE_NAME);
- writeItems(0);
- });
- request.addEventListener('blocked', fail('setVersion blocked'));
- request.addEventListener('error', fail('setVersion error'));
- }
-
- writeItems(int index) {
- if (index < 100) {
- var transaction = db.transaction([STORE_NAME], IDBTransaction.READ_WRITE);
- var request = transaction.objectStore(STORE_NAME)
- .put('Item $index', index);
- request.addEventListener('success', (e) { writeItems(index + 1); });
- request.addEventListener('error', fail('put'));
- } else {
- callbackDone();
- }
- }
-
- fail(message) => (e) {
- callbackDone();
- Expect.fail('IndexedDB failure: $message');
- };
-
- readAllViaCursor() {
- IDBTransaction txn = db.transaction(STORE_NAME, IDBTransaction.READ_ONLY);
- IDBObjectStore objectStore = txn.objectStore(STORE_NAME);
- IDBRequest cursorRequest = objectStore.openCursor();
- int itemCount = 0;
- int sumKeys = 0;
- int lastKey = null;
- cursorRequest.addEventListener("success", (e) {
- var cursor = e.target.result;
- if (cursor != null) {
- lastKey = cursor.key;
- itemCount += 1;
- sumKeys += cursor.key;
- Expect.equals('Item ${cursor.key}', cursor.value);
- cursor.continueFunction();
- } else {
- // Done
- Expect.equals(99, lastKey);
- Expect.equals(100, itemCount);
- Expect.equals((100 * 99) ~/ 2, sumKeys);
- callbackDone();
- }
- });
- cursorRequest.addEventListener('error', fail('openCursor'));
- }
-
- readAllReversedViaCursor() {
- IDBTransaction txn = db.transaction(STORE_NAME, IDBTransaction.READ_ONLY);
- IDBObjectStore objectStore = txn.objectStore(STORE_NAME);
- // TODO: create a IDBKeyRange(0,100)
- IDBRequest cursorRequest = objectStore.openCursor(null, IDBCursor.PREV);
- int itemCount = 0;
- int sumKeys = 0;
- int lastKey = null;
- cursorRequest.addEventListener("success", (e) {
- var cursor = e.target.result;
- if (cursor != null) {
- lastKey = cursor.key;
- itemCount += 1;
- sumKeys += cursor.key;
- Expect.equals('Item ${cursor.key}', cursor.value);
- cursor.continueFunction();
- } else {
- // Done
- Expect.equals(0, lastKey); // i.e. first key (scanned in reverse).
- Expect.equals(100, itemCount);
- Expect.equals((100 * 99) ~/ 2, sumKeys);
- callbackDone();
- }
- });
- cursorRequest.addEventListener('error', fail('openCursor'));
- }
-}
-
-main() {
- useDomConfiguration();
-
- var test = new Test();
- asyncTest('prepare', 1, test.start);
- asyncTest('readAll1', 1, test.readAllViaCursor);
- asyncTest('readAll2', 1, test.readAllReversedViaCursor);
-}
« no previous file with comments | « client/tests/client/dom/IndexedDB2Test.dart ('k') | client/tests/client/dom/IndexedDB4Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698