@@ -18,7 +18,6 @@ use std::path::{Path, PathBuf};
1818) ) ]
1919use std:: process:: { Command , Stdio } ;
2020#[ cfg( any(
21- test,
2221 target_os = "macos" ,
2322 target_os = "windows" ,
2423 all( target_os = "linux" , not( target_env = "ohos" ) )
@@ -27,15 +26,13 @@ use std::time::{SystemTime, UNIX_EPOCH};
2726
2827use anyhow:: { Context , Result , bail} ;
2928#[ cfg( any(
30- test,
3129 target_os = "macos" ,
3230 target_os = "windows" ,
3331 all( target_os = "linux" , not( target_env = "ohos" ) )
3432) ) ]
3533use arboard:: { Clipboard , ImageData } ;
3634use base64:: Engine as _;
3735#[ cfg( any(
38- test,
3936 target_os = "macos" ,
4037 target_os = "windows" ,
4138 all( target_os = "linux" , not( target_env = "ohos" ) )
@@ -71,7 +68,10 @@ impl PastedImage {
7168
7269/// Clipboard payloads supported by the TUI.
7370#[ cfg_attr(
74- all( any( target_env = "ohos" , target_os = "android" ) , not( test) ) ,
71+ all(
72+ any( target_env = "ohos" , target_os = "android" , target_os = "netbsd" ) ,
73+ not( test)
74+ ) ,
7575 allow( dead_code)
7676) ]
7777pub enum ClipboardContent {
@@ -82,14 +82,12 @@ pub enum ClipboardContent {
8282/// Clipboard reader/writer helper.
8383pub struct ClipboardHandler {
8484 #[ cfg( any(
85- test,
8685 target_os = "macos" ,
8786 target_os = "windows" ,
8887 all( target_os = "linux" , not( target_env = "ohos" ) )
8988 ) ) ]
9089 clipboard : Option < Clipboard > ,
9190 #[ cfg( any(
92- test,
9391 target_os = "macos" ,
9492 target_os = "windows" ,
9593 all( target_os = "linux" , not( target_env = "ohos" ) )
@@ -108,14 +106,12 @@ impl ClipboardHandler {
108106 pub fn new ( ) -> Self {
109107 Self {
110108 #[ cfg( any(
111- test,
112109 target_os = "macos" ,
113110 target_os = "windows" ,
114111 all( target_os = "linux" , not( target_env = "ohos" ) )
115112 ) ) ]
116113 clipboard : None ,
117114 #[ cfg( any(
118- test,
119115 target_os = "macos" ,
120116 target_os = "windows" ,
121117 all( target_os = "linux" , not( target_env = "ohos" ) )
@@ -135,7 +131,6 @@ impl ClipboardHandler {
135131 /// handler stays in fallback/no-op mode and `read`/`write_text` fall
136132 /// through to their OSC 52 and pbcopy/powershell fallbacks.
137133 #[ cfg( any(
138- test,
139134 target_os = "macos" ,
140135 target_os = "windows" ,
141136 all( target_os = "linux" , not( target_env = "ohos" ) )
@@ -167,7 +162,6 @@ impl ClipboardHandler {
167162 }
168163
169164 #[ cfg( any(
170- test,
171165 target_os = "macos" ,
172166 target_os = "windows" ,
173167 all( target_os = "linux" , not( target_env = "ohos" ) )
@@ -378,7 +372,6 @@ fn clipboard_images_dir_for_home(workspace: &Path, home: Option<&Path>) -> PathB
378372/// Encode an RGBA `ImageData` from arboard as PNG and persist it. Returns
379373/// the resulting path along with metadata used to render the paste hint.
380374#[ cfg( any(
381- test,
382375 target_os = "macos" ,
383376 target_os = "windows" ,
384377 all( target_os = "linux" , not( target_env = "ohos" ) )
@@ -390,7 +383,6 @@ fn save_image_as_png(workspace: &Path, image: &ImageData) -> Result<PastedImage>
390383/// Lower-level variant that writes into an explicit directory. Exposed so the
391384/// unit tests don't have to scribble inside the user's real home directory.
392385#[ cfg( any(
393- test,
394386 target_os = "macos" ,
395387 target_os = "windows" ,
396388 all( target_os = "linux" , not( target_env = "ohos" ) )
@@ -439,10 +431,21 @@ fn save_image_as_png_in(dir: &Path, image: &ImageData) -> Result<PastedImage> {
439431#[ cfg( test) ]
440432mod tests {
441433 use super :: * ;
434+ // ImageData from arboard is only available on these platforms.
435+ #[ cfg( any(
436+ target_os = "macos" ,
437+ target_os = "windows" ,
438+ all( target_os = "linux" , not( target_env = "ohos" ) )
439+ ) ) ]
442440 use std:: borrow:: Cow ;
443441 #[ cfg( unix) ]
444442 use std:: os:: unix:: fs:: PermissionsExt ;
445443
444+ #[ cfg( any(
445+ target_os = "macos" ,
446+ target_os = "windows" ,
447+ all( target_os = "linux" , not( target_env = "ohos" ) )
448+ ) ) ]
446449 fn solid_rgba ( width : u16 , height : u16 , rgba : [ u8 ; 4 ] ) -> ImageData < ' static > {
447450 let mut bytes = Vec :: with_capacity ( ( width as usize ) * ( height as usize ) * 4 ) ;
448451 for _ in 0 ..( width as usize * height as usize ) {
@@ -456,6 +459,11 @@ mod tests {
456459 }
457460
458461 #[ test]
462+ #[ cfg( any(
463+ target_os = "macos" ,
464+ target_os = "windows" ,
465+ all( target_os = "linux" , not( target_env = "ohos" ) )
466+ ) ) ]
459467 fn save_image_as_png_writes_valid_png ( ) {
460468 let dir = tempfile:: tempdir ( ) . unwrap ( ) ;
461469 let img = solid_rgba ( 8 , 4 , [ 255 , 0 , 0 , 255 ] ) ;
0 commit comments