Files
Qlyra/test/markup_editor_test.dart
T
sevenhill f74057ce9b
Build Android (FCM) / build-android-fcm (push) Canceled after 0s
Build Android / build-android (push) Canceled after 0s
Build iOS / build-ios (push) Canceled after 0s
Build Linux / build-linux (push) Canceled after 0s
Build macOS / build-macos (push) Canceled after 0s
Build Windows / build-windows (push) Canceled after 0s
Release (main) / android (oneme) (push) Canceled after 0s
Release (main) / android (qlyra) (push) Canceled after 0s
Release (main) / windows (push) Canceled after 0s
Release (main) / linux (push) Canceled after 0s
Release (main) / macos (push) Canceled after 0s
Release (main) / ios (push) Canceled after 0s
Release (main) / release (push) Canceled after 0s
Rebrand application as Qlyra
2026-08-30 13:16:17 +03:00

74 lines
2.1 KiB
Dart

import 'dart:async';
import 'dart:io';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:material_symbols_icons/symbols.dart';
import 'package:qlyra/frontend/widgets/attachment/photo_editor.dart';
import 'package:qlyra/l10n/app_localizations.dart';
void main() {
late Directory tmp;
late File source;
setUpAll(() async {
tmp = Directory.systemTemp.createTempSync('qlyra_markup_test');
final recorder = ui.PictureRecorder();
Canvas(recorder).drawRect(
const Rect.fromLTWH(0, 0, 8, 8),
Paint()..color = const Color(0xFF224466),
);
final image = await recorder.endRecording().toImage(8, 8);
final data = await image.toByteData(format: ui.ImageByteFormat.png);
image.dispose();
source = File('${tmp.path}/source.png')
..writeAsBytesSync(data!.buffer.asUint8List());
});
tearDownAll(() => tmp.deleteSync(recursive: true));
testWidgets('пустая разметка закрывается без результата', (tester) async {
var previews = 0;
Object? popped = 'untouched';
late BuildContext context;
await tester.pumpWidget(
MaterialApp(
locale: const Locale('ru'),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Builder(
builder: (ctx) {
context = ctx;
return const Scaffold();
},
),
),
);
unawaited(
Navigator.of(context)
.push<Object?>(
MaterialPageRoute<Object?>(
builder: (_) => PhotoDrawEditor(
source: source,
imageWidth: 8,
imageHeight: 8,
onPreview: (_) async => previews++,
),
),
)
.then((value) => popped = value),
);
await tester.pumpAndSettle();
await tester.tap(find.byIcon(Symbols.check));
await tester.pumpAndSettle();
expect(previews, 0);
expect(popped, isNull);
});
}