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

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

Issue 2935873002: Revert "Address additional analysis issues in the observatory codebase." (Closed)
Patch Set: Created 3 years, 6 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/service/get_native_allocation_samples_test.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 4
5 library service_test_common; 5 library service_test_common;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io' show File, Platform; 8 import 'dart:io' show Platform;
9
10 import 'package:observatory/models.dart' as M; 9 import 'package:observatory/models.dart' as M;
11 import 'package:observatory/service_common.dart'; 10 import 'package:observatory/service_common.dart';
12 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
13 12
14 typedef Future IsolateTest(Isolate isolate); 13 typedef Future IsolateTest(Isolate isolate);
15 typedef Future VMTest(VM vm); 14 typedef Future VMTest(VM vm);
16 15
17 Map<String, StreamSubscription> streamSubscriptions = {}; 16 Map<String, StreamSubscription> streamSubscriptions = {};
18 17
19 class ScriptLineParser {
20 List<String> lines;
21
22 ScriptLineParser(Uri scriptUri) {
23 String content = new File(scriptUri.toFilePath()).readAsStringSync();
24 lines = content.split('\n');
25 }
26
27 int lineFor(String commentContent) {
28 String match1 = '// $commentContent';
29 String match2 = '/* $commentContent */';
30
31 for (int i = 0; i < lines.length; i++) {
32 if (lines[i].contains(match1) || lines[i].contains(match2)) {
33 // return the 1-based line number
34 return i + 1;
35 }
36 }
37
38 return -1;
39 }
40 }
41
42 Future subscribeToStream(VM vm, String streamName, onEvent) async { 18 Future subscribeToStream(VM vm, String streamName, onEvent) async {
43 assert(streamSubscriptions[streamName] == null); 19 assert(streamSubscriptions[streamName] == null);
44 20
45 Stream stream = await vm.getEventStream(streamName); 21 Stream stream = await vm.getEventStream(streamName);
46 StreamSubscription subscription = stream.listen(onEvent); 22 StreamSubscription subscription = stream.listen(onEvent);
47 streamSubscriptions[streamName] = subscription; 23 streamSubscriptions[streamName] = subscription;
48 } 24 }
49 25
50 Future cancelStreamSubscription(String streamName) async { 26 Future cancelStreamSubscription(String streamName) async {
51 StreamSubscription subscription = streamSubscriptions[streamName]; 27 StreamSubscription subscription = streamSubscriptions[streamName];
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 if (!isKernel()) { 525 if (!isKernel()) {
550 nonKernelFunction(); 526 nonKernelFunction();
551 } 527 }
552 } 528 }
553 529
554 void kernelExecute(Function kernelFunction) { 530 void kernelExecute(Function kernelFunction) {
555 if (isKernel()) { 531 if (isKernel()) {
556 kernelFunction(); 532 kernelFunction();
557 } 533 }
558 } 534 }
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/get_native_allocation_samples_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698