1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/foundation.dart';
import 'package:test/test.dart';
import 'capture_output.dart';
void main() {
test('debugPrintStack', () {
final List<String> log = captureOutput(() {
debugPrintStack(label: 'Example label', maxFrames: 7);
});
expect(log[0], contains('Example label'));
expect(log[1], contains('debugPrintStack'));
});
test('debugPrintStack', () {
final List<String> log = captureOutput(() {
final FlutterErrorDetails details = new FlutterErrorDetails(
exception: 'Example exception',
stack: StackTrace.current,
library: 'Example library',
context: 'Example context',
informationCollector: (StringBuffer information) {
information.writeln('Example information');
},
);
FlutterError.dumpErrorToConsole(details);
});
expect(log[0], contains('EXAMPLE LIBRARY'));
expect(log[1], contains('Example context'));
expect(log[2], contains('Example exception'));
final String joined = log.join('\n');
expect(joined, contains('captureOutput'));
expect(joined, contains('\nExample information\n'));
});
}