@@ -54,6 +54,14 @@ pub fn build_screen_record_file_stem(
5454 }
5555}
5656
57+ pub fn build_local_recording_artifact_dir (
58+ output_root : & Path ,
59+ serial : & str ,
60+ timestamp : & str ,
61+ ) -> PathBuf {
62+ output_root. join ( build_screen_record_file_stem ( serial, timestamp, None ) )
63+ }
64+
5765pub fn build_remote_recording_path (
5866 serial : & str ,
5967 timestamp : & str ,
@@ -66,19 +74,44 @@ pub fn build_remote_recording_path(
6674}
6775
6876pub fn build_local_recording_path (
69- output_dir : & Path ,
77+ output_root : & Path ,
7078 serial : & str ,
7179 timestamp : & str ,
7280 segment_index : Option < usize > ,
7381 extension : & str ,
7482) -> PathBuf {
75- output_dir . join ( format ! (
83+ build_local_recording_artifact_dir ( output_root , serial , timestamp ) . join ( format ! (
7684 "{}.{}" ,
7785 build_screen_record_file_stem( serial, timestamp, segment_index) ,
7886 extension. trim_start_matches( '.' )
7987 ) )
8088}
8189
90+ pub fn build_local_recording_logcat_path (
91+ output_root : & Path ,
92+ serial : & str ,
93+ timestamp : & str ,
94+ ) -> PathBuf {
95+ build_local_recording_artifact_dir ( output_root, serial, timestamp) . join ( format ! (
96+ "{}_logcat.txt" ,
97+ build_screen_record_file_stem( serial, timestamp, None )
98+ ) )
99+ }
100+
101+ pub fn build_recording_logcat_args ( serial : & str ) -> Vec < String > {
102+ vec ! [
103+ "-s" . to_string( ) ,
104+ serial. to_string( ) ,
105+ "logcat" . to_string( ) ,
106+ "-v" . to_string( ) ,
107+ "threadtime" . to_string( ) ,
108+ "-b" . to_string( ) ,
109+ "all" . to_string( ) ,
110+ "-T" . to_string( ) ,
111+ "1" . to_string( ) ,
112+ ]
113+ }
114+
82115pub fn build_adb_screen_record_args (
83116 serial : & str ,
84117 settings : & ScreenRecordSettings ,
@@ -211,6 +244,70 @@ mod tests {
211244 assert ! ( !args. iter( ) . any( |item| item == "--time-limit" ) ) ;
212245 }
213246
247+ #[ test]
248+ fn build_local_recording_artifact_dir_uses_sanitized_recording_stem ( ) {
249+ let dir = build_local_recording_artifact_dir (
250+ Path :: new ( "/tmp/out" ) ,
251+ "USB:ABC/12 34" ,
252+ "20260523_153000" ,
253+ ) ;
254+ assert_eq ! (
255+ dir,
256+ PathBuf :: from( "/tmp/out/screenrecord_USB_ABC_12_34_20260523_153000" )
257+ ) ;
258+ }
259+
260+ #[ test]
261+ fn build_local_recording_path_uses_artifact_dir ( ) {
262+ let path = build_local_recording_path (
263+ Path :: new ( "/tmp/out" ) ,
264+ "USB:ABC/12 34" ,
265+ "20260523_153000" ,
266+ None ,
267+ "mp4" ,
268+ ) ;
269+ assert_eq ! (
270+ path,
271+ PathBuf :: from(
272+ "/tmp/out/screenrecord_USB_ABC_12_34_20260523_153000/screenrecord_USB_ABC_12_34_20260523_153000.mp4"
273+ )
274+ ) ;
275+ }
276+
277+ #[ test]
278+ fn build_recording_logcat_args_uses_structured_raw_all_buffers_args ( ) {
279+ let args = build_recording_logcat_args ( "USB:ABC/12 34" ) ;
280+ assert_eq ! (
281+ args,
282+ vec![
283+ "-s" ,
284+ "USB:ABC/12 34" ,
285+ "logcat" ,
286+ "-v" ,
287+ "threadtime" ,
288+ "-b" ,
289+ "all" ,
290+ "-T" ,
291+ "1" ,
292+ ]
293+ ) ;
294+ }
295+
296+ #[ test]
297+ fn build_local_recording_logcat_path_uses_artifact_dir ( ) {
298+ let path = build_local_recording_logcat_path (
299+ Path :: new ( "/tmp/out" ) ,
300+ "USB:ABC/12 34" ,
301+ "20260523_153000" ,
302+ ) ;
303+ assert_eq ! (
304+ path,
305+ PathBuf :: from(
306+ "/tmp/out/screenrecord_USB_ABC_12_34_20260523_153000/screenrecord_USB_ABC_12_34_20260523_153000_logcat.txt"
307+ )
308+ ) ;
309+ }
310+
214311 #[ test]
215312 fn normalize_screen_record_time_limit_sec_preserves_zero_and_large_values ( ) {
216313 assert_eq ! ( normalize_screen_record_time_limit_sec( -1 ) , 180 ) ;
0 commit comments