fix(app): keep diff typography and colours native to the host
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -18,22 +16,14 @@ const _raggedPatch =
|
||||
'-x\n'
|
||||
' tail\n';
|
||||
|
||||
double _addGreenMinusRed(Color color) => color.g - color.r;
|
||||
|
||||
double _removeRedMinusGreen(Color color) => color.r - color.g;
|
||||
|
||||
void main() {
|
||||
test('patch text uses the bundled code face, not a web fallback', () {
|
||||
final style = monospaceText(const TextStyle(fontSize: 12));
|
||||
expect(style.fontFamily, codeFontFamily);
|
||||
expect(style.fontFamilyFallback, contains('Menlo'));
|
||||
// Flutter web can only render a monospace diff if the build carries one.
|
||||
expect(File('assets/fonts/RobotoMono.ttf').existsSync(), isTrue);
|
||||
expect(
|
||||
File('pubspec.yaml').readAsStringSync(),
|
||||
contains('family: $codeFontFamily'),
|
||||
);
|
||||
});
|
||||
test(
|
||||
'patch typography preserves the native host style without overrides',
|
||||
() {
|
||||
const native = TextStyle(fontSize: 19, fontFamily: 'host-font');
|
||||
expect(nativeDiffText(native), same(native));
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'light and dark themes give additions and removals distinct hues',
|
||||
@@ -45,29 +35,16 @@ void main() {
|
||||
final context = tester.element(find.byType(Scaffold));
|
||||
final add = diffLineColors(context, ChangeLineKind.add);
|
||||
final remove = diffLineColors(context, ChangeLineKind.remove);
|
||||
expect(add.background, isNotNull, reason: '$brightness add tint');
|
||||
expect(remove.background, isNotNull, reason: '$brightness remove tint');
|
||||
expect(add.background, isNull);
|
||||
expect(remove.background, isNull);
|
||||
expect(add.text, isNot(remove.text), reason: '$brightness text');
|
||||
expect(
|
||||
_addGreenMinusRed(add.background!),
|
||||
greaterThan(0.02),
|
||||
reason: '$brightness additions read as green, not another red',
|
||||
);
|
||||
expect(
|
||||
_removeRedMinusGreen(remove.background!),
|
||||
greaterThan(0.02),
|
||||
reason: '$brightness removals read as red, not another green',
|
||||
);
|
||||
expect(
|
||||
_removeRedMinusGreen(remove.text),
|
||||
greaterThan(0.02),
|
||||
reason: '$brightness removal text is a red hue',
|
||||
);
|
||||
expect(add.text, Theme.of(context).colorScheme.primary);
|
||||
expect(remove.text, Theme.of(context).colorScheme.error);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('every diff line tint spans the hunk width, not its own text', (
|
||||
testWidgets('every diff line shares the hunk width, not its own text width', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
|
||||
Reference in New Issue
Block a user