mute button test
parent
7b4d7abe4e
commit
58ce7fdb0e
|
@ -0,0 +1,34 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:smoke_cess_app/providers/audio_provider.dart';
|
||||
import 'package:smoke_cess_app/widgets/buttons/mute_button.dart';
|
||||
|
||||
void main() {
|
||||
group('MuteButton', () {
|
||||
testWidgets('should handle mute logic', (WidgetTester tester) async {
|
||||
AudioProvider audioProvider = AudioProvider();
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ChangeNotifierProvider(
|
||||
create: (context) => audioProvider,
|
||||
child: const MuteButton()))),
|
||||
);
|
||||
final button = find.byType(IconButton);
|
||||
final mutedIcon = find.byIcon(Icons.volume_off_outlined);
|
||||
final unMutedIcon = find.byIcon(Icons.volume_up_outlined);
|
||||
expect(audioProvider.isMuted, false);
|
||||
expect(button, findsOneWidget);
|
||||
expect(mutedIcon, findsNothing);
|
||||
expect(unMutedIcon, findsOneWidget);
|
||||
|
||||
await tester.tap(unMutedIcon);
|
||||
await tester.pump();
|
||||
|
||||
expect(audioProvider.isMuted, true);
|
||||
expect(mutedIcon, findsOneWidget);
|
||||
expect(unMutedIcon, findsNothing);
|
||||
});
|
||||
});
|
||||
}
|
|
@ -5,37 +5,39 @@ import 'package:smoke_cess_app/widgets/entry_detail_widget.dart';
|
|||
|
||||
void main() {
|
||||
initializeDateFormatting('de');
|
||||
testWidgets('Entry Detail should use ExpansionTile if Comments is set',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: EntryDetail(
|
||||
date: DateTime.now(),
|
||||
entryComment: 'A comment',
|
||||
entryData: 'Test',
|
||||
iconData: Icons.plus_one,
|
||||
),
|
||||
)),
|
||||
);
|
||||
group('EntryDetail', () {
|
||||
testWidgets('should use ExpansionTile if Comments is set',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: EntryDetail(
|
||||
date: DateTime.now(),
|
||||
entryComment: 'A comment',
|
||||
entryData: 'Test',
|
||||
iconData: Icons.plus_one,
|
||||
),
|
||||
)),
|
||||
);
|
||||
|
||||
expect(find.byType(ExpansionTile), findsOneWidget);
|
||||
});
|
||||
expect(find.byType(ExpansionTile), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Entry Detail should use ListTile if Comments is null',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: EntryDetail(
|
||||
date: DateTime.now(),
|
||||
entryComment: 'A comment',
|
||||
entryData: 'Test',
|
||||
iconData: Icons.plus_one,
|
||||
),
|
||||
)),
|
||||
);
|
||||
testWidgets('should use ListTile if Comments is null',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: EntryDetail(
|
||||
date: DateTime.now(),
|
||||
entryComment: 'A comment',
|
||||
entryData: 'Test',
|
||||
iconData: Icons.plus_one,
|
||||
),
|
||||
)),
|
||||
);
|
||||
|
||||
expect(find.byType(ListTile), findsOneWidget);
|
||||
expect(find.byType(ListTile), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue