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

Side by Side Diff: packages/observe/test/observable_list_test.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « packages/observe/pubspec.yaml ('k') | packages/path/.gitignore » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'package:observe/observe.dart'; 6 import 'package:observe/observe.dart';
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'observe_test_utils.dart'; 8 import 'observe_test_utils.dart';
9 9
10 main() => dirtyCheckZone().run(_runTests); 10 main() => dirtyCheckZone().run(_runTests);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 262
263 return new Future(() { 263 return new Future(() {
264 expectChanges(propRecords, null); 264 expectChanges(propRecords, null);
265 expectChanges(listRecords, [ 265 expectChanges(listRecords, [
266 _change(1, addedCount: 1), 266 _change(1, addedCount: 1),
267 _change(4, removed: [1]) 267 _change(4, removed: [1])
268 ]); 268 ]);
269 }); 269 });
270 }); 270 });
271 271
272 test('sort of 2 elements', () {
273 var list = toObservable([3, 1]);
274 // Dummy listener to record changes.
275 // TODO(jmesserly): should we just record changes always, to support the s ync api?
276 sub = list.listChanges.listen((records) => null);
277 list.sort();
278 expect(list.deliverListChanges(), true);
279 list.sort();
280 expect(list.deliverListChanges(), false);
281 list.sort();
282 expect(list.deliverListChanges(), false);
283 });
284
272 test('clear', () { 285 test('clear', () {
273 list.clear(); 286 list.clear();
274 expect(list, []); 287 expect(list, []);
275 288
276 return new Future(() { 289 return new Future(() {
277 expectChanges(propRecords, [ 290 expectChanges(propRecords, [
278 _lengthChange(6, 0), 291 _lengthChange(6, 0),
279 new PropertyChangeRecord(list, #isEmpty, false, true), 292 new PropertyChangeRecord(list, #isEmpty, false, true),
280 new PropertyChangeRecord(list, #isNotEmpty, true, false), 293 new PropertyChangeRecord(list, #isNotEmpty, true, false),
281 ]); 294 ]);
282 expectChanges(listRecords, [_change(0, removed: [1, 2, 3, 1, 3, 4])]); 295 expectChanges(listRecords, [_change(0, removed: [1, 2, 3, 1, 3, 4])]);
283 }); 296 });
284 }); 297 });
285 }); 298 });
286 } 299 }
287 300
288 ObservableList list; 301 ObservableList list;
289 302
290 _lengthChange(int oldValue, int newValue) => 303 _lengthChange(int oldValue, int newValue) =>
291 new PropertyChangeRecord(list, #length, oldValue, newValue); 304 new PropertyChangeRecord(list, #length, oldValue, newValue);
292 305
293 _change(index, {removed: const [], addedCount: 0}) => new ListChangeRecord( 306 _change(index, {removed: const [], addedCount: 0}) => new ListChangeRecord(
294 list, index, removed: removed, addedCount: addedCount); 307 list, index, removed: removed, addedCount: addedCount);
308
OLDNEW
« no previous file with comments | « packages/observe/pubspec.yaml ('k') | packages/path/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698