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

Side by Side Diff: runtime/observatory/tests/observatory_ui/source_link/element_test.dart

Issue 2212253002: Converted Observatory class-tree element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Removed tmp code Created 4 years, 4 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
« no previous file with comments | « runtime/observatory/tests/observatory_ui/mocks/repositories/script.dart ('k') | no next file » | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:html'; 4 import 'dart:html';
5 import 'package:unittest/unittest.dart'; 5 import 'package:unittest/unittest.dart';
6 import 'package:observatory/models.dart' as M;
7 import 'package:observatory/src/elements/source_link.dart'; 6 import 'package:observatory/src/elements/source_link.dart';
8 import '../mocks.dart'; 7 import '../mocks.dart';
9 8
10 main() { 9 main() {
11 SourceLinkElement.tag.ensureRegistration(); 10 SourceLinkElement.tag.ensureRegistration();
12 11
13 const isolate = const IsolateRefMock(id: 'isolate-id'); 12 const isolate = const IsolateRefMock(id: 'isolate-id');
13 const script_id = 'script-id';
14 const file = 'filename.dart'; 14 const file = 'filename.dart';
15 final script = new ScriptMock(id: 'script-id', uri: 'package/$file', 15 final script = new ScriptMock(id: script_id, uri: 'package/$file',
16 tokenToLine: (int token) => 1, tokenToCol: (int token) => 2); 16 tokenToLine: (int token) => 1, tokenToCol: (int token) => 2);
17 final location = new SourceLocationMock(script: script, tokenPos: 0, 17 final location = new SourceLocationMock(script: script, tokenPos: 0,
18 endTokenPos: 1); 18 endTokenPos: 1);
19 M.ScriptRepository repository;
20 setUp(() {
21 repository = new ScriptRepositoryMock({ 'script-id': script });
22 });
23 test('instantiation', () { 19 test('instantiation', () {
24 final e = new SourceLinkElement(isolate, location, repository); 20 final e = new SourceLinkElement(isolate, location,
21 new ScriptRepositoryMock());
25 expect(e, isNotNull, reason: 'element correctly created'); 22 expect(e, isNotNull, reason: 'element correctly created');
26 expect(e.isolate, equals(isolate)); 23 expect(e.isolate, equals(isolate));
27 expect(e.location, equals(location)); 24 expect(e.location, equals(location));
28 }); 25 });
29 test('elements created after attachment', () async { 26 test('elements created after attachment', () async {
30 final e = new SourceLinkElement(isolate, location, repository); 27 bool rendered = false;
28 final e = new SourceLinkElement(isolate, location,
29 new ScriptRepositoryMock(getter: expectAsync((String id) async {
30 expect(rendered, isFalse);
31 expect(id, equals(script_id));
32 return script;
33 }, count: 1)));
31 document.body.append(e); 34 document.body.append(e);
32 await e.onRendered.first; 35 await e.onRendered.first;
36 rendered = true;
33 expect(e.children.length, isNonZero, reason: 'has elements'); 37 expect(e.children.length, isNonZero, reason: 'has elements');
34 expect(e.innerHtml.contains(isolate.id), isTrue, 38 expect(e.innerHtml.contains(isolate.id), isTrue,
35 reason: 'no message in the component'); 39 reason: 'no message in the component');
36 expect(e.innerHtml.contains(file), isTrue, 40 expect(e.innerHtml.contains(file), isTrue,
37 reason: 'no message in the component'); 41 reason: 'no message in the component');
38 e.remove(); 42 e.remove();
39 await e.onRendered.first; 43 await e.onRendered.first;
40 expect(e.children.length, isZero, 44 expect(e.children.length, isZero,
41 reason: 'is empty'); 45 reason: 'is empty');
42 }); 46 });
43 } 47 }
OLDNEW
« no previous file with comments | « runtime/observatory/tests/observatory_ui/mocks/repositories/script.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698