33 lines
1.2 KiB
Dart
33 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
import 'package:ikar/core/storage/chat_wallpaper_store.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
test(
|
|
'custom gradient survives storage reload without replacing another chat',
|
|
() async {
|
|
SharedPreferences.setMockInitialValues({});
|
|
final store = ChatWallpaperStore.forTesting();
|
|
await store.load();
|
|
await store.setTheme(101, 203, 'synthetic-theme');
|
|
const colors = [Colors.red, Colors.blue, Colors.green];
|
|
await store.setGradient(101, 202, colors, animated: true, rotation: 0.7);
|
|
final restored = ChatWallpaperStore.forTesting();
|
|
await restored.load();
|
|
final wallpaper = restored.get(101, 202)!;
|
|
expect(wallpaper.kind, ChatWallpaperKind.gradient);
|
|
expect(
|
|
wallpaper.gradientColors!.map((color) => color.toARGB32()),
|
|
colors.map((color) => color.toARGB32()),
|
|
);
|
|
expect(wallpaper.gradientAnimated, isTrue);
|
|
expect(wallpaper.gradientRotation, 0.7);
|
|
expect(restored.get(101, 203)!.themeId, 'synthetic-theme');
|
|
expect(restored.get(102, 202), isNull);
|
|
},
|
|
);
|
|
}
|