Use bIsmanaged to decide shortcut type

This commit is contained in:
Philip Kristoffersen
2021-12-31 14:57:39 +01:00
parent ecfee2ec42
commit 0e8509a87f
+25 -1
View File
@@ -25,6 +25,9 @@ pub(crate) struct ManifestItem {
#[serde(alias = "CatalogItemId")] #[serde(alias = "CatalogItemId")]
pub catalog_item_id: String, pub catalog_item_id: String,
#[serde(alias = "bIsManaged")]
pub is_managed: bool,
} }
fn exe_shortcut(manifest: ManifestItem) -> ShortcutOwned { fn exe_shortcut(manifest: ManifestItem) -> ShortcutOwned {
@@ -92,7 +95,7 @@ impl ManifestItem {
) )
} }
fn needs_launcher(&self) -> bool { fn needs_launcher(&self) -> bool {
false self.is_managed
} }
} }
@@ -117,4 +120,25 @@ mod tests {
assert_eq!(expected, actual); assert_eq!(expected, actual);
} }
#[test]
fn generates_shortcut_managed() {
let json = include_str!("example_item.json");
let mut manifest: ManifestItem = serde_json::from_str(json).unwrap();
manifest.is_managed = true;
let shortcut: ShortcutOwned = manifest.clone().into();
assert_eq!(shortcut.exe, "explorer.exe");
assert_eq!(shortcut.launch_options, manifest.get_launch_url());
}
#[test]
fn generates_shortcut_not_managed() {
let json = include_str!("example_item.json");
let mut manifest: ManifestItem = serde_json::from_str(json).unwrap();
manifest.is_managed = false;
let shortcut: ShortcutOwned = manifest.clone().into();
assert_eq!(shortcut.exe, "\"C:\\Games\\MarvelGOTG/retail/gotg.exe\"");
assert_eq!(shortcut.launch_options, "");
}
} }