mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-10-11 02:08:44 +02:00
143 lines
4.7 KiB
Dart
143 lines
4.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:liquid_glass_easy/liquid_glass_easy.dart';
|
|
import 'package:spotiflac_android/providers/runtime_profile_provider.dart';
|
|
import 'package:spotiflac_android/theme/mornye_theme.dart';
|
|
import 'package:spotiflac_android/widgets/app_switch.dart';
|
|
import 'package:spotiflac_android/widgets/mornye_chrome.dart';
|
|
|
|
MornyeGlassLevel _levelFor({
|
|
required bool lowEnd,
|
|
required bool blur,
|
|
required bool liquidCapable,
|
|
}) {
|
|
final container = ProviderContainer(
|
|
overrides: [
|
|
lowEndDeviceProvider.overrideWithValue(lowEnd),
|
|
// Device default or the user's "always use blur effects" override.
|
|
backdropBlurEnabledProvider.overrideWithValue(blur),
|
|
deviceSupportsLiquidGlassProvider.overrideWithValue(liquidCapable),
|
|
],
|
|
);
|
|
addTearDown(container.dispose);
|
|
return container.read(mornyeGlassLevelProvider);
|
|
}
|
|
|
|
void main() {
|
|
test('runtime tiers map to Mornye glass levels', () {
|
|
// Low tier: arm32-only or low-RAM Android.
|
|
expect(
|
|
_levelFor(lowEnd: true, blur: false, liquidCapable: false),
|
|
MornyeGlassLevel.flat,
|
|
);
|
|
// Standard Android: frosted blur without shader passes.
|
|
expect(
|
|
_levelFor(lowEnd: false, blur: false, liquidCapable: false),
|
|
MornyeGlassLevel.frosted,
|
|
);
|
|
// iOS runs the standard tier but keeps the full material.
|
|
expect(
|
|
_levelFor(lowEnd: false, blur: false, liquidCapable: true),
|
|
MornyeGlassLevel.liquid,
|
|
);
|
|
// High-tier Android.
|
|
expect(
|
|
_levelFor(lowEnd: false, blur: true, liquidCapable: true),
|
|
MornyeGlassLevel.liquid,
|
|
);
|
|
// "Always use blur effects" restores the full material on any tier.
|
|
for (final lowEnd in [true, false]) {
|
|
expect(
|
|
_levelFor(lowEnd: lowEnd, blur: true, liquidCapable: false),
|
|
MornyeGlassLevel.liquid,
|
|
);
|
|
}
|
|
});
|
|
|
|
testWidgets('frosted level keeps blur but drops every shader surface', (
|
|
tester,
|
|
) async {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
overrides: [
|
|
deviceSupportsLiquidGlassProvider.overrideWithValue(false),
|
|
backdropBlurEnabledProvider.overrideWithValue(false),
|
|
],
|
|
child: MaterialApp(
|
|
theme: MornyeTheme.build(Brightness.dark),
|
|
home: Scaffold(
|
|
body: Column(
|
|
children: [
|
|
const MornyeGlass(
|
|
blurEnabled: true,
|
|
child: SizedBox(width: 200, height: 50),
|
|
),
|
|
MornyeSegmentedControl(
|
|
labels: const ['One', 'Two'],
|
|
selectedIndex: 0,
|
|
onChanged: (_) {},
|
|
),
|
|
AppSwitch(value: true, onChanged: (_) {}),
|
|
Consumer(
|
|
builder: (context, ref, _) => MornyeTabBar(
|
|
destinations: const [
|
|
NavigationDestination(
|
|
icon: Icon(Icons.home),
|
|
label: 'Home',
|
|
),
|
|
NavigationDestination(
|
|
icon: Icon(Icons.music_note),
|
|
label: 'Library',
|
|
),
|
|
],
|
|
selectedIndex: 0,
|
|
onSelected: (_) {},
|
|
blurEnabled: ref.watch(mornyeBlurEnabledProvider),
|
|
liquidGlass: ref.watch(mornyeLiquidGlassProvider),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
|
|
expect(find.byType(LiquidGlassLens), findsNothing);
|
|
expect(find.byType(LiquidGlassTabBar), findsNothing);
|
|
expect(find.byType(LiquidGlassSwitch), findsNothing);
|
|
// The frosted material still samples the page behind it.
|
|
expect(find.byType(BackdropFilter), findsWidgets);
|
|
expect(find.text('Library'), findsOneWidget);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
|
|
testWidgets('liquid level keeps the shader glass', (tester) async {
|
|
await tester.pumpWidget(
|
|
ProviderScope(
|
|
child: MaterialApp(
|
|
theme: MornyeTheme.build(Brightness.dark),
|
|
home: Scaffold(
|
|
body: Column(
|
|
children: [
|
|
const MornyeGlass(
|
|
blurEnabled: true,
|
|
child: SizedBox(width: 200, height: 50),
|
|
),
|
|
AppSwitch(value: true, onChanged: (_) {}),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pump();
|
|
|
|
expect(find.byType(LiquidGlassLens), findsWidgets);
|
|
expect(find.byType(LiquidGlassSwitch), findsOneWidget);
|
|
expect(tester.takeException(), isNull);
|
|
});
|
|
}
|