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

Unified Diff: tests/html/indexeddb_2_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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
Index: tests/html/indexeddb_2_test.dart
diff --git a/tests/html/indexeddb_2_test.dart b/tests/html/indexeddb_2_test.dart
index 7350559240b0ac83dffdd1d86afb666e8f6481f4..5b12887427bfd8635e0659126fd48463ea09cdf3 100644
--- a/tests/html/indexeddb_2_test.dart
+++ b/tests/html/indexeddb_2_test.dart
@@ -1,4 +1,5 @@
library IndexedDB1Test;
+
import 'package:unittest/unittest.dart';
import 'package:unittest/html_config.dart';
import 'dart:async';
@@ -14,8 +15,7 @@ const String STORE_NAME = 'TEST';
const int VERSION = 1;
testReadWrite(key, value, check,
- [dbName = DB_NAME, storeName = STORE_NAME, version = VERSION]) {
-
+ [dbName = DB_NAME, storeName = STORE_NAME, version = VERSION]) {
createObjectStore(e) {
var store = e.target.result.createObjectStore(storeName);
expect(store, isNotNull);
@@ -24,26 +24,26 @@ testReadWrite(key, value, check,
var db;
// Delete any existing DBs.
return html.window.indexedDB.deleteDatabase(dbName).then(expectAsync((_) {
- return html.window.indexedDB.open(dbName, version: version,
- onUpgradeNeeded: createObjectStore);
- })).then(expectAsync((result) {
- db = result;
- var transaction = db.transactionList([storeName], 'readwrite');
- transaction.objectStore(storeName).put(value, key);
-
- return transaction.completed;
- })).then(expectAsync((db) {
- var transaction = db.transaction(storeName, 'readonly');
- return transaction.objectStore(storeName).getObject(key);
- })).then(expectAsync((object) {
+ return html.window.indexedDB
+ .open(dbName, version: version, onUpgradeNeeded: createObjectStore);
+ })).then(expectAsync((result) {
+ db = result;
+ var transaction = db.transactionList([storeName], 'readwrite');
+ transaction.objectStore(storeName).put(value, key);
+
+ return transaction.completed;
+ })).then(expectAsync((db) {
+ var transaction = db.transaction(storeName, 'readonly');
+ return transaction.objectStore(storeName).getObject(key);
+ })).then(expectAsync((object) {
+ db.close();
+ check(value, object);
+ })).catchError((e) {
+ if (db != null) {
db.close();
- check(value, object);
- })).catchError((e) {
- if (db != null) {
- db.close();
- }
- throw e;
- });
+ }
+ throw e;
+ });
}
List<String> get nonNativeListData {
@@ -59,35 +59,42 @@ main() {
useHtmlConfiguration();
var obj1 = {'a': 100, 'b': 's'};
- var obj2 = {'x': obj1, 'y': obj1}; // DAG.
+ var obj2 = {'x': obj1, 'y': obj1}; // DAG.
var obj3 = {};
obj3['a'] = 100;
- obj3['b'] = obj3; // Cycle.
+ obj3['b'] = obj3; // Cycle.
- var obj4 = new SplayTreeMap<String, dynamic>(); // Different implementation.
+ var obj4 = new SplayTreeMap<String, dynamic>(); // Different implementation.
obj4['a'] = 100;
obj4['b'] = 's';
var cyclic_list = [1, 2, 3];
cyclic_list[1] = cyclic_list;
- go(name, data) => test(name,
- () => testReadWrite(123, data, verifyGraph));
+ go(name, data) => test(name, () => testReadWrite(123, data, verifyGraph));
test('test_verifyGraph', () {
- // Nice to know verifyGraph is working before we rely on it.
- verifyGraph(obj4, obj4);
- verifyGraph(obj1, new Map.from(obj1));
- verifyGraph(obj4, new Map.from(obj4));
-
- var l1 = [1,2,3];
- var l2 = [const [1, 2, 3], const [1, 2, 3]];
- verifyGraph([l1, l1], l2);
- expect(() => verifyGraph([[1, 2, 3], [1, 2, 3]], l2), throws);
-
- verifyGraph(cyclic_list, cyclic_list);
- });
+ // Nice to know verifyGraph is working before we rely on it.
+ verifyGraph(obj4, obj4);
+ verifyGraph(obj1, new Map.from(obj1));
+ verifyGraph(obj4, new Map.from(obj4));
+
+ var l1 = [1, 2, 3];
+ var l2 = [
+ const [1, 2, 3],
+ const [1, 2, 3]
+ ];
+ verifyGraph([l1, l1], l2);
+ expect(
+ () => verifyGraph([
+ [1, 2, 3],
+ [1, 2, 3]
+ ], l2),
+ throws);
+
+ verifyGraph(cyclic_list, cyclic_list);
+ });
// Don't bother with these tests if it's unsupported.
// Support is tested in indexeddb_1_test
@@ -96,10 +103,22 @@ main() {
go('test_DAG', obj2);
go('test_cycle', obj3);
go('test_simple_splay', obj4);
- go('const_array_1', const [const [1], const [2]]);
- go('const_array_dag', const [const [1], const [1]]);
- go('array_deferred_copy', [1,2,3, obj3, obj3, 6]);
- go('array_deferred_copy_2', [1,2,3, [4, 5, obj3], [obj3, 6]]);
+ go('const_array_1', const [
+ const [1],
+ const [2]
+ ]);
+ go('const_array_dag', const [
+ const [1],
+ const [1]
+ ]);
+ go('array_deferred_copy', [1, 2, 3, obj3, obj3, 6]);
+ go('array_deferred_copy_2', [
+ 1,
+ 2,
+ 3,
+ [4, 5, obj3],
+ [obj3, 6]
+ ]);
go('cyclic_list', cyclic_list);
go('non-native lists', nonNativeListData);
}

Powered by Google App Engine
This is Rietveld 408576698