From ba9d5e924878256a69e3af76d3a6838c1a209dbb Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Wed, 8 Feb 2017 21:43:22 -0800 Subject: [PATCH] Add tests for Baseline. (#8021) --- .../flutter/test/widgets/baseline_test.dart | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 packages/flutter/test/widgets/baseline_test.dart diff --git a/packages/flutter/test/widgets/baseline_test.dart b/packages/flutter/test/widgets/baseline_test.dart new file mode 100644 index 0000000000..fa382bcb0e --- /dev/null +++ b/packages/flutter/test/widgets/baseline_test.dart @@ -0,0 +1,43 @@ +// Copyright 2016 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_test/flutter_test.dart'; +import 'package:flutter/widgets.dart'; + +void main() { + testWidgets('Baseline - control test', (WidgetTester tester) async { + await tester.pumpWidget( + new Center( + child: new DefaultTextStyle( + style: new TextStyle( + fontFamily: 'Ahem', + fontSize: 100.0, + ), + child: new Text('X'), + ), + ), + ); + expect(tester.renderObject(find.text('X')).size, const Size(100.0, 100.0)); + }); + + testWidgets('Baseline - position test', (WidgetTester tester) async { + await tester.pumpWidget( + new Center( + child: new Baseline( + baseline: 180.0, + baselineType: TextBaseline.alphabetic, + child: new DefaultTextStyle( + style: new TextStyle( + fontFamily: 'Ahem', + fontSize: 100.0, + ), + child: new Text('X'), + ), + ), + ), + ); + expect(tester.renderObject(find.text('X')).size, const Size(100.0, 100.0)); + expect(tester.renderObject(find.byType(Baseline)).size, const Size(100.0, 200.0)); + }); +}