forked from 1b-agent/opencadstudio-upstream
Add demo_plugin and plugin host integration tests
Minimal in-tree add-on (DP_HELLO) validates registry, ribbon merge, and try_dispatch. Five new lib tests; EntryKind gains PartialEq for test helpers.
This commit is contained in:
1 parent
9f35456205
commit
82993bc1db
12 files changed
+214
-2
No files matched your search
@@ -0,0 +1,47 @@
|
||||
// Minimal in-tree add-on — validates plugin host on `feature/plugin-host`.
|
||||
|
||||
pub mod dispatch;
|
||||
pub mod manifest;
|
||||
pub mod plugin;
|
||||
pub mod register;
|
||||
|
||||
use crate::modules::{CadModule, IconKind, ModuleEvent, RibbonGroup, RibbonItem, ToolDef};
|
||||
|
||||
inventory::submit!(crate::command::CommandRegistration {
|
||||
names: &["DP_HELLO"]
|
||||
});
|
||||
|
||||
pub struct DemoPluginModule;
|
||||
|
||||
impl CadModule for DemoPluginModule {
|
||||
fn id(&self) -> &'static str {
|
||||
"demo_plugin"
|
||||
}
|
||||
|
||||
fn title(&self) -> &'static str {
|
||||
"Demo Plugin"
|
||||
}
|
||||
|
||||
fn ribbon_groups(&self) -> Vec<RibbonGroup> {
|
||||
vec![RibbonGroup {
|
||||
title: "Smoke",
|
||||
tools: vec![RibbonItem::LargeTool(ToolDef {
|
||||
id: "DP_HELLO",
|
||||
label: "Hello",
|
||||
icon: IconKind::Glyph("★"),
|
||||
event: ModuleEvent::Command("DP_HELLO".to_string()),
|
||||
})],
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::plugin::all_ribbon_modules;
|
||||
|
||||
#[test]
|
||||
fn ribbon_tab_is_registered() {
|
||||
let titles: Vec<&str> = all_ribbon_modules().iter().map(|m| m.title()).collect();
|
||||
assert!(titles.contains(&"Demo Plugin"), "tabs: {titles:?}");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user