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

Side by Side Diff: runtime/observatory/tests/service/developer_service_get_isolate_id_test.dart

Issue 2542003002: Add getIsolateID to Service class in dart:developer (Closed)
Patch Set: fix test Created 4 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 | « runtime/lib/developer.dart ('k') | runtime/observatory/tests/service/service_test_common.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4 // VMOptions=--error_on_bad_type --error_on_bad_override
5
6 import 'dart:async';
7 import 'dart:developer' as dev;
8 import 'dart:isolate' as Core;
9
10 import 'package:observatory/service_io.dart' as Service;
11 import 'package:unittest/unittest.dart';
12 import 'service_test_common.dart';
13 import 'test_helper.dart';
14
15
16 // testee state.
17 String selfId;
18 Core.Isolate childIsolate;
19 String childId;
20
21 void spawnEntry(int i) {
22 dev.debugger();
23 }
24
25 Future testeeMain() async {
26 dev.debugger();
27 // Spawn an isolate.
28 childIsolate = await Core.Isolate.spawn(spawnEntry, 0);
29 // Assign the id for this isolate and it's child to strings so they can
30 // be read by the tester.
31 selfId = dev.Service.getIsolateID(Core.Isolate.current);
32 childId = dev.Service.getIsolateID(childIsolate);
33 dev.debugger();
34 }
35
36 // tester state:
37 Service.Isolate initialIsolate;
38 Service.Isolate localChildIsolate;
39
40 var tests = [
41 (Service.VM vm) async {
42 // Sanity check.
43 expect(vm.isolates.length, 1);
44 initialIsolate = vm.isolates[0];
45 await hasStoppedAtBreakpoint(initialIsolate);
46 // Resume.
47 await initialIsolate.resume();
48 },
49 (Service.VM vm) async {
50 // Initial isolate has paused at second debugger call.
51 await hasStoppedAtBreakpoint(initialIsolate);
52 },
53 (Service.VM vm) async {
54 // Reload the VM.
55 await vm.reload();
56
57 // Grab the child isolate.
58 localChildIsolate =
59 vm.isolates.firstWhere(
60 (Service.Isolate i) => i != initialIsolate);
61 expect(localChildIsolate, isNotNull);
62
63 // Reload the initial isolate.
64 await initialIsolate.reload();
65
66 // Grab the root library.
67 Service.Library rootLbirary = await initialIsolate.rootLibrary.load();
68
69 // Grab self id.
70 Service.Instance localSelfId =
71 await initialIsolate.eval(rootLbirary, 'selfId');
72
73 // Check that the id reported from dart:developer matches the id reported
74 // from the service protocol.
75 expect(localSelfId.isString, true);
76 expect(initialIsolate.id, equals(localSelfId.valueAsString));
77
78 // Grab the child isolate's id.
79 Service.Instance localChildId =
80 await initialIsolate.eval(rootLbirary, 'childId');
81
82 // Check that the id reported from dart:developer matches the id reported
83 // from the service protocol.
84 expect(localChildId.isString, true);
85 expect(localChildIsolate.id, equals(localChildId.valueAsString));
86 }
87 ];
88
89 main(args) async => runVMTests(args, tests,
90 testeeConcurrent: testeeMain);
OLDNEW
« no previous file with comments | « runtime/lib/developer.dart ('k') | runtime/observatory/tests/service/service_test_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698