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

Unified Diff: tests/html/indexeddb_5_test.dart

Issue 12421005: Attempting to fix IndexedDB test on IE10 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 | « tests/html/indexeddb_1_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/indexeddb_5_test.dart
diff --git a/tests/html/indexeddb_5_test.dart b/tests/html/indexeddb_5_test.dart
index ac126ff45e4eaa9836930e388d88b5e929e41015..826b9d1894cf4b4590cd5fd810c943242370b5d9 100644
--- a/tests/html/indexeddb_5_test.dart
+++ b/tests/html/indexeddb_5_test.dart
@@ -1,191 +1,183 @@
library IndexedDB1Test;
import '../../pkg/unittest/lib/unittest.dart';
-import '../../pkg/unittest/lib/html_individual_config.dart';
+import '../../pkg/unittest/lib/html_config.dart';
import 'dart:async';
import 'dart:html' as html;
import 'dart:indexed_db' as idb;
main() {
- useHtmlIndividualConfiguration();
-
- group('supportsDatabaseNames', () {
- test('supported', () {
- expect(html.window.indexedDB.supportsDatabaseNames, isTrue);
- });
- });
+ useHtmlConfiguration();
if (!idb.IdbFactory.supported) {
return;
}
- group('functional', () {
- var dbName = 'test_db';
- var storeName = 'test_store';
- var indexName = 'name_index';
- var db;
+ var dbName = 'test_db_5';
+ var storeName = 'test_store';
+ var indexName = 'name_index';
+ var db;
- test('init', () {
- return html.window.indexedDB.deleteDatabase(dbName).then((_) {
- return html.window.indexedDB.open(dbName, version: 1,
- onUpgradeNeeded: (e) {
- var db = e.target.result;
- var objectStore = db.createObjectStore(storeName,
- autoIncrement: true);
- var index = objectStore.createIndex(indexName, 'name_index',
- unique: false);
- });
- }).then((database) {
- db = database;
- });
+ test('init', () {
+ return html.window.indexedDB.deleteDatabase(dbName).then((_) {
+ return html.window.indexedDB.open(dbName, version: 1,
+ onUpgradeNeeded: (e) {
+ var db = e.target.result;
+ var objectStore = db.createObjectStore(storeName,
+ autoIncrement: true);
+ var index = objectStore.createIndex(indexName, 'name_index',
+ unique: false);
+ });
+ }).then((database) {
+ db = database;
});
+ });
- if (html.window.indexedDB.supportsDatabaseNames) {
- test('getDatabaseNames', () {
- return html.window.indexedDB.getDatabaseNames().then((names) {
- expect(names.contains(dbName), isTrue);
- });
+ if (html.window.indexedDB.supportsDatabaseNames) {
+ test('getDatabaseNames', () {
+ return html.window.indexedDB.getDatabaseNames().then((names) {
+ expect(names.contains(dbName), isTrue);
});
- }
+ });
+ }
- var value = {'name_index': 'one', 'value': 'add_value'};
- test('add/delete', () {
- var transaction = db.transaction([storeName], 'readwrite');
- var key;
- return transaction.objectStore(storeName).add(value).then((addedKey) {
- key = addedKey;
- }).then((_) {
- return transaction.completed;
- }).then((_) {
- transaction = db.transaction([storeName], 'readonly');
- return transaction.objectStore(storeName).getObject(key);
- }).then((readValue) {
- expect(readValue['value'], value['value']);
- return transaction.completed;
- }).then((_) {
- transaction = db.transaction([storeName], 'readwrite');
- return transaction.objectStore(storeName).delete(key);
- }).then((_) {
- return transaction.completed;
- }).then((_) {
- var transaction = db.transaction([storeName], 'readonly');
- return transaction.objectStore(storeName).count();
- }).then((count) {
- expect(count, 0);
- });
+ var value = {'name_index': 'one', 'value': 'add_value'};
+ test('add/delete', () {
+ var transaction = db.transaction([storeName], 'readwrite');
+ var key;
+ return transaction.objectStore(storeName).add(value).then((addedKey) {
+ key = addedKey;
+ }).then((_) {
+ return transaction.completed;
+ }).then((_) {
+ transaction = db.transaction([storeName], 'readonly');
+ return transaction.objectStore(storeName).getObject(key);
+ }).then((readValue) {
+ expect(readValue['value'], value['value']);
+ return transaction.completed;
+ }).then((_) {
+ transaction = db.transaction([storeName], 'readwrite');
+ return transaction.objectStore(storeName).delete(key);
+ }).then((_) {
+ return transaction.completed;
+ }).then((_) {
+ var transaction = db.transaction([storeName], 'readonly');
+ return transaction.objectStore(storeName).count();
+ }).then((count) {
+ expect(count, 0);
});
+ });
- test('clear/count', () {
- var transaction = db.transaction([storeName], 'readwrite');
- transaction.objectStore(storeName).add(value);
+ test('clear/count', () {
+ var transaction = db.transaction([storeName], 'readwrite');
+ transaction.objectStore(storeName).add(value);
- return transaction.completed.then((_) {
- transaction = db.transaction([storeName], 'readonly');
- return transaction.objectStore(storeName).count();
- }).then((count) {
- expect(count, 1);
- }).then((_) {
- return transaction.completed;
- }).then((_) {
- transaction = db.transaction([storeName], 'readwrite');
- transaction.objectStore(storeName).clear();
- return transaction.completed;
- }).then((_) {
- var transaction = db.transaction([storeName], 'readonly');
- return transaction.objectStore(storeName).count();
- }).then((count) {
- expect(count, 0);
- });
+ return transaction.completed.then((_) {
+ transaction = db.transaction([storeName], 'readonly');
+ return transaction.objectStore(storeName).count();
+ }).then((count) {
+ expect(count, 1);
+ }).then((_) {
+ return transaction.completed;
+ }).then((_) {
+ transaction = db.transaction([storeName], 'readwrite');
+ transaction.objectStore(storeName).clear();
+ return transaction.completed;
+ }).then((_) {
+ var transaction = db.transaction([storeName], 'readonly');
+ return transaction.objectStore(storeName).count();
+ }).then((count) {
+ expect(count, 0);
});
+ });
- test('index', () {
- var transaction = db.transaction([storeName], 'readwrite');
- transaction.objectStore(storeName).add(value);
- transaction.objectStore(storeName).add(value);
- transaction.objectStore(storeName).add(value);
- transaction.objectStore(storeName).add(value);
+ test('index', () {
+ var transaction = db.transaction([storeName], 'readwrite');
+ transaction.objectStore(storeName).add(value);
+ transaction.objectStore(storeName).add(value);
+ transaction.objectStore(storeName).add(value);
+ transaction.objectStore(storeName).add(value);
- return transaction.completed.then((_) {
- transaction = db.transaction([storeName], 'readonly');
- var index = transaction.objectStore(storeName).index(indexName);
- return index.count();
- }).then((count) {
- expect(count, 4);
- return transaction.completed;
- }).then((_) {
- transaction = db.transaction([storeName], 'readonly');
- var index = transaction.objectStore(storeName).index(indexName);
- return index.openCursor(autoAdvance: true).length;
- }).then((cursorsLength) {
- expect(cursorsLength, 4);
- return transaction.completed;
- }).then((_) {
- transaction = db.transaction([storeName], 'readonly');
- var index = transaction.objectStore(storeName).index(indexName);
- return index.openKeyCursor(autoAdvance: true).length;
- }).then((cursorsLength) {
- expect(cursorsLength, 4);
- return transaction.completed;
- }).then((_) {
- transaction = db.transaction([storeName], 'readonly');
- var index = transaction.objectStore(storeName).index(indexName);
- return index.get('one');
- }).then((readValue) {
- expect(readValue['value'], value['value']);
- return transaction.completed;
- }).then((_) {
- transaction = db.transaction([storeName], 'readwrite');
- transaction.objectStore(storeName).clear();
- return transaction.completed;
- });
+ return transaction.completed.then((_) {
+ transaction = db.transaction([storeName], 'readonly');
+ var index = transaction.objectStore(storeName).index(indexName);
+ return index.count();
+ }).then((count) {
+ expect(count, 4);
+ return transaction.completed;
+ }).then((_) {
+ transaction = db.transaction([storeName], 'readonly');
+ var index = transaction.objectStore(storeName).index(indexName);
+ return index.openCursor(autoAdvance: true).length;
+ }).then((cursorsLength) {
+ expect(cursorsLength, 4);
+ return transaction.completed;
+ }).then((_) {
+ transaction = db.transaction([storeName], 'readonly');
+ var index = transaction.objectStore(storeName).index(indexName);
+ return index.openKeyCursor(autoAdvance: true).length;
+ }).then((cursorsLength) {
+ expect(cursorsLength, 4);
+ return transaction.completed;
+ }).then((_) {
+ transaction = db.transaction([storeName], 'readonly');
+ var index = transaction.objectStore(storeName).index(indexName);
+ return index.get('one');
+ }).then((readValue) {
+ expect(readValue['value'], value['value']);
+ return transaction.completed;
+ }).then((_) {
+ transaction = db.transaction([storeName], 'readwrite');
+ transaction.objectStore(storeName).clear();
+ return transaction.completed;
});
+ });
- var deleteValue = {'name_index': 'two', 'value': 'delete_value'};
- var updateValue = {'name_index': 'three', 'value': 'update_value'};
- var updatedValue = {'name_index': 'three', 'value': 'updated_value'};
- test('cursor', () {
- var transaction = db.transaction([storeName], 'readwrite');
- transaction.objectStore(storeName).add(value);
- transaction.objectStore(storeName).add(deleteValue);
- transaction.objectStore(storeName).add(updateValue);
+ var deleteValue = {'name_index': 'two', 'value': 'delete_value'};
+ var updateValue = {'name_index': 'three', 'value': 'update_value'};
+ var updatedValue = {'name_index': 'three', 'value': 'updated_value'};
+ test('cursor', () {
+ var transaction = db.transaction([storeName], 'readwrite');
+ transaction.objectStore(storeName).add(value);
+ transaction.objectStore(storeName).add(deleteValue);
+ transaction.objectStore(storeName).add(updateValue);
- return transaction.completed.then((_) {
- transaction = db.transaction([storeName], 'readwrite');
- var index = transaction.objectStore(storeName).index(indexName);
- var cursors = index.openCursor().asBroadcastStream();
+ return transaction.completed.then((_) {
+ transaction = db.transaction([storeName], 'readwrite');
+ var index = transaction.objectStore(storeName).index(indexName);
+ var cursors = index.openCursor().asBroadcastStream();
- cursors.listen((cursor) {
- var value = cursor.value;
- if (value['value'] == 'delete_value') {
- cursor.delete().then((_) {
- cursor.next();
- });
- } else if (value['value'] == 'update_value') {
- cursor.update(updatedValue).then((_) {
- cursor.next();
- });
- } else {
+ cursors.listen((cursor) {
+ var value = cursor.value;
+ if (value['value'] == 'delete_value') {
+ cursor.delete().then((_) {
cursor.next();
- }
- });
- return cursors.last;
-
- }).then((_) {
- return transaction.completed;
- }).then((_) {
- transaction = db.transaction([storeName], 'readonly');
- var index = transaction.objectStore(storeName).index(indexName);
- return index.get('three');
- }).then((readValue) {
- expect(readValue['value'], 'updated_value');
- return transaction.completed;
- }).then((_) {
- transaction = db.transaction([storeName], 'readonly');
- var index = transaction.objectStore(storeName).index(indexName);
- return index.get('two');
- }).then((readValue) {
- expect(readValue, isNull);
- return transaction.completed;
+ });
+ } else if (value['value'] == 'update_value') {
+ cursor.update(updatedValue).then((_) {
+ cursor.next();
+ });
+ } else {
+ cursor.next();
+ }
});
+ return cursors.last;
+
+ }).then((_) {
+ return transaction.completed;
+ }).then((_) {
+ transaction = db.transaction([storeName], 'readonly');
+ var index = transaction.objectStore(storeName).index(indexName);
+ return index.get('three');
+ }).then((readValue) {
+ expect(readValue['value'], 'updated_value');
+ return transaction.completed;
+ }).then((_) {
+ transaction = db.transaction([storeName], 'readonly');
+ var index = transaction.objectStore(storeName).index(indexName);
+ return index.get('two');
+ }).then((readValue) {
+ expect(readValue, isNull);
+ return transaction.completed;
});
});
}
« no previous file with comments | « tests/html/indexeddb_1_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698