• Adam Barth's avatar
    Fix several minor bugs and add many tests (#7506) · 2b742289
    Adam Barth authored
    * MultiTapGestureRecognizer previously would assert if there was no
       competition.
     * GestureArenaTeam would always select the first recongizer as the
       winner even if a later recognizer actually accepted the pointer
       sequence.
     * debugPrintStack would fail a type check if maxFrames was non-null.
     * FractionalOffset.lerp would throw a null-pointer exception if its
       second argument was null.
    
    Also, add a number of tests for previously untested lines of code.
    2b742289
assertions_test.dart 1.3 KB
// 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'));
  });

}