Unverified Commit 7b7778a8 authored by Markus Aksli's avatar Markus Aksli Committed by GitHub

Add golden tests for default and overriden `expandedTitleScale` in `FlexibleSpaceBar` (#93059)

parent a4fa2aff
......@@ -2,6 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This file is run as part of a reduced test set in CI on Mac and Windows
// machines.
@Tags(<String>['reduced-test-set'])
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
......@@ -542,6 +546,127 @@ void main() {
);
});
testWidgets('FlexibleSpaceBar scaled title', (WidgetTester tester) async {
const double titleFontSize = 20.0;
const double height = 300.0;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: CustomScrollView(
slivers: <Widget>[
const SliverAppBar(
expandedHeight: height,
pinned: true,
stretch: true,
flexibleSpace: RepaintBoundary(
child: FlexibleSpaceBar(
title: Text(
'X',
style: TextStyle(fontSize: titleFontSize,),
),
centerTitle: false,
),
),
),
SliverList(
delegate: SliverChildListDelegate(
<Widget>[
for (int i = 0; i < 3; i += 1)
SizedBox(
height: 200.0,
child: Center(child: Text('Item $i')),
),
],
),
),
],
),
),
),
);
// We drag up to fully collapse the space bar.
await tester.drag(find.text('Item 0'), const Offset(0, -600.0));
await tester.pumpAndSettle();
final Finder flexibleSpaceBar = find.ancestor(of: find.byType(FlexibleSpaceBar), matching: find.byType(RepaintBoundary).first);
await expectLater(
flexibleSpaceBar,
matchesGoldenFile('flexible_space_bar.expanded_title_scale_default.collapsed.png')
);
// We drag down to fully expand the space bar.
await tester.drag(find.text('Item 2'), const Offset(0, 600.0));
await tester.pumpAndSettle();
await expectLater(
flexibleSpaceBar,
matchesGoldenFile('flexible_space_bar.expanded_title_scale_default.expanded.png')
);
});
testWidgets('FlexibleSpaceBar scaled title - override expandedTitleScale', (WidgetTester tester) async {
const double titleFontSize = 20.0;
const double height = 300.0;
const double expandedTitleScale = 3.0;
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: CustomScrollView(
slivers: <Widget>[
const SliverAppBar(
expandedHeight: height,
pinned: true,
stretch: true,
flexibleSpace: RepaintBoundary(
child: FlexibleSpaceBar(
title: Text(
'X',
style: TextStyle(fontSize: titleFontSize,),
),
centerTitle: false,
expandedTitleScale: expandedTitleScale,
),
),
),
SliverList(
delegate: SliverChildListDelegate(
<Widget>[
for (int i = 0; i < 3; i += 1)
SizedBox(
height: 200.0,
child: Center(child: Text('Item $i')),
),
],
),
),
],
),
),
),
);
// We drag up to fully collapse the space bar.
await tester.drag(find.text('Item 0'), const Offset(0, -600.0));
await tester.pumpAndSettle();
final Finder flexibleSpaceBar = find.ancestor(of: find.byType(FlexibleSpaceBar), matching: find.byType(RepaintBoundary).first);
// This should match the default behavior
await expectLater(
flexibleSpaceBar,
matchesGoldenFile('flexible_space_bar.expanded_title_scale_default.collapsed.png')
);
// We drag down to fully expand the space bar.
await tester.drag(find.text('Item 2'), const Offset(0, 600.0));
await tester.pumpAndSettle();
await expectLater(
flexibleSpaceBar,
matchesGoldenFile('flexible_space_bar.expanded_title_scale_override.expanded.png')
);
});
testWidgets('FlexibleSpaceBar test titlePadding defaults', (WidgetTester tester) async {
Widget buildFrame(TargetPlatform platform, bool? centerTitle) {
return MaterialApp(
......
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