recognizer_test.dart 1.46 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 6
// @dart = 2.8

7 8 9 10
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';

class TestGestureRecognizer extends GestureRecognizer {
11 12
  TestGestureRecognizer({ Object debugOwner }) : super(debugOwner: debugOwner);

13
  @override
14
  String get debugDescription => 'debugDescription content';
15 16

  @override
17
  void addPointer(PointerDownEvent event) { }
18 19

  @override
20
  void acceptGesture(int pointer) { }
21 22

  @override
23
  void rejectGesture(int pointer) { }
24 25 26
}

void main() {
27
  test('GestureRecognizer smoketest', () {
28
    final TestGestureRecognizer recognizer = TestGestureRecognizer(debugOwner: 0);
29
    expect(recognizer, hasAGoodToStringDeep);
30
  });
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

  test('OffsetPair', () {
    const OffsetPair offset1 = OffsetPair(
      local: Offset(10, 20),
      global: Offset(30, 40),
    );

    expect(offset1.local, const Offset(10, 20));
    expect(offset1.global, const Offset(30, 40));

    const OffsetPair offset2 = OffsetPair(
      local: Offset(50, 60),
      global: Offset(70, 80),
    );

    final OffsetPair sum = offset2 + offset1;
    expect(sum.local, const Offset(60, 80));
    expect(sum.global, const Offset(100, 120));

    final OffsetPair difference = offset2 - offset1;
    expect(difference.local, const Offset(40, 40));
    expect(difference.global, const Offset(40, 40));

  });
55
}