Replace the native showTimePicker dialog in the alarm editor sheet with a giant inline HH:MM editor (drag/tap to adjust, wraps at 23:59-00:00). Weekday circles now render unconditionally (disabled outside weekly mode) instead of being gated behind an `if`. The date field, fallback-station picker, and sound dropdown are not dropped: per resolution 3 they move into a collapsed "Advanced" section so the mockup's weekday-circles-only layout does not lose capability. Volume/fade-in sliders get a cosmetic type-scale restyle only. size:exception: 993 changed lines (891+/102-) against the 500-650 forecast - lib/ production code alone is 429 lines, within band; new test files and 13 regenerated l10n/gen files account for the rest, the same pattern every prior work unit in this branch has hit.
169 lines
4.7 KiB
Dart
169 lines
4.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pluriwave/l10n/gen/app_localizations.dart';
|
|
import 'package:pluriwave/widgets/editor_hora_inline.dart';
|
|
|
|
/// WU10: standalone tests for the inline HH:MM editor, independent of
|
|
/// `_EditorAlarmaSheet` (the sheet only wires `value`/`onChanged`).
|
|
Future<void> _montar(
|
|
WidgetTester tester, {
|
|
required TimeOfDay inicial,
|
|
ValueChanged<TimeOfDay>? onChanged,
|
|
}) async {
|
|
var valor = inicial;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
locale: const Locale('es'),
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
|
home: Scaffold(
|
|
body: StatefulBuilder(
|
|
builder: (context, setState) {
|
|
return EditorHoraInline(
|
|
value: valor,
|
|
onChanged: (nuevo) {
|
|
setState(() => valor = nuevo);
|
|
onChanged?.call(nuevo);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
const _keyHora = ValueKey('editor-hora-inline-hora');
|
|
const _keyMinuto = ValueKey('editor-hora-inline-minuto');
|
|
|
|
void main() {
|
|
testWidgets('muestra la hora inicial formateada HH:MM', (tester) async {
|
|
await _montar(tester, inicial: const TimeOfDay(hour: 7, minute: 5));
|
|
|
|
expect(find.text('07'), findsOneWidget);
|
|
expect(find.text('05'), findsOneWidget);
|
|
expect(find.text(':'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('tocar el segmento de hora incrementa solo la hora', (
|
|
tester,
|
|
) async {
|
|
TimeOfDay? recibido;
|
|
await _montar(
|
|
tester,
|
|
inicial: const TimeOfDay(hour: 10, minute: 30),
|
|
onChanged: (nuevo) => recibido = nuevo,
|
|
);
|
|
|
|
await tester.tap(find.byKey(_keyHora));
|
|
await tester.pump();
|
|
|
|
expect(recibido, const TimeOfDay(hour: 11, minute: 30));
|
|
expect(find.text('11'), findsOneWidget);
|
|
expect(find.text('30'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('tocar el segmento de minuto incrementa solo el minuto', (
|
|
tester,
|
|
) async {
|
|
TimeOfDay? recibido;
|
|
await _montar(
|
|
tester,
|
|
inicial: const TimeOfDay(hour: 10, minute: 30),
|
|
onChanged: (nuevo) => recibido = nuevo,
|
|
);
|
|
|
|
await tester.tap(find.byKey(_keyMinuto));
|
|
await tester.pump();
|
|
|
|
expect(recibido, const TimeOfDay(hour: 10, minute: 31));
|
|
});
|
|
|
|
testWidgets(
|
|
'incrementar el minuto en 23:59 envuelve a 00:00 (hora y minuto)',
|
|
(tester) async {
|
|
TimeOfDay? recibido;
|
|
await _montar(
|
|
tester,
|
|
inicial: const TimeOfDay(hour: 23, minute: 59),
|
|
onChanged: (nuevo) => recibido = nuevo,
|
|
);
|
|
|
|
await tester.tap(find.byKey(_keyMinuto));
|
|
await tester.pump();
|
|
|
|
expect(recibido, const TimeOfDay(hour: 0, minute: 0));
|
|
},
|
|
);
|
|
|
|
testWidgets('incrementar la hora en 23 envuelve a 0 sin tocar el minuto', (
|
|
tester,
|
|
) async {
|
|
TimeOfDay? recibido;
|
|
await _montar(
|
|
tester,
|
|
inicial: const TimeOfDay(hour: 23, minute: 45),
|
|
onChanged: (nuevo) => recibido = nuevo,
|
|
);
|
|
|
|
await tester.tap(find.byKey(_keyHora));
|
|
await tester.pump();
|
|
|
|
expect(recibido, const TimeOfDay(hour: 0, minute: 45));
|
|
});
|
|
|
|
testWidgets(
|
|
'arrastrar hacia arriba en el minuto lo incrementa; hacia abajo lo '
|
|
'decrementa',
|
|
(tester) async {
|
|
TimeOfDay? recibido;
|
|
await _montar(
|
|
tester,
|
|
inicial: const TimeOfDay(hour: 10, minute: 30),
|
|
onChanged: (nuevo) => recibido = nuevo,
|
|
);
|
|
|
|
await tester.drag(find.byKey(_keyMinuto), const Offset(0, -96));
|
|
await tester.pump();
|
|
expect(recibido, isNotNull);
|
|
expect(recibido!.hour, 10);
|
|
expect(recibido!.minute, greaterThan(30));
|
|
final minutoTrasSubir = recibido!.minute;
|
|
|
|
await tester.drag(find.byKey(_keyMinuto), Offset(0, 96));
|
|
await tester.pump();
|
|
expect(recibido!.minute, lessThan(minutoTrasSubir));
|
|
},
|
|
);
|
|
|
|
testWidgets('expone acciones de accesibilidad de incrementar/decrementar con '
|
|
'etiqueta y valor', (tester) async {
|
|
final semantics = tester.ensureSemantics();
|
|
final l10n = await AppLocalizations.delegate.load(const Locale('es'));
|
|
await _montar(tester, inicial: const TimeOfDay(hour: 6, minute: 8));
|
|
|
|
expect(
|
|
tester.getSemantics(find.byKey(_keyHora)),
|
|
matchesSemantics(
|
|
label: l10n.alarmInlineHourLabel,
|
|
value: '06',
|
|
hasIncreaseAction: true,
|
|
hasDecreaseAction: true,
|
|
hasTapAction: true,
|
|
),
|
|
);
|
|
expect(
|
|
tester.getSemantics(find.byKey(_keyMinuto)),
|
|
matchesSemantics(
|
|
label: l10n.alarmInlineMinuteLabel,
|
|
value: '08',
|
|
hasIncreaseAction: true,
|
|
hasDecreaseAction: true,
|
|
hasTapAction: true,
|
|
),
|
|
);
|
|
|
|
semantics.dispose();
|
|
});
|
|
}
|