水印优化+ORC优化
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:image/image.dart' as img;
|
||||
|
||||
import 'package:qiangbao_accounting/models/photo.dart';
|
||||
import 'package:qiangbao_accounting/models/watermark.dart';
|
||||
import 'package:qiangbao_accounting/pages/watermark/watermark_painter.dart';
|
||||
|
||||
@@ -211,6 +212,57 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('照片记录还原成水印数据', () {
|
||||
test('天气和温度能从拼在一起的那个字段拆回来', () {
|
||||
expect(splitWeatherText('晴 25℃'), (weather: '晴', temperature: '25℃'));
|
||||
expect(splitWeatherText('多云 18℃'), (weather: '多云', temperature: '18℃'));
|
||||
});
|
||||
|
||||
test('只有天气 / 只有温度 / 空,三种都要兜住', () {
|
||||
expect(splitWeatherText('晴'), (weather: '晴', temperature: ''));
|
||||
expect(splitWeatherText('25℃'), (weather: '', temperature: '25℃'));
|
||||
expect(splitWeatherText(''), (weather: '', temperature: ''));
|
||||
expect(splitWeatherText(' '), (weather: '', temperature: ''));
|
||||
});
|
||||
|
||||
test('★ 重新打水印时复用当时的地点和天气(不是你现在站的地方)', () {
|
||||
const photo = PhotoItem(
|
||||
id: 7,
|
||||
url: '/uploads/photo/a.jpg',
|
||||
thumbUrl: null,
|
||||
takenAt: '2026-09-28 14:30',
|
||||
address: '云南省昆明市五华区',
|
||||
weather: '晴 25℃',
|
||||
remark: '和宝一起',
|
||||
latitude: 25.0,
|
||||
longitude: 102.7,
|
||||
);
|
||||
|
||||
final data = photo.toWatermarkData();
|
||||
|
||||
expect(data.address, '云南省昆明市五华区');
|
||||
expect(data.weather, '晴');
|
||||
expect(data.temperature, '25℃');
|
||||
expect(data.remark, '和宝一起');
|
||||
expect(data.time, DateTime(2026, 9, 28, 14, 30));
|
||||
});
|
||||
|
||||
test('拍摄时间解析不出来时退回当前时间,不崩', () {
|
||||
const photo = PhotoItem(
|
||||
id: 1,
|
||||
url: '',
|
||||
thumbUrl: null,
|
||||
takenAt: '',
|
||||
address: '',
|
||||
weather: '',
|
||||
remark: '',
|
||||
latitude: null,
|
||||
longitude: null,
|
||||
);
|
||||
expect(photo.toWatermarkData().time, isNotNull);
|
||||
});
|
||||
});
|
||||
|
||||
group('绘制', () {
|
||||
test('paintWatermark 在真实画布上不抛异常', () {
|
||||
final recorder = ui.PictureRecorder();
|
||||
|
||||
Reference in New Issue
Block a user