Chromium Code Reviews| Index: runtime/observatory/tests/observatory_ui/isolate_ref_test.dart |
| diff --git a/runtime/observatory/tests/observatory_ui/isolate_ref_test.dart b/runtime/observatory/tests/observatory_ui/isolate_ref_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5acd06733f88f0ed53755204cd26635f4ce8957e |
| --- /dev/null |
| +++ b/runtime/observatory/tests/observatory_ui/isolate_ref_test.dart |
| @@ -0,0 +1,72 @@ |
| +// 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/repositories.dart'; |
| +import 'package:observatory/src/elements/isolate_ref.dart'; |
| + |
| +import 'helpers/webcomponents.dart'; |
| + |
| +main() async{ |
|
rmacnak
2016/07/11 17:54:01
async {
cbernaschina
2016/07/11 18:14:12
This was replaced in the last version. Going to up
|
| + await loadWebComponents(); |
| + IsolateRefElement.tag.ensureRegistration(); |
| + |
| + StreamController<IsolateUpdateEvent> updatesController; |
| + final IsolateRefMock ref = new IsolateRefMock(id: 'id', name: 'old-name'); |
| + final IsolateMock obj = new IsolateMock(id: 'id', name: 'new-name'); |
| + setUp(() { |
| + updatesController = new StreamController<IsolateUpdateEvent>(); |
| + }); |
| + group('instantiation', () { |
| + test('IsolateRef', () { |
| + final IsolateRefElement e = new IsolateRefElement(ref, |
| + updatesController.stream); |
| + expect(e, isNotNull, reason: 'element correctly created'); |
| + expect(e.isolate, equals(ref)); |
| + }); |
| + test('Isolate', () { |
| + final IsolateRefElement e = new IsolateRefElement(obj, |
| + updatesController.stream); |
| + expect(e, isNotNull, reason: 'element correctly created'); |
| + expect(e.isolate, equals(obj)); |
| + }); |
| + }); |
| + group('elements', () { |
| + test('created after attachment', () { |
| + final IsolateRefElement e = new IsolateRefElement(ref, |
| + updatesController.stream); |
| + expect(e.children.length, isZero, |
| + reason: 'is empty'); |
| + document.body.append(e); |
| + expect(e.children.length, isNonZero, |
| + reason: 'has elements'); |
| + e.remove(); |
| + }); |
| + }); |
| + group('updates', () { |
| + test('are correctly listen', () { |
| + final IsolateRefElement e = new IsolateRefElement(ref, |
| + updatesController.stream); |
| + expect(updatesController.hasListener, isFalse); |
| + document.body.append(e); |
| + expect(updatesController.hasListener, isTrue); |
| + e.remove(); |
| + expect(updatesController.hasListener, isFalse); |
| + }); |
| + test('have effects', () async { |
| + final IsolateRefElement e = new IsolateRefElement(ref, |
| + updatesController.stream); |
| + document.body.append(e); |
| + expect(e.innerHtml.contains(ref.id), isTrue); |
| + Future check() async { |
| + expect(e.innerHtml.contains(ref.name), isFalse); |
| + expect(e.innerHtml.contains(obj.name), isTrue); |
| + }; |
| + updatesController.add(new IsolateUpdateEvent(obj)); |
| + await check(); |
| + e.remove(); |
| + }); |
| + }); |
| +} |