Merge branch 'testing_branch' of https://gitlab.com/Crondung/hsma_cpd into testing_branch
commit
b337c8d25c
|
@ -0,0 +1,22 @@
|
||||||
|
import 'package:audioplayers/audioplayers.dart';
|
||||||
|
import 'package:smoke_cess_app/providers/audio_provider.dart';
|
||||||
|
|
||||||
|
class AudioProviderMock extends AudioProvider {
|
||||||
|
@override
|
||||||
|
bool get isMuted => true;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void stop() {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void playFinishSound() {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void mutePlayer() {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void unMutePlayer() {}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void playSourceAfterBeep(AssetSource source) {}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ import 'package:smoke_cess_app/providers/audio_provider.dart';
|
||||||
import 'package:smoke_cess_app/providers/timer_provider.dart';
|
import 'package:smoke_cess_app/providers/timer_provider.dart';
|
||||||
import 'package:smoke_cess_app/providers/workout_provider.dart';
|
import 'package:smoke_cess_app/providers/workout_provider.dart';
|
||||||
import 'package:smoke_cess_app/globals.dart' as globals;
|
import 'package:smoke_cess_app/globals.dart' as globals;
|
||||||
|
import '../mock/audio_provider_mock.dart';
|
||||||
import '../mock/db_mock.dart';
|
import '../mock/db_mock.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
@ -16,7 +17,7 @@ void main() {
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
timerProvider = TimerProvider();
|
timerProvider = TimerProvider();
|
||||||
audioProvider = AudioProvider();
|
audioProvider = AudioProviderMock();
|
||||||
workoutProvider = WorkoutProvider(timerProvider, audioProvider);
|
workoutProvider = WorkoutProvider(timerProvider, audioProvider);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:smoke_cess_app/providers/timer_provider.dart';
|
||||||
|
import 'package:smoke_cess_app/utils/timer_util.dart';
|
||||||
|
import 'package:smoke_cess_app/widgets/timer_widget.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('TimerWidget', () {
|
||||||
|
testWidgets('should display duration', (WidgetTester tester) async {
|
||||||
|
TimerProvider timerProvider = TimerProvider();
|
||||||
|
Duration duration = const Duration(minutes: 1);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: ChangeNotifierProvider(
|
||||||
|
create: (context) => timerProvider,
|
||||||
|
child: TimerWidget(duration: duration)))),
|
||||||
|
);
|
||||||
|
|
||||||
|
final durationTextFinder = find.text(formatTime(duration.inSeconds));
|
||||||
|
expect(durationTextFinder, findsOneWidget);
|
||||||
|
|
||||||
|
timerProvider.startTimer(duration);
|
||||||
|
await tester.pump(const Duration(seconds: 1));
|
||||||
|
expect(durationTextFinder, findsNothing);
|
||||||
|
expect(find.text(formatTime(duration.inSeconds - 1)), findsOneWidget);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
|
@ -5,37 +5,39 @@ import 'package:smoke_cess_app/widgets/entry_detail_widget.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
initializeDateFormatting('de');
|
initializeDateFormatting('de');
|
||||||
testWidgets('Entry Detail should use ExpansionTile if Comments is set',
|
group('EntryDetail', () {
|
||||||
(WidgetTester tester) async {
|
testWidgets('should use ExpansionTile if Comments is set',
|
||||||
await tester.pumpWidget(
|
(WidgetTester tester) async {
|
||||||
MaterialApp(
|
await tester.pumpWidget(
|
||||||
home: Scaffold(
|
MaterialApp(
|
||||||
body: EntryDetail(
|
home: Scaffold(
|
||||||
date: DateTime.now(),
|
body: EntryDetail(
|
||||||
entryComment: 'A comment',
|
date: DateTime.now(),
|
||||||
entryData: 'Test',
|
entryComment: 'A comment',
|
||||||
iconData: Icons.plus_one,
|
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',
|
testWidgets('should use ListTile if Comments is null',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
MaterialApp(
|
MaterialApp(
|
||||||
home: Scaffold(
|
home: Scaffold(
|
||||||
body: EntryDetail(
|
body: EntryDetail(
|
||||||
date: DateTime.now(),
|
date: DateTime.now(),
|
||||||
entryComment: 'A comment',
|
entryComment: 'A comment',
|
||||||
entryData: 'Test',
|
entryData: 'Test',
|
||||||
iconData: Icons.plus_one,
|
iconData: Icons.plus_one,
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(find.byType(ListTile), findsOneWidget);
|
expect(find.byType(ListTile), findsOneWidget);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue