use crate::*;
#[test]
fn test_clear() {
let mut clipboard = Clipboard::get();
clipboard.write_text("Hello").unwrap();
assert_eq!(clipboard.read().unwrap().into_text().unwrap(), "Hello");
clipboard.clear().unwrap();
assert_eq!(clipboard.read(), None);
}
#[test]
fn test_write_text() {
let mut clipboard = Clipboard::get();
clipboard.write_text("Hello").unwrap();
assert_eq!(clipboard.read().unwrap().into_text().unwrap(), "Hello");
}
#[test]
fn test_write_blank_text() {
let mut clipboard = Clipboard::get();
clipboard.write_text("").unwrap();
assert_eq!(clipboard.read(), None);
}
#[test]
fn test_write_image() {
let mut clipboard = Clipboard::get();
let image = image::ImageBuffer::from_fn(8, 8, |x, y| {
if (x * y) % 2 == 0 {
image::Rgba([255, 0, 0, 255])
} else {
image::Rgba([0, 255, 0, 255])
}
});
clipboard
.write_image(image.width(), image.height(), image.as_raw())
.unwrap();
assert_eq!(
clipboard
.read()
.unwrap()
.into_image()
.unwrap()
.as_raw()
.as_ref(),
image.as_ref()
);
}