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

Side by Side Diff: tests/html/indexeddb_2_test.dart

Issue 12226134: Fixing Indexed DB's CursorWithValue.value (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 library IndexedDB1Test; 1 library IndexedDB1Test;
2 import '../../pkg/unittest/lib/unittest.dart'; 2 import '../../pkg/unittest/lib/unittest.dart';
3 import '../../pkg/unittest/lib/html_config.dart'; 3 import '../../pkg/unittest/lib/html_config.dart';
4 import 'dart:async'; 4 import 'dart:async';
5 import 'dart:html' as html; 5 import 'dart:html' as html;
6 import 'dart:indexed_db' as idb; 6 import 'dart:indexed_db' as idb;
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'utils.dart'; 8 import 'utils.dart';
9 9
10 // Write and re-read Maps: simple Maps; Maps with DAGs; Maps with cycles. 10 // Write and re-read Maps: simple Maps; Maps with DAGs; Maps with cycles.
11 11
12 const String DB_NAME = 'Test'; 12 const String DB_NAME = 'Test';
13 const String STORE_NAME = 'TEST'; 13 const String STORE_NAME = 'TEST';
14 const int VERSION = 1; 14 const int VERSION = 1;
15 15
16 testReadWrite(key, value, check, 16 testReadWrite(key, value, check,
17 [dbName = DB_NAME, storeName = STORE_NAME, version = VERSION]) { 17 [dbName = DB_NAME, storeName = STORE_NAME, version = VERSION]) {
18 18
19 createObjectStore(e) { 19 createObjectStore(e) {
20 var store = e.target.result.createObjectStore(storeName); 20 var store = e.target.result.createObjectStore(storeName);
21 expect(store, isNotNull); 21 expect(store, isNotNull);
22 } 22 }
23 23
24 var db; 24 var db;
25 // Delete any existing DBs. 25 // Delete any existing DBs.
26 return html.window.indexedDB.deleteDatabase(dbName).then((_) { 26 return html.window.indexedDB.deleteDatabase(dbName).then((_) {
27 html.window.console.log('open');
28 return html.window.indexedDB.open(dbName, version: version, 27 return html.window.indexedDB.open(dbName, version: version,
29 onUpgradeNeeded: createObjectStore); 28 onUpgradeNeeded: createObjectStore);
30 }).then((result) { 29 }).then((result) {
31 html.window.console.log('write');
32 db = result; 30 db = result;
33 var transaction = db.transaction([storeName], 'readwrite'); 31 var transaction = db.transaction([storeName], 'readwrite');
34 transaction.objectStore(storeName).put(value, key); 32 transaction.objectStore(storeName).put(value, key);
35 33
36 return transaction.completed; 34 return transaction.completed;
37 }).then((db) { 35 }).then((db) {
38 html.window.console.log('read');
39 var transaction = db.transaction(storeName, 'readonly'); 36 var transaction = db.transaction(storeName, 'readonly');
40 return transaction.objectStore(storeName).getObject(key); 37 return transaction.objectStore(storeName).getObject(key);
41 }).then((object) { 38 }).then((object) {
42 html.window.console.log('got close');
43 db.close(); 39 db.close();
44 check(value, object); 40 check(value, object);
45 }).catchError((e) { 41 }).catchError((e) {
46 if (db != null) { 42 if (db != null) {
47 db.close(); 43 db.close();
48 } 44 }
49 throw e; 45 throw e;
50 }); 46 });
51 } 47 }
52 48
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 go('test_DAG', obj2); 88 go('test_DAG', obj2);
93 go('test_cycle', obj3); 89 go('test_cycle', obj3);
94 go('test_simple_splay', obj4); 90 go('test_simple_splay', obj4);
95 go('const_array_1', const [const [1], const [2]]); 91 go('const_array_1', const [const [1], const [2]]);
96 go('const_array_dag', const [const [1], const [1]]); 92 go('const_array_dag', const [const [1], const [1]]);
97 go('array_deferred_copy', [1,2,3, obj3, obj3, 6]); 93 go('array_deferred_copy', [1,2,3, obj3, obj3, 6]);
98 go('array_deferred_copy_2', [1,2,3, [4, 5, obj3], [obj3, 6]]); 94 go('array_deferred_copy_2', [1,2,3, [4, 5, obj3], [obj3, 6]]);
99 go('cyclic_list', cyclic_list); 95 go('cyclic_list', cyclic_list);
100 } 96 }
101 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698