Commit f894edeb authored by xster's avatar xster Committed by GitHub

Use exact Ahem and exact dimensions for Cupertino button test (#8561)

* Use exact Ahem and exact dimensions for test

* use ‘px’ everywhere
parent 54d95416
......@@ -24,7 +24,7 @@ final TextStyle _kBackgroundButtonTextStyle = _kButtonTextStyle.copyWith(
const EdgeInsets _kButtonPadding = const EdgeInsets.all(16.0);
const EdgeInsets _kBackgroundButtonPadding =
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 64.0);
const EdgeInsets.symmetric(vertical: 16.0, horizontal: 64.0);
/// An iOS style button.
///
......
......@@ -7,56 +7,66 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
const TextStyle testStyle = const TextStyle(
fontFamily: 'Ahem',
fontSize: 10.0,
);
void main() {
testWidgets('Layout minimum size', (WidgetTester tester) async {
await tester.pumpWidget(
new Center(child: new CupertinoButton(child: new Text(' '), onPressed: null))
new Center(child: new CupertinoButton(
child: new Text('X', style: testStyle),
onPressed: null,
))
);
RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
expect(
buttonBox.size,
greaterThanOrEqualTo(const Size.square(48.0)),
);
expect(
buttonBox.size,
lessThan(const Size.square(100.0)),
// 1 10px character + 16px * 2 is smaller than the 48px minimum.
const Size.square(48.0),
);
});
testWidgets('Size grows with text', (WidgetTester tester) async {
await tester.pumpWidget(
new Center(child: new CupertinoButton(child: new Text('blah blah blah'), onPressed: null))
new Center(child: new CupertinoButton(
child: new Text('XXXX', style: testStyle),
onPressed: null,
))
);
RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
expect(
buttonBox.size.width,
greaterThan(48.0),
// 4 10px character + 16px * 2 = 72.
72.0,
);
});
testWidgets('Button with background is wider', (WidgetTester tester) async {
await tester.pumpWidget(new Center(child: new CupertinoButton(
child: new Text(' '),
child: new Text('X', style: testStyle),
onPressed: null,
color: new Color(0xFFFFFFFF),
)));
RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
expect(
buttonBox.size.width,
greaterThan(120.0),
// 1 10px character + 64 * 2 = 138 for buttons with background.
138.0,
);
});
testWidgets('Custom padding', (WidgetTester tester) async {
await tester.pumpWidget(new Center(child: new CupertinoButton(
child: new Text(' '),
child: new Text(' ', style: testStyle),
onPressed: null,
padding: new EdgeInsets.all(100.0),
)));
RenderBox buttonBox = tester.renderObject(find.byType(CupertinoButton));
expect(
buttonBox.size,
greaterThan(const Size.square(100.0)),
const Size.square(210.0),
);
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment