@@ -79,29 +79,31 @@ fn initiate_file_copy_advertises_drop_effect_alongside_file_group_descriptor() {
7979/// A `FormatDataRequest` for the drop-effect format id is answered
8080/// inline by `Cliprdr` itself (not forwarded to the backend) with the
8181/// 4-byte little-endian `DROPEFFECT_COPY = 0x00000001` payload.
82+ ///
83+ /// Keys off the format *name* (`PREFERRED_DROP_EFFECT`) when looking up
84+ /// the id — wire-faithful (the remote keys off the name too), and
85+ /// resilient to any internal-id constant changes upstream.
86+ ///
87+ /// If `local_drop_effect_format_id` ever stops being set by
88+ /// `initiate_file_copy` (or the inline short-circuit in
89+ /// `handle_format_data_request` is removed), this test fails because
90+ /// `TestBackend::on_format_data_request` is a no-op — the request
91+ /// would fall through to the backend, no response would be emitted,
92+ /// and `responses.len()` would be `0`.
8293#[ test]
8394fn format_data_request_for_drop_effect_returns_dropeffect_copy_inline ( ) {
8495 let mut cliprdr = init_ready_client ( ) ;
8596
86- // Drive `initiate_file_copy` so the server sets its
87- // `local_drop_effect_format_id` and starts recognizing requests for
88- // it. Discard the outbound FormatList — covered by the test above.
97+ // Drive `initiate_file_copy`; the returned FormatList carries the
98+ // drop-effect format we need to query.
8999 let files = vec ! [ FileDescriptor :: new( "doc.txt" ) . with_file_size( 42 ) ] ;
90- let _ = cliprdr. initiate_file_copy ( files) . unwrap ( ) ;
91-
92- // Find the drop-effect format id from the advertised FormatList by
93- // re-driving the call would be circular; instead, key off the format
94- // *name* by walking the FormatList we just emitted. Easier and
95- // wire-faithful since the remote keys off the name too.
96- let initiate_msgs: Vec < SvcMessage > = cliprdr
97- . initiate_file_copy ( vec ! [ FileDescriptor :: new( "d.txt" ) . with_file_size( 1 ) ] )
98- . unwrap ( )
99- . into ( ) ;
100+ let initiate_msgs: Vec < SvcMessage > = cliprdr. initiate_file_copy ( files) . unwrap ( ) . into ( ) ;
101+
100102 decode_pdu ! ( & initiate_msgs[ 0 ] => initiate_bytes, initiate_pdu) ;
101103 let ClipboardPdu :: FormatList ( format_list) = initiate_pdu else {
102- panic ! ( "expected FormatList" ) ;
104+ panic ! ( "expected FormatList, got {initiate_pdu:?} " ) ;
103105 } ;
104- let drop_effect_format = format_list
106+ let drop_effect_id = format_list
105107 . get_formats ( true )
106108 . unwrap ( )
107109 . into_iter ( )
@@ -110,8 +112,8 @@ fn format_data_request_for_drop_effect_returns_dropeffect_copy_inline() {
110112 . as_ref ( )
111113 . is_some_and ( |n| n == & ClipboardFormatName :: PREFERRED_DROP_EFFECT )
112114 } )
113- . expect ( "Preferred DropEffect must be advertised" ) ;
114- let drop_effect_id = drop_effect_format . id ;
115+ . expect ( "initiate_file_copy must advertise Preferred DropEffect" )
116+ . id ;
115117
116118 // Simulate the remote asking for the drop-effect format.
117119 let request_pdu = ClipboardPdu :: FormatDataRequest ( FormatDataRequest { format : drop_effect_id } ) ;
@@ -121,7 +123,7 @@ fn format_data_request_for_drop_effect_returns_dropeffect_copy_inline() {
121123 assert_eq ! (
122124 responses. len( ) ,
123125 1 ,
124- "drop-effect FormatDataRequest should be answered inline with one FormatDataResponse"
126+ "drop-effect FormatDataRequest must be answered inline with one FormatDataResponse"
125127 ) ;
126128
127129 decode_pdu ! ( & responses[ 0 ] => resp_bytes, resp_pdu) ;
@@ -131,8 +133,8 @@ fn format_data_request_for_drop_effect_returns_dropeffect_copy_inline() {
131133 assert ! ( !response. is_error( ) , "response must not be an error" ) ;
132134
133135 // [MS-RDPECLIP] Preferred DropEffect payload is a 4-byte u32 LE.
134- // `DROPEFFECT_COPY = 0x00000001` is what we advertise as the only
135- // value `initiate_file_copy` ever produces .
136+ // `DROPEFFECT_COPY = 0x00000001` is what `initiate_file_copy`
137+ // semantically always means .
136138 assert_eq ! (
137139 response. data( ) ,
138140 & [ 0x01 , 0x00 , 0x00 , 0x00 ] ,
0 commit comments