-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
181 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
use { | ||
crate::{ | ||
client::{Client, ClientError}, | ||
globals::{Global, GlobalName}, | ||
leaks::Tracker, | ||
object::{Object, Version}, | ||
wire::{wl_fixes::*, WlFixesId}, | ||
}, | ||
std::rc::Rc, | ||
thiserror::Error, | ||
}; | ||
|
||
pub struct WlFixesGlobal { | ||
pub name: GlobalName, | ||
} | ||
|
||
impl WlFixesGlobal { | ||
pub fn new(name: GlobalName) -> Self { | ||
Self { name } | ||
} | ||
|
||
fn bind_( | ||
self: Rc<Self>, | ||
id: WlFixesId, | ||
client: &Rc<Client>, | ||
version: Version, | ||
) -> Result<(), WlFixesError> { | ||
let mgr = Rc::new(WlFixes { | ||
id, | ||
client: client.clone(), | ||
tracker: Default::default(), | ||
version, | ||
}); | ||
track!(client, mgr); | ||
client.add_client_obj(&mgr)?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
global_base!(WlFixesGlobal, WlFixes, WlFixesError); | ||
|
||
simple_add_global!(WlFixesGlobal); | ||
|
||
impl Global for WlFixesGlobal { | ||
fn singleton(&self) -> bool { | ||
true | ||
} | ||
|
||
fn version(&self) -> u32 { | ||
1 | ||
} | ||
} | ||
|
||
pub struct WlFixes { | ||
pub id: WlFixesId, | ||
pub client: Rc<Client>, | ||
pub tracker: Tracker<Self>, | ||
pub version: Version, | ||
} | ||
|
||
impl WlFixesRequestHandler for WlFixes { | ||
type Error = WlFixesError; | ||
|
||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> { | ||
self.client.remove_obj(self)?; | ||
Ok(()) | ||
} | ||
|
||
fn destroy_registry(&self, req: DestroyRegistry, _slf: &Rc<Self>) -> Result<(), Self::Error> { | ||
let registry = self.client.lookup(req.registry)?; | ||
self.client.remove_obj(&*registry)?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
object_base! { | ||
self = WlFixes; | ||
version = self.version; | ||
} | ||
|
||
impl Object for WlFixes {} | ||
|
||
simple_add_obj!(WlFixes); | ||
|
||
#[derive(Debug, Error)] | ||
pub enum WlFixesError { | ||
#[error(transparent)] | ||
ClientError(Box<ClientError>), | ||
} | ||
efrom!(WlFixesError, ClientError); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use { | ||
crate::{ | ||
it::{ | ||
test_error::TestResult, test_ifs::test_registry::TestRegistry, test_object::TestObject, | ||
test_transport::TestTransport, | ||
}, | ||
wire::{wl_fixes::*, WlFixesId}, | ||
}, | ||
std::rc::Rc, | ||
}; | ||
|
||
pub struct TestWlFixes { | ||
pub id: WlFixesId, | ||
pub tran: Rc<TestTransport>, | ||
} | ||
|
||
impl TestWlFixes { | ||
pub fn new(tran: &Rc<TestTransport>) -> Self { | ||
Self { | ||
id: tran.id(), | ||
tran: tran.clone(), | ||
} | ||
} | ||
|
||
pub fn destroy_registry(&self, registry: &TestRegistry) -> TestResult { | ||
self.tran.send(DestroyRegistry { | ||
self_id: self.id, | ||
registry: registry.id, | ||
})?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
test_object! { | ||
TestWlFixes, WlFixes; | ||
} | ||
|
||
impl TestObject for TestWlFixes {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use { | ||
crate::it::{test_error::TestResult, testrun::TestRun}, | ||
std::rc::Rc, | ||
}; | ||
|
||
testcase!(); | ||
|
||
async fn test(run: Rc<TestRun>) -> TestResult { | ||
let client = run.create_client().await?; | ||
let wl_fixes = client.registry.get_wl_fixes().await?; | ||
|
||
let registry1 = client.tran.get_registry(); | ||
|
||
client.sync().await; | ||
let before = client.server.objects.registries.len(); | ||
|
||
wl_fixes.destroy_registry(®istry1)?; | ||
|
||
client.sync().await; | ||
let after = client.server.objects.registries.len(); | ||
|
||
tassert_eq!(before, after + 1); | ||
|
||
let registry2 = client.tran.get_registry(); | ||
client.sync().await; | ||
|
||
tassert_eq!(registry1.id, registry2.id); | ||
tassert!(registry2.globals.is_not_empty()); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
request destroy { | ||
|
||
} | ||
|
||
request destroy_registry { | ||
registry: id(wl_registry), | ||
} |