You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.9 KiB
89 lines
2.9 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:meshcore_open/l10n/app_localizations.dart';
|
|
import 'package:meshcore_open/services/ui_view_state_service.dart';
|
|
import 'package:meshcore_open/widgets/app_shell.dart';
|
|
import 'package:meshcore_open/widgets/quick_switch_bar.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
// #1274: the bar was a frosted BackdropFilter over a transparent background.
|
|
// Nothing was drawn behind it, so the blur only showed where it sampled the
|
|
// content above its top edge, as a glow over the light map.
|
|
void main() {
|
|
for (final brightness in Brightness.values) {
|
|
testWidgets('the bar is opaque with no blur ($brightness)', (tester) async {
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
localizationsDelegates: const [
|
|
AppLocalizations.delegate,
|
|
GlobalMaterialLocalizations.delegate,
|
|
GlobalWidgetsLocalizations.delegate,
|
|
],
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
theme: ThemeData(
|
|
colorScheme: ColorScheme.fromSeed(
|
|
seedColor: Colors.blue,
|
|
brightness: brightness,
|
|
),
|
|
useMaterial3: true,
|
|
),
|
|
home: Scaffold(
|
|
body: const SizedBox.expand(),
|
|
bottomNavigationBar: QuickSwitchBar(
|
|
selectedIndex: 2,
|
|
onDestinationSelected: (_) {},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
expect(find.byType(BackdropFilter), findsNothing);
|
|
final surface = tester.widget<Material>(
|
|
find
|
|
.descendant(
|
|
of: find.byType(NavigationBar),
|
|
matching: find.byType(Material),
|
|
)
|
|
.first,
|
|
);
|
|
expect(surface.color, isNotNull);
|
|
expect(surface.color!.a, 1.0);
|
|
});
|
|
}
|
|
|
|
testWidgets('in the shell, the bar paints down under the bottom inset', (
|
|
tester,
|
|
) async {
|
|
tester.view.physicalSize = const Size(400, 800);
|
|
tester.view.devicePixelRatio = 1;
|
|
tester.view.padding = const FakeViewPadding(bottom: 34);
|
|
addTearDown(tester.view.reset);
|
|
|
|
await tester.pumpWidget(
|
|
ChangeNotifierProvider(
|
|
create: (_) => UiViewStateService(),
|
|
child: MaterialApp(
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: AppShell(
|
|
isTopLevel: true,
|
|
selectedIndex: 2,
|
|
onDestinationSelected: (_) {},
|
|
body: const SizedBox.expand(),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
final surface = find
|
|
.descendant(
|
|
of: find.byType(NavigationBar),
|
|
matching: find.byType(Material),
|
|
)
|
|
.first;
|
|
expect(tester.getRect(surface).bottom, 800);
|
|
expect(tester.getRect(surface).height, greaterThanOrEqualTo(60 + 34));
|
|
});
|
|
}
|