flutter/examples/layers/test/gestures_test.dart
Ian Hickson f235a2c104 RTL: Padding, Flex (#11709)
* Introduce a Directionality inherited widget which sets the ambient LTR vs RTL mode (defaulting to null, which means you cannot use directionality-influenced values).

* Make it possible to configure Padding (including Container.padding and Container.margin) using a directionality-agnostic EdgeInsets variant.

* Provide textDirection and verticalDirection controls on Row and Column to make them RTL-aware.

* Introduce a variant of FractionalOffset based on the EdgeInsets variant. Not yet actually used.

* Fix all the tests that depended on Row defaulting to LTR.
2017-08-28 12:50:24 -07:00

39 lines
1.2 KiB
Dart

// 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/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../widgets/gestures.dart';
void main() {
testWidgets('Tap on center change color', (WidgetTester tester) async {
await tester.pumpWidget(new Directionality(
textDirection: TextDirection.ltr,
child: new GestureDemo(),
));
final Finder finder = find.byType(GestureDemo);
MaterialColor getSwatch() => tester.state<GestureDemoState>(finder).swatch;
Future<Null> tap() async {
final Offset topLeft = tester.getTopLeft(finder);
await tester.tapAt(tester.getSize(finder).center(topLeft));
await tester.pump(const Duration(seconds: 1));
}
// initial swatch
expect(getSwatch(), GestureDemoState.kSwatches[0]);
// every tap change swatch
for (int i = 1; i < GestureDemoState.kSwatches.length; i++) {
await tap();
expect(getSwatch(), GestureDemoState.kSwatches[i]);
}
// tap on last swatch display first swatch
await tap();
expect(getSwatch(), GestureDemoState.kSwatches[0]);
});
}