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

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

Issue 2930993004: 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 Platform; 8 import 'dart:io' show File, Platform;
9
9 import 'package:observatory/models.dart' as M; 10 import 'package:observatory/models.dart' as M;
10 import 'package:observatory/service_common.dart'; 11 import 'package:observatory/service_common.dart';
11 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
12 13
13 typedef Future IsolateTest(Isolate isolate); 14 typedef Future IsolateTest(Isolate isolate);
14 typedef Future VMTest(VM vm); 15 typedef Future VMTest(VM vm);
15 16
16 Map<String, StreamSubscription> streamSubscriptions = {}; 17 Map<String, StreamSubscription> streamSubscriptions = {};
17 18
19 class ScriptLineParser {
rmacnak 2017/06/12 16:02:12 Awesome!
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
18 Future subscribeToStream(VM vm, String streamName, onEvent) async { 42 Future subscribeToStream(VM vm, String streamName, onEvent) async {
19 assert(streamSubscriptions[streamName] == null); 43 assert(streamSubscriptions[streamName] == null);
20 44
21 Stream stream = await vm.getEventStream(streamName); 45 Stream stream = await vm.getEventStream(streamName);
22 StreamSubscription subscription = stream.listen(onEvent); 46 StreamSubscription subscription = stream.listen(onEvent);
23 streamSubscriptions[streamName] = subscription; 47 streamSubscriptions[streamName] = subscription;
24 } 48 }
25 49
26 Future cancelStreamSubscription(String streamName) async { 50 Future cancelStreamSubscription(String streamName) async {
27 StreamSubscription subscription = streamSubscriptions[streamName]; 51 StreamSubscription subscription = streamSubscriptions[streamName];
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 if (!isKernel()) { 549 if (!isKernel()) {
526 nonKernelFunction(); 550 nonKernelFunction();
527 } 551 }
528 } 552 }
529 553
530 void kernelExecute(Function kernelFunction) { 554 void kernelExecute(Function kernelFunction) {
531 if (isKernel()) { 555 if (isKernel()) {
532 kernelFunction(); 556 kernelFunction();
533 } 557 }
534 } 558 }
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