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

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

Issue 12388094: Removing futureTest test method (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 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_individual_config.dart'; 3 import '../../pkg/unittest/lib/html_individual_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 'utils.dart'; 7 import 'utils.dart';
8 8
9 main() { 9 main() {
10 useHtmlIndividualConfiguration(); 10 useHtmlIndividualConfiguration();
11 11
12 group('supportsDatabaseNames', () { 12 group('supportsDatabaseNames', () {
13 test('supported', () { 13 test('supported', () {
14 expect(html.window.indexedDB.supportsDatabaseNames, isTrue); 14 expect(html.window.indexedDB.supportsDatabaseNames, isTrue);
15 }); 15 });
16 }); 16 });
17 17
18 if (!idb.IdbFactory.supported) { 18 if (!idb.IdbFactory.supported) {
19 return; 19 return;
20 } 20 }
21 21
22 group('functional', () { 22 group('functional', () {
23 var dbName = 'test_db'; 23 var dbName = 'test_db';
24 var storeName = 'test_store'; 24 var storeName = 'test_store';
25 var indexName = 'name_index'; 25 var indexName = 'name_index';
26 var db; 26 var db;
27 27
28 futureTest('init', () { 28 test('init', () {
29 return html.window.indexedDB.deleteDatabase(dbName).then((_) { 29 return html.window.indexedDB.deleteDatabase(dbName).then((_) {
30 return html.window.indexedDB.open(dbName, version: 1, 30 return html.window.indexedDB.open(dbName, version: 1,
31 onUpgradeNeeded: (e) { 31 onUpgradeNeeded: (e) {
32 var db = e.target.result; 32 var db = e.target.result;
33 var objectStore = db.createObjectStore(storeName, 33 var objectStore = db.createObjectStore(storeName,
34 autoIncrement: true); 34 autoIncrement: true);
35 var index = objectStore.createIndex(indexName, 'name_index', 35 var index = objectStore.createIndex(indexName, 'name_index',
36 unique: false); 36 unique: false);
37 }); 37 });
38 }).then((database) { 38 }).then((database) {
39 db = database; 39 db = database;
40 }); 40 });
41 }); 41 });
42 42
43 if (html.window.indexedDB.supportsDatabaseNames) { 43 if (html.window.indexedDB.supportsDatabaseNames) {
44 futureTest('getDatabaseNames', () { 44 test('getDatabaseNames', () {
45 return html.window.indexedDB.getDatabaseNames().then((names) { 45 return html.window.indexedDB.getDatabaseNames().then((names) {
46 expect(names.contains(dbName), isTrue); 46 expect(names.contains(dbName), isTrue);
47 }); 47 });
48 }); 48 });
49 } 49 }
50 50
51 var value = {'name_index': 'one', 'value': 'add_value'}; 51 var value = {'name_index': 'one', 'value': 'add_value'};
52 futureTest('add/delete', () { 52 test('add/delete', () {
53 var transaction = db.transaction([storeName], 'readwrite'); 53 var transaction = db.transaction([storeName], 'readwrite');
54 var key; 54 var key;
55 return transaction.objectStore(storeName).add(value).then((addedKey) { 55 return transaction.objectStore(storeName).add(value).then((addedKey) {
56 key = addedKey; 56 key = addedKey;
57 }).then((_) { 57 }).then((_) {
58 return transaction.completed; 58 return transaction.completed;
59 }).then((_) { 59 }).then((_) {
60 transaction = db.transaction([storeName], 'readonly'); 60 transaction = db.transaction([storeName], 'readonly');
61 return transaction.objectStore(storeName).getObject(key); 61 return transaction.objectStore(storeName).getObject(key);
62 }).then((readValue) { 62 }).then((readValue) {
63 expect(readValue['value'], value['value']); 63 expect(readValue['value'], value['value']);
64 return transaction.completed; 64 return transaction.completed;
65 }).then((_) { 65 }).then((_) {
66 transaction = db.transaction([storeName], 'readwrite'); 66 transaction = db.transaction([storeName], 'readwrite');
67 return transaction.objectStore(storeName).delete(key); 67 return transaction.objectStore(storeName).delete(key);
68 }).then((_) { 68 }).then((_) {
69 return transaction.completed; 69 return transaction.completed;
70 }).then((_) { 70 }).then((_) {
71 var transaction = db.transaction([storeName], 'readonly'); 71 var transaction = db.transaction([storeName], 'readonly');
72 return transaction.objectStore(storeName).count(); 72 return transaction.objectStore(storeName).count();
73 }).then((count) { 73 }).then((count) {
74 expect(count, 0); 74 expect(count, 0);
75 }); 75 });
76 }); 76 });
77 77
78 futureTest('clear/count', () { 78 test('clear/count', () {
79 var transaction = db.transaction([storeName], 'readwrite'); 79 var transaction = db.transaction([storeName], 'readwrite');
80 transaction.objectStore(storeName).add(value); 80 transaction.objectStore(storeName).add(value);
81 81
82 return transaction.completed.then((_) { 82 return transaction.completed.then((_) {
83 transaction = db.transaction([storeName], 'readonly'); 83 transaction = db.transaction([storeName], 'readonly');
84 return transaction.objectStore(storeName).count(); 84 return transaction.objectStore(storeName).count();
85 }).then((count) { 85 }).then((count) {
86 expect(count, 1); 86 expect(count, 1);
87 }).then((_) { 87 }).then((_) {
88 return transaction.completed; 88 return transaction.completed;
89 }).then((_) { 89 }).then((_) {
90 transaction = db.transaction([storeName], 'readwrite'); 90 transaction = db.transaction([storeName], 'readwrite');
91 transaction.objectStore(storeName).clear(); 91 transaction.objectStore(storeName).clear();
92 return transaction.completed; 92 return transaction.completed;
93 }).then((_) { 93 }).then((_) {
94 var transaction = db.transaction([storeName], 'readonly'); 94 var transaction = db.transaction([storeName], 'readonly');
95 return transaction.objectStore(storeName).count(); 95 return transaction.objectStore(storeName).count();
96 }).then((count) { 96 }).then((count) {
97 expect(count, 0); 97 expect(count, 0);
98 }); 98 });
99 }); 99 });
100 100
101 futureTest('index', () { 101 test('index', () {
102 var transaction = db.transaction([storeName], 'readwrite'); 102 var transaction = db.transaction([storeName], 'readwrite');
103 transaction.objectStore(storeName).add(value); 103 transaction.objectStore(storeName).add(value);
104 transaction.objectStore(storeName).add(value); 104 transaction.objectStore(storeName).add(value);
105 transaction.objectStore(storeName).add(value); 105 transaction.objectStore(storeName).add(value);
106 transaction.objectStore(storeName).add(value); 106 transaction.objectStore(storeName).add(value);
107 107
108 return transaction.completed.then((_) { 108 return transaction.completed.then((_) {
109 transaction = db.transaction([storeName], 'readonly'); 109 transaction = db.transaction([storeName], 'readonly');
110 var index = transaction.objectStore(storeName).index(indexName); 110 var index = transaction.objectStore(storeName).index(indexName);
111 return index.count(); 111 return index.count();
(...skipping 24 matching lines...) Expand all
136 }).then((_) { 136 }).then((_) {
137 transaction = db.transaction([storeName], 'readwrite'); 137 transaction = db.transaction([storeName], 'readwrite');
138 transaction.objectStore(storeName).clear(); 138 transaction.objectStore(storeName).clear();
139 return transaction.completed; 139 return transaction.completed;
140 }); 140 });
141 }); 141 });
142 142
143 var deleteValue = {'name_index': 'two', 'value': 'delete_value'}; 143 var deleteValue = {'name_index': 'two', 'value': 'delete_value'};
144 var updateValue = {'name_index': 'three', 'value': 'update_value'}; 144 var updateValue = {'name_index': 'three', 'value': 'update_value'};
145 var updatedValue = {'name_index': 'three', 'value': 'updated_value'}; 145 var updatedValue = {'name_index': 'three', 'value': 'updated_value'};
146 futureTest('cursor', () { 146 test('cursor', () {
147 var transaction = db.transaction([storeName], 'readwrite'); 147 var transaction = db.transaction([storeName], 'readwrite');
148 transaction.objectStore(storeName).add(value); 148 transaction.objectStore(storeName).add(value);
149 transaction.objectStore(storeName).add(deleteValue); 149 transaction.objectStore(storeName).add(deleteValue);
150 transaction.objectStore(storeName).add(updateValue); 150 transaction.objectStore(storeName).add(updateValue);
151 151
152 return transaction.completed.then((_) { 152 return transaction.completed.then((_) {
153 transaction = db.transaction([storeName], 'readwrite'); 153 transaction = db.transaction([storeName], 'readwrite');
154 var index = transaction.objectStore(storeName).index(indexName); 154 var index = transaction.objectStore(storeName).index(indexName);
155 var cursors = index.openCursor().asBroadcastStream(); 155 var cursors = index.openCursor().asBroadcastStream();
156 156
(...skipping 26 matching lines...) Expand all
183 transaction = db.transaction([storeName], 'readonly'); 183 transaction = db.transaction([storeName], 'readonly');
184 var index = transaction.objectStore(storeName).index(indexName); 184 var index = transaction.objectStore(storeName).index(indexName);
185 return index.get('two'); 185 return index.get('two');
186 }).then((readValue) { 186 }).then((readValue) {
187 expect(readValue, isNull); 187 expect(readValue, isNull);
188 return transaction.completed; 188 return transaction.completed;
189 }); 189 });
190 }); 190 });
191 }); 191 });
192 } 192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698