Merge 30ade60ee7
into bd4e943597
This commit is contained in:
commit
e087894c74
4 changed files with 33 additions and 93 deletions
|
@ -15,11 +15,6 @@ use std::{
|
|||
rc::{Rc, Weak},
|
||||
sync::Arc,
|
||||
};
|
||||
#[cfg(target_os = "windows")]
|
||||
use windows::Win32::{
|
||||
Graphics::Imaging::{CLSID_WICImagingFactory, IWICImagingFactory},
|
||||
System::Com::{CLSCTX_INPROC_SERVER, CoCreateInstance},
|
||||
};
|
||||
|
||||
/// TestPlatform implements the Platform trait for use in tests.
|
||||
pub(crate) struct TestPlatform {
|
||||
|
@ -36,8 +31,6 @@ pub(crate) struct TestPlatform {
|
|||
screen_capture_sources: RefCell<Vec<TestScreenCaptureSource>>,
|
||||
pub opened_url: RefCell<Option<String>>,
|
||||
pub text_system: Arc<dyn PlatformTextSystem>,
|
||||
#[cfg(target_os = "windows")]
|
||||
bitmap_factory: std::mem::ManuallyDrop<IWICImagingFactory>,
|
||||
weak: Weak<Self>,
|
||||
}
|
||||
|
||||
|
@ -92,16 +85,6 @@ pub(crate) struct TestPrompts {
|
|||
|
||||
impl TestPlatform {
|
||||
pub fn new(executor: BackgroundExecutor, foreground_executor: ForegroundExecutor) -> Rc<Self> {
|
||||
#[cfg(target_os = "windows")]
|
||||
let bitmap_factory = unsafe {
|
||||
windows::Win32::System::Ole::OleInitialize(None)
|
||||
.expect("unable to initialize Windows OLE");
|
||||
std::mem::ManuallyDrop::new(
|
||||
CoCreateInstance(&CLSID_WICImagingFactory, None, CLSCTX_INPROC_SERVER)
|
||||
.expect("Error creating bitmap factory."),
|
||||
)
|
||||
};
|
||||
|
||||
let text_system = Arc::new(NoopTextSystem);
|
||||
|
||||
Rc::new_cyclic(|weak| TestPlatform {
|
||||
|
@ -117,8 +100,6 @@ impl TestPlatform {
|
|||
current_primary_item: Mutex::new(None),
|
||||
weak: weak.clone(),
|
||||
opened_url: Default::default(),
|
||||
#[cfg(target_os = "windows")]
|
||||
bitmap_factory,
|
||||
text_system,
|
||||
})
|
||||
}
|
||||
|
@ -440,16 +421,6 @@ impl TestScreenCaptureSource {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
impl Drop for TestPlatform {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
std::mem::ManuallyDrop::drop(&mut self.bitmap_factory);
|
||||
windows::Win32::System::Ole::OleUninitialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct TestKeyboardLayout;
|
||||
|
||||
impl PlatformKeyboardLayout for TestKeyboardLayout {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue