This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:riverpod/riverpod.dart';
|
||||
import 'package:weblibre/features/geckoview/domain/providers/tab_detail_state.dart';
|
||||
|
||||
void main() {
|
||||
test('closed tab progress is pruned without touching active tabs', () {
|
||||
final container = ProviderContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
final notifier = container.read(tabProgressStatesProvider.notifier);
|
||||
notifier.update('closed-tab', 80);
|
||||
notifier.update('active-tab', 40);
|
||||
|
||||
notifier.removeAll({'closed-tab', 'unknown-tab'});
|
||||
|
||||
expect(container.read(tabProgressStatesProvider), {'active-tab': 40});
|
||||
});
|
||||
|
||||
test('pruning unrelated ids does not publish a new map', () {
|
||||
final container = ProviderContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
final notifier = container.read(tabProgressStatesProvider.notifier);
|
||||
notifier.update('active-tab', 40);
|
||||
final before = container.read(tabProgressStatesProvider);
|
||||
|
||||
notifier.removeAll({'unknown-tab'});
|
||||
|
||||
expect(
|
||||
identical(container.read(tabProgressStatesProvider), before),
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -75,6 +75,27 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('tryDecodeImage can bypass the global image cache', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.runAsync(() async {
|
||||
clearImageCache();
|
||||
final svgBytes = Uint8List.fromList(utf8.encode(_svgIcon));
|
||||
|
||||
final first = await tryDecodeImage(svgBytes, cacheResult: false);
|
||||
final second = await tryDecodeImage(svgBytes, cacheResult: false);
|
||||
|
||||
expect(first, isNotNull);
|
||||
expect(second, isNotNull);
|
||||
expect(first, equals(second));
|
||||
expect(identical(first, second), isFalse);
|
||||
|
||||
// These are deliberately distinct uncached image resources.
|
||||
first!.dispose();
|
||||
second!.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
test('ImageIdentity compares structurally, not by a folded hash', () {
|
||||
const a = (
|
||||
digest: 0x0123456789ABCDEF,
|
||||
|
||||
Reference in New Issue
Block a user