Some checks failed
CI / Windows build (push) Has been cancelled
A blank note can show a page-background template painted behind the ink, picked from the toolbar and persisted per notebook. - NoteBackground: blank / dots / ruled / grid / cornell, drawn in page space (scales with zoom), subtle grey. Cornell = left margin + bottom summary rule over a ruled body. - Stored as the enum name in the notebook sidecar (back-compat: missing/unknown -> blank), saved/loaded via SidecarRepository so it restores on reopen. - Picker added to the note tool palette. PDF backgrounds skipped (PDFs have their own page content). analyze clean, 386 tests green.
42 lines
1.4 KiB
Dart
42 lines
1.4 KiB
Dart
// test/note_background_test.dart
|
|
//
|
|
// Covers the NoteBackground template enum decode (back-compat: missing/unknown →
|
|
// blank) and the painter's shouldRepaint reacting to a background change.
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:badnote/editor/canvas/note_background.dart';
|
|
|
|
void main() {
|
|
group('noteBackgroundFromName', () {
|
|
test('decodes each enum name round-trip', () {
|
|
for (final b in NoteBackground.values) {
|
|
expect(noteBackgroundFromName(b.name), b);
|
|
}
|
|
});
|
|
|
|
test('null → blank (back-compat for legacy sidecars)', () {
|
|
expect(noteBackgroundFromName(null), NoteBackground.blank);
|
|
});
|
|
|
|
test('unknown name → blank (forward-compat)', () {
|
|
expect(noteBackgroundFromName('isometric'), NoteBackground.blank);
|
|
expect(noteBackgroundFromName(''), NoteBackground.blank);
|
|
});
|
|
});
|
|
|
|
group('NoteBackgroundPainter.shouldRepaint', () {
|
|
test('repaints when the background changes', () {
|
|
const a = NoteBackgroundPainter(NoteBackground.blank);
|
|
const b = NoteBackgroundPainter(NoteBackground.dots);
|
|
expect(a.shouldRepaint(b), isTrue);
|
|
});
|
|
|
|
test('does not repaint when the background is identical', () {
|
|
const a = NoteBackgroundPainter(NoteBackground.grid);
|
|
const b = NoteBackgroundPainter(NoteBackground.grid);
|
|
expect(a.shouldRepaint(b), isFalse);
|
|
});
|
|
});
|
|
}
|