Files
clide/test/terminal/coverage_trivials_test.dart
T
jpmschweitzerandClaude Opus 4.7 0a43a1f7d2
test / unit + widget + golden + a11y (push) Failing after 30s
test / integration_test (xvfb) (push) Has been skipped
test / bundle smoke (xvfb 5s) (push) Has been skipped
test / daemon subprocess + web WASM smoke (push) Has been skipped
test / dart doc (lib API) (push) Failing after 1m1s
remove dead tertiary-tap surface (T-95)
The middle-click ("tertiary tap") path in TerminalGestureHandler was
wired wrong: build() bound onTertiaryTapDown to the secondary state
method, so a middle-click fired as if it were a right-click. The
state's onTertiaryTapDown/Up methods were unreachable, and the
onTertiaryTapUp body had a copy-paste bug (button=right instead of
middle). No production caller passed onTertiaryTapDown / onTertiaryTapUp
through, and TerminalView didn't expose them either, so the public
parameters were dead too.

Drops both layers of dead surface — option B of T-95. Same shape as
T-93's resolution (delete unused, restore later when a real consumer
needs it). Also collapses the unreachable onDragStart selectWord
branch (PanGestureRecognizer is mouse-only, so the touch path can't
fire) into a single selectCharacters call with a comment.

Companion: refines the reflow-padding test in coverage_trivials_test
to use narrow→wide reflow setup (more honest about intent, also
actually exercises the padding branch — Buffer.resize now 100%) and
clears two unnecessary_import warnings surfaced by the deletion.

Coverage: gesture_handler 55/59 -> 59/59; gesture_detector 50/50;
buffer/buffer 260/261 -> 261/261.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 17:56:24 +02:00

60 lines
2.3 KiB
Dart

/// Closeout tests for the last single-digit-uncovered lines in
/// `lib/src/terminal/`: pointer_input constructors, the abstract
/// TerminalMouseHandler constructor, the reflow padding branch in
/// Buffer.resize, and the wide-char skip branch in
/// TerminalPainter.paintLine.
library;
import 'dart:ui';
import 'package:clide/src/terminal/src/core/mouse/handler.dart';
import 'package:clide/src/terminal/src/terminal.dart';
import 'package:clide/src/terminal/src/ui/painter.dart';
import 'package:clide/src/terminal/src/ui/pointer_input.dart';
import 'package:clide/src/terminal/src/ui/terminal_text_style.dart';
import 'package:clide/src/terminal/src/ui/themes.dart';
import 'package:flutter/painting.dart';
import 'package:test/test.dart';
class _StubMouseHandler extends TerminalMouseHandler {
const _StubMouseHandler();
@override
String? call(TerminalMouseEvent event) => null;
}
void main() {
test('PointerInputs.none / .all produce expected sets', () {
expect(const PointerInputs.none().inputs, isEmpty);
expect(const PointerInputs.all().inputs, containsAll(PointerInput.values));
});
test('TerminalMouseHandler abstract const constructor is reachable via a subclass', () {
const h = _StubMouseHandler();
expect(h, isA<TerminalMouseHandler>());
});
test('Buffer.resize pads reflow output up to the new height', () {
final t = Terminal(maxLines: 200, onOutput: (_) {});
// Setup: narrow viewport with wrapped continuation lines. Widening
// collapses them in reflow → output rows < newHeight → the
// pad-with-empty-lines branch in Buffer.resize runs.
t.resize(5, 30, 8, 16);
t.write('aaaaaaaaaaaaaaaaaaaa'); // wraps 4 times
t.resize(80, 30, 8, 16); // widen, same height
expect(t.buffer.lines.length, 30);
});
test('TerminalPainter.paintLine handles wide (CJK) cells without skipping the skip', () {
final t = Terminal(maxLines: 100, onOutput: (_) {});
// CJK ideograph — terminal stores it as a width-2 cell, so paintLine
// advances `i` twice and the wide-char branch fires.
t.write('漢字');
final p = TerminalPainter(
theme: TerminalThemes.defaultTheme,
textStyle: const TerminalStyle(),
textScaler: const TextScaler.linear(1.0),
);
p.paintLine(Canvas(PictureRecorder()), Offset.zero, t.buffer.lines[0]);
});
}