3873fdaf64
桌面壳 capabilities 增加无重复与能力边界单测 桌面壳配置门禁反查能力清单单测覆盖 宿主壳方案文档和共享决策同步桌面能力边界
120 lines
3.5 KiB
Rust
120 lines
3.5 KiB
Rust
pub(crate) fn capabilities() -> Vec<&'static str> {
|
|
vec![
|
|
"host.getRuntime",
|
|
"appearance.getColorScheme",
|
|
"host.events",
|
|
"app.lifecycle",
|
|
"share.open",
|
|
"share.setTarget",
|
|
"navigation.openNativePage",
|
|
"navigation.canGoBack",
|
|
"app.reloadWebView",
|
|
"app.openExternalUrl",
|
|
"app.setTitle",
|
|
"app.setBadgeCount",
|
|
"network.status",
|
|
"network.statusChanged",
|
|
"clipboard.writeText",
|
|
"clipboard.readText",
|
|
"file.exportText",
|
|
"file.importText",
|
|
"file.importDocument",
|
|
"file.exportImage",
|
|
"file.importImage",
|
|
"file.importAudio",
|
|
"file.exportAudio",
|
|
"file.imageDropped",
|
|
"notification.showLocal",
|
|
]
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use serde_json::Value;
|
|
use std::collections::HashSet;
|
|
|
|
#[test]
|
|
fn runtime_capability_list_stays_ordered() {
|
|
assert_eq!(
|
|
capabilities(),
|
|
vec![
|
|
"host.getRuntime",
|
|
"appearance.getColorScheme",
|
|
"host.events",
|
|
"app.lifecycle",
|
|
"share.open",
|
|
"share.setTarget",
|
|
"navigation.openNativePage",
|
|
"navigation.canGoBack",
|
|
"app.reloadWebView",
|
|
"app.openExternalUrl",
|
|
"app.setTitle",
|
|
"app.setBadgeCount",
|
|
"network.status",
|
|
"network.statusChanged",
|
|
"clipboard.writeText",
|
|
"clipboard.readText",
|
|
"file.exportText",
|
|
"file.importText",
|
|
"file.importDocument",
|
|
"file.exportImage",
|
|
"file.importImage",
|
|
"file.importAudio",
|
|
"file.exportAudio",
|
|
"file.imageDropped",
|
|
"notification.showLocal",
|
|
]
|
|
);
|
|
assert!(Value::from(capabilities()).as_array().is_some());
|
|
}
|
|
|
|
#[test]
|
|
fn runtime_capability_list_keeps_desktop_boundaries() {
|
|
let desktop_capabilities = capabilities();
|
|
let unique_capabilities = desktop_capabilities.iter().copied().collect::<HashSet<_>>();
|
|
|
|
assert_eq!(unique_capabilities.len(), desktop_capabilities.len());
|
|
|
|
for capability in [
|
|
"host.getRuntime",
|
|
"appearance.getColorScheme",
|
|
"host.events",
|
|
"app.lifecycle",
|
|
"share.open",
|
|
"share.setTarget",
|
|
"navigation.openNativePage",
|
|
"navigation.canGoBack",
|
|
"app.reloadWebView",
|
|
"app.openExternalUrl",
|
|
"app.setTitle",
|
|
"app.setBadgeCount",
|
|
"network.status",
|
|
"network.statusChanged",
|
|
"clipboard.writeText",
|
|
"clipboard.readText",
|
|
"file.exportText",
|
|
"file.importText",
|
|
"file.importDocument",
|
|
"file.exportImage",
|
|
"file.importImage",
|
|
"file.importAudio",
|
|
"file.exportAudio",
|
|
"file.imageDropped",
|
|
"notification.showLocal",
|
|
] {
|
|
assert!(desktop_capabilities.contains(&capability));
|
|
}
|
|
|
|
for capability in [
|
|
"auth.requestLogin",
|
|
"payment.request",
|
|
"file.captureImage",
|
|
"scanner.scanQrCode",
|
|
"haptics.impact",
|
|
] {
|
|
assert!(!desktop_capabilities.contains(&capability));
|
|
}
|
|
}
|
|
}
|