From 22ec5e3f970559e2921f4f5eb9ac665289bd2f06 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Wed, 23 Sep 2026 20:27:25 +0800 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab --- flutter/test/cursor_replay_test.dart | 6 ----- src/client/io_loop.rs | 39 +++++----------------------- src/common.rs | 2 +- 3 files changed, 7 insertions(+), 40 deletions(-) diff --git a/flutter/test/cursor_replay_test.dart b/flutter/test/cursor_replay_test.dart index 97cc954cb..b44f3ac5a 100644 --- a/flutter/test/cursor_replay_test.dart +++ b/flutter/test/cursor_replay_test.dart @@ -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); - }); } diff --git a/src/client/io_loop.rs b/src/client/io_loop.rs index 22e3f8c77..e98099ca0 100644 --- a/src/client/io_loop.rs +++ b/src/client/io_loop.rs @@ -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] diff --git a/src/common.rs b/src/common.rs index 766f03338..0d46bafe2 100644 --- a/src/common.rs +++ b/src/common.rs @@ -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 {