mirror of
https://github.com/flutter/flutter
synced 2024-10-13 19:52:53 +00:00
74bd7b6f6d
* opt out the flutter tool * oops EOF * fix import * Update tool_backend.dart * Update daemon_client.dart * fix more
43 lines
1.3 KiB
Dart
43 lines
1.3 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// @dart = 2.8
|
|
|
|
import 'package:flutter_tools/src/base/utils.dart';
|
|
|
|
import '../src/common.dart';
|
|
|
|
void main() {
|
|
group('ItemListNotifier', () {
|
|
test('sends notifications', () async {
|
|
final ItemListNotifier<String> list = ItemListNotifier<String>();
|
|
expect(list.items, isEmpty);
|
|
|
|
final Future<List<String>> addedStreamItems = list.onAdded.toList();
|
|
final Future<List<String>> removedStreamItems = list.onRemoved.toList();
|
|
|
|
list.updateWithNewList(<String>['aaa']);
|
|
list.removeItem('bogus');
|
|
list.updateWithNewList(<String>['aaa', 'bbb', 'ccc']);
|
|
list.updateWithNewList(<String>['bbb', 'ccc']);
|
|
list.removeItem('bbb');
|
|
|
|
expect(list.items, <String>['ccc']);
|
|
list.dispose();
|
|
|
|
final List<String> addedItems = await addedStreamItems;
|
|
final List<String> removedItems = await removedStreamItems;
|
|
|
|
expect(addedItems.length, 3);
|
|
expect(addedItems.first, 'aaa');
|
|
expect(addedItems[1], 'bbb');
|
|
expect(addedItems[2], 'ccc');
|
|
|
|
expect(removedItems.length, 2);
|
|
expect(removedItems.first, 'aaa');
|
|
expect(removedItems[1], 'bbb');
|
|
});
|
|
});
|
|
}
|