Index: runtime/observatory/tests/observatory_ui/flag-list/element_test.dart |
diff --git a/runtime/observatory/tests/observatory_ui/flag-list/element_test.dart b/runtime/observatory/tests/observatory_ui/flag-list/element_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e88dea66fd565943f5e98fca1d449e62d7d2d658 |
--- /dev/null |
+++ b/runtime/observatory/tests/observatory_ui/flag-list/element_test.dart |
@@ -0,0 +1,60 @@ |
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+import 'dart:html'; |
+import 'dart:async'; |
+import 'package:unittest/unittest.dart'; |
+import 'package:observatory/mocks.dart'; |
+import 'package:observatory/src/elements/flag_list.dart'; |
+import 'package:observatory/src/elements/nav/notify.dart'; |
+ |
+main() { |
+ FlagListElement.tag.ensureRegistration(); |
+ |
+ final nTag = NavNotifyElement.tag.name; |
+ const vm = const VMMock(name: 'vm'); |
+ final stream = new StreamController().stream; |
+ |
+ group('instantiation', () { |
+ test('default', () { |
+ final FlagListElement e = new FlagListElement(vm, stream, |
+ new FlagsRepositoryMock(), |
+ new NotificationRepositoryMock()); |
+ expect(e, isNotNull, reason: 'element correctly created'); |
+ }); |
+ }); |
+ group('elements', () { |
+ test('created after attachment', () async { |
+ const modified = const [ |
+ const FlagMock(name: 'f1', comment: 'c1', modified: true), |
+ ]; |
+ const unmodifed = const [ |
+ const FlagMock(name: 'f2', comment: 'c2', modified: false), |
+ const FlagMock(name: 'f3', comment: 'c3', modified: false), |
+ ]; |
+ final flags = new List.unmodifiable([]..addAll(modified) |
+ ..addAll(unmodifed)); |
+ final FlagListElement e = new FlagListElement(vm, stream, |
+ new FlagsRepositoryMock(list: expectAsync((input) async { |
+ expect(input, equals(vm)); |
+ return flags; |
+ }, count: 1)), new NotificationRepositoryMock()); |
+ document.body.append(e); |
+ await e.onRendered.first; |
+ expect(e.children.length, isNonZero, reason: 'has elements'); |
+ expect(e.querySelectorAll(nTag).length, equals(1)); |
+ expect(e.querySelectorAll('.flag').length, equals(flags.length)); |
+ expect(e.querySelectorAll('.flag.modified').length, |
+ equals(modified.length)); |
+ expect(e.querySelectorAll('.flag.unmodified').length, |
+ equals(unmodifed.length)); |
+ expect(e.querySelectorAll('.flag').length, equals(flags.length)); |
+ expect(e.querySelectorAll('.comment').length, equals(flags.length)); |
+ expect(e.querySelectorAll('.name').length, equals(flags.length)); |
+ expect(e.querySelectorAll('.value').length, equals(flags.length)); |
+ e.remove(); |
+ await e.onRendered.first; |
+ expect(e.children.length, isZero, reason: 'is empty'); |
+ }); |
+ }); |
+} |