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

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

Issue 26554008: Minor tweak to indexeddb_3 test transaction handling (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library IndexedDB3Test; 1 library IndexedDB3Test;
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'; 6 import 'dart:indexed_db';
7 7
8 // Read with cursor. 8 // Read with cursor.
9 9
10 const String DB_NAME = 'Test3'; 10 const String DB_NAME = 'Test3';
11 const String STORE_NAME = 'TEST'; 11 const String STORE_NAME = 'TEST';
12 const int VERSION = 1; 12 const int VERSION = 1;
13 13
14 14
15 Future<Database> createAndOpenDb() { 15 Future<Database> createAndOpenDb() {
16 return html.window.indexedDB.deleteDatabase(DB_NAME).then((_) { 16 return html.window.indexedDB.deleteDatabase(DB_NAME).then((_) {
17 return html.window.indexedDB.open(DB_NAME, version: VERSION, 17 return html.window.indexedDB.open(DB_NAME, version: VERSION,
18 onUpgradeNeeded: (e) { 18 onUpgradeNeeded: (e) {
19 var db = e.target.result; 19 var db = e.target.result;
20 db.createObjectStore(STORE_NAME); 20 db.createObjectStore(STORE_NAME);
21 }); 21 });
22 }); 22 });
23 } 23 }
24 24
25 Future<Database> writeItems(Database db) { 25 Future<Database> writeItems(Database db) {
26 Future<Object> write(index) { 26 Future<Object> write(index) {
27 var transaction = db.transaction(STORE_NAME, 'readwrite'); 27 var transaction = db.transaction(STORE_NAME, 'readwrite');
28 return transaction.objectStore(STORE_NAME).put('Item $index', index) 28 transaction.objectStore(STORE_NAME).put('Item $index', index);
29 .then((_) => transaction.onComplete.first); 29 return transaction.completed;
30 } 30 }
31 31
32 var future = write(0); 32 var future = write(0);
33 for (var i = 1; i < 100; ++i) { 33 for (var i = 1; i < 100; ++i) {
34 future = future.then((_) => write(i)); 34 future = future.then((_) => write(i));
35 } 35 }
36 36
37 // Chain on the DB so we return it at the end. 37 // Chain on the DB so we return it at the end.
38 return future.then((_) => db); 38 return future.then((_) => db);
39 } 39 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 }); 105 });
106 test('readAll1', () { 106 test('readAll1', () {
107 return readAllViaCursor(db); 107 return readAllViaCursor(db);
108 }); 108 });
109 109
110 test('readAll2', () { 110 test('readAll2', () {
111 return readAllReversedViaCursor(db); 111 return readAllReversedViaCursor(db);
112 }); 112 });
113 } 113 }
114 } 114 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698