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

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

Issue 2767533002: Revert "Fix observatory tests broken by running dartfmt." (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // VMOptions=--error_on_bad_type --error_on_bad_override 4 // VMOptions=--error_on_bad_type --error_on_bad_override
5 5
6 import 'package:observatory/models.dart' as M; 6 import 'package:observatory/models.dart' as M;
7 import 'package:observatory/service_io.dart'; 7 import 'package:observatory/service_io.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 import 'service_test_common.dart'; 9 import 'service_test_common.dart';
10 import 'test_helper.dart'; 10 import 'test_helper.dart';
11 import 'dart:async'; 11 import 'dart:async';
12 import 'dart:isolate' as isolate; 12 import 'dart:isolate' as isolate;
13 import 'dart:developer' as developer; 13 import 'dart:developer' as developer;
14 14
15 int counter = 0; 15 int counter = 0;
16 const stoppedAtLine = 25; 16 const stoppedAtLine = 25;
17 var port = new isolate.RawReceivePort(msgHandler); 17 var port = new isolate.RawReceivePort(msgHandler);
18 18
19 // This name is used in a test below. 19 // This name is used in a test below.
20 void msgHandler(_) {} 20 void msgHandler(_) { }
21 21
22 void periodicTask(_) { 22 void periodicTask(_) {
23 port.sendPort.send(34); 23 port.sendPort.send(34);
24 developer.debugger(message: "fo", when: true); // We will be at the next line. 24 developer.debugger(message: "fo", when: true); // We will be at the next line.
25 counter++; 25 counter++;
26 if (counter % 300 == 0) { 26 if (counter % 300 == 0) {
27 print('counter = $counter'); 27 print('counter = $counter');
28 } 28 }
29 } 29 }
30 30
31 void startTimer() { 31 void startTimer() {
32 new Timer.periodic(const Duration(milliseconds: 10), periodicTask); 32 new Timer.periodic(const Duration(milliseconds:10), periodicTask);
33 } 33 }
34 34
35 var tests = [ 35 var tests = [
36
36 // Initial data fetch and verify we've hit the breakpoint. 37 // Initial data fetch and verify we've hit the breakpoint.
37 (Isolate isolate) async { 38 (Isolate isolate) async {
38 await isolate.rootLibrary.load(); 39 await isolate.rootLibrary.load();
39 var script = isolate.rootLibrary.scripts[0]; 40 var script = isolate.rootLibrary.scripts[0];
40 await script.load(); 41 await script.load();
41 await hasStoppedAtBreakpoint(isolate); 42 await hasStoppedAtBreakpoint(isolate);
42 // Sanity check. 43 // Sanity check.
43 expect(isolate.pauseEvent is M.PauseBreakpointEvent, isTrue); 44 expect(isolate.pauseEvent is M.PauseBreakpointEvent, isTrue);
44 }, 45 },
45 46
46 // Get stack 47 // Get stack
47 (Isolate isolate) async { 48 (Isolate isolate) async {
48 var stack = await isolate.getStack(); 49 var stack = await isolate.getStack();
49 expect(stack.type, equals('Stack')); 50 expect(stack.type, equals('Stack'));
50 51
51 // Sanity check. 52 // Sanity check.
52 expect(stack['frames'].length, greaterThanOrEqualTo(1)); 53 expect(stack['frames'].length, greaterThanOrEqualTo(1));
53 Script script = stack['frames'][0].location.script; 54 Script script = stack['frames'][0].location.script;
54 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), 55 expect(script.tokenToLine(stack['frames'][0].location.tokenPos),
55 equals(stoppedAtLine)); 56 equals(stoppedAtLine));
56 57
57 // Iterate over frames. 58 // Iterate over frames.
58 var frameDepth = 0; 59 var frameDepth = 0;
59 for (var frame in stack['frames']) { 60 for (var frame in stack['frames']) {
60 print('checking frame $frameDepth'); 61 print('checking frame $frameDepth');
61 expect(frame.type, equals('Frame')); 62 expect(frame.type, equals('Frame'));
62 expect(frame.index, equals(frameDepth++)); 63 expect(frame.index, equals(frameDepth++));
63 expect(frame.code.type, equals('Code')); 64 expect(frame.code.type, equals('Code'));
64 expect(frame.function.type, equals('Function')); 65 expect(frame.function.type, equals('Function'));
65 expect(frame.location.type, equals('SourceLocation')); 66 expect(frame.location.type, equals('SourceLocation'));
67 }
68
69 // Sanity check.
70 expect(stack['messages'].length, greaterThanOrEqualTo(1));
71
72 // Iterate over messages.
73 var messageDepth = 0;
74 // objectId of message to be handled by msgHandler.
75 var msgHandlerObjectId;
76 for (var message in stack['messages']) {
77 print('checking message $messageDepth');
78 expect(message.index, equals(messageDepth++));
79 expect(message.size, greaterThanOrEqualTo(0));
80 expect(message.handler.type, equals('Function'));
81 expect(message.location.type, equals('SourceLocation'));
82 if (message.handler.name.contains('msgHandler')) {
83 msgHandlerObjectId = message.messageObjectId;
66 } 84 }
85 }
86 expect(msgHandlerObjectId, isNotNull);
67 87
68 // Sanity check. 88 // Get object.
69 expect(stack['messages'].length, greaterThanOrEqualTo(1)); 89 var object = await isolate.getObject(msgHandlerObjectId);
90 expect(object.valueAsString, equals('34'));
91 }
70 92
71 // Iterate over messages.
72 var messageDepth = 0;
73 // objectId of message to be handled by msgHandler.
74 var msgHandlerObjectId;
75 for (var message in stack['messages']) {
76 print('checking message $messageDepth');
77 expect(message.index, equals(messageDepth++));
78 expect(message.size, greaterThanOrEqualTo(0));
79 expect(message.handler.type, equals('Function'));
80 expect(message.location.type, equals('SourceLocation'));
81 if (message.handler.name.contains('msgHandler')) {
82 msgHandlerObjectId = message.messageObjectId;
83 }
84 }
85 expect(msgHandlerObjectId, isNotNull);
86
87 // Get object.
88 var object = await isolate.getObject(msgHandlerObjectId);
89 expect(object.valueAsString, equals('34'));
90 }
91 ]; 93 ];
92 94
93 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); 95 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698