stack_trace_test.dart 1.37 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
@TestOn('!chrome')
6
import 'package:flutter/foundation.dart';
7
import '../flutter_test_alternative.dart';
8 9

void main() {
10 11
  // TODO(ianh): These tests and the filtering mechanism should be revisited to
  // account for causal async stack traces. https://github.com/flutter/flutter/issues/8128
12
  test('FlutterError.defaultStackFilter', () {
13
    final List<String> filtered = FlutterError.defaultStackFilter(StackTrace.current.toString().trimRight().split('\n')).toList();
14
    expect(filtered.length, greaterThanOrEqualTo(4));
15
    expect(filtered[0], matches(r'^#0 +main\.<anonymous closure> \(.*stack_trace_test\.dart:[0-9]+:[0-9]+\)$'));
16
    expect(filtered[1], matches(r'^#1 +Declarer\.test\.<anonymous closure>.<anonymous closure> \(package:test_api/.+:[0-9]+:[0-9]+\)$'));
17
    expect(filtered[2], equals('<asynchronous suspension>'));
18
  }, skip: kIsWeb);
19 20

  test('FlutterError.defaultStackFilter (async test body)', () async {
21
    final List<String> filtered = FlutterError.defaultStackFilter(StackTrace.current.toString().trimRight().split('\n')).toList();
22
    expect(filtered.length, greaterThanOrEqualTo(3));
23
    expect(filtered[0], matches(r'^#0 +main\.<anonymous closure> \(.*stack_trace_test\.dart:[0-9]+:[0-9]+\)$'));
24 25
  });
}