cursor: drop the tests nothing can fail

a_handle_is_named_once_its_shape_is_shown dates from when `name`
wrote the handle map. `name` is pure now, so its last assertion
cannot fail, and the others repeat two neighbours.
every_handle_the_peer_named_stays_for_the_connection fails only for
a bound added on purpose, which the struct's doc rules out. The Dart
arrival test is covered by the first test of its file.

The kept-shape test now asserts what `cursor_shape` is for, a copy
rather than a view of the received buffer, in place of the unknown
fields it drops. The content-id test moves out from between two
`use` lines.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
This commit is contained in:
rustdesk
2026-09-23 20:27:25 +08:00
co-authored by Claude Fable 5.1
parent b93d71899f
commit 22ec5e3f97
3 changed files with 7 additions and 40 deletions
-6
View File
@@ -370,10 +370,4 @@ void main() {
final p = ffi.cursorModel.cache!.image.getPixel(0, 0);
expect([p.r, p.g, p.b, p.a], [3, 4, 5, 6]);
});
test('a shape is decoded from its pixels as they arrive', () async {
await _feed(ffi, '5');
expect(ffi.cursorModel.cache?.id, '5');
expect(ffi.cursorModel.image, isNotNull);
});
}
+6 -33
View File
@@ -2862,25 +2862,6 @@ mod cursor_dedupe_tests {
assert_eq!(dedupe.id(1), first);
}
#[test]
fn a_handle_is_named_once_its_shape_is_shown() {
let mut dedupe = CursorDedupe::default();
let arrow = CursorDedupe::name(&shape(1, 0, b"arrow"));
assert_eq!(
dedupe.id(1),
1,
"a shape that did not decode leaves nothing"
);
dedupe.shown(1, arrow);
assert_eq!(dedupe.id(1), arrow);
CursorDedupe::name(&shape(1, 0, b"bad"));
assert_eq!(
dedupe.id(1),
arrow,
"nor does it take a handle from a shape that did"
);
}
#[test]
fn the_hotspot_is_part_of_the_shape() {
let a = CursorDedupe::name(&shape(1, 0, b"arrow"));
@@ -2902,17 +2883,6 @@ mod cursor_dedupe_tests {
assert_eq!(CursorDedupe::default().id(7), 7);
}
#[test]
fn every_handle_the_peer_named_stays_for_the_connection() {
let mut dedupe = CursorDedupe::default();
let arrow = CursorDedupe::name(&shape(0, 0, b"arrow"));
for handle in 0..100_000 {
dedupe.shown(handle, arrow);
}
assert_eq!(dedupe.id(0), arrow);
assert_eq!(dedupe.id(99_999), arrow);
}
#[test]
fn peers_from_1_5_0_name_cursors_by_content() {
use hbb_common::get_version_number as v;
@@ -2938,15 +2908,18 @@ mod kept_cursor_tests {
}
#[test]
fn a_kept_shape_is_the_shape_under_the_ui_id_and_nothing_else() {
fn a_kept_shape_is_a_copy_under_the_ui_id() {
let mut cd = compressed(4, 4);
cd.hotx = 1;
cd.mut_unknown_fields().add_varint(99, 1);
let kept = cursor_shape(42, &cd, &cd.colors);
assert_eq!(kept.id, 42);
assert_eq!((kept.hotx, kept.width, kept.height), (1, 4, 4));
assert_eq!(kept.colors, cd.colors);
assert_eq!(kept.special_fields.unknown_fields().iter().count(), 0);
assert_ne!(
kept.colors.as_ptr(),
cd.colors.as_ptr(),
"not a view of the received buffer"
);
}
#[test]
+1 -1
View File
@@ -2952,6 +2952,7 @@ mod tests {
self,
time::{interval, interval_at, sleep, Duration, Instant, Interval},
};
use std::collections::HashSet;
#[test]
fn a_cursor_content_id_fits_a_web_client_number() {
@@ -2962,7 +2963,6 @@ mod tests {
}
}
}
use std::collections::HashSet;
#[inline]
fn get_timestamp_secs() -> u128 {