80 } 81 82 private Path desktopShortcutPath() { 83 return Path.of(cmd.name() + ".lnk"); 84 } 85 86 private void verifySystemDesktopShortcut(boolean exists) { 87 Path dir = Path.of(queryRegistryValueCache( 88 SYSTEM_SHELL_FOLDERS_REGKEY, "Common Desktop")); 89 Test.assertFileExists(dir.resolve(desktopShortcutPath()), exists); 90 } 91 92 private void verifyUserLocalDesktopShortcut(boolean exists) { 93 Path dir = Path.of( 94 queryRegistryValueCache(USER_SHELL_FOLDERS_REGKEY, "Desktop")); 95 Test.assertFileExists(dir.resolve(desktopShortcutPath()), exists); 96 } 97 98 private void verifyStartMenuShortcut() { 99 boolean appInstalled = cmd.launcherInstallationPath().toFile().exists(); 100 if (cmd.hasArgument("--win-menu") || !cmd.hasArgument("--win-shortcut")) { 101 if (isUserLocalInstall(cmd)) { 102 verifyUserLocalStartMenuShortcut(appInstalled); 103 verifySystemStartMenuShortcut(false); 104 } else { 105 verifySystemStartMenuShortcut(appInstalled); 106 verifyUserLocalStartMenuShortcut(false); 107 } 108 } else { 109 verifySystemStartMenuShortcut(false); 110 verifyUserLocalStartMenuShortcut(false); 111 } 112 } 113 114 private Path startMenuShortcutPath() { 115 return Path.of(cmd.getArgumentValue("--win-menu-group", 116 () -> "Unknown"), cmd.name() + ".lnk"); 117 } 118 119 private void verifySystemStartMenuShortcut(boolean exists) { 120 Path dir = Path.of(queryRegistryValueCache( 121 SYSTEM_SHELL_FOLDERS_REGKEY, "Common Programs")); 122 Test.assertFileExists(dir.resolve(startMenuShortcutPath()), exists); 123 } 124 125 private void verifyUserLocalStartMenuShortcut(boolean exists) { 126 Path dir = Path.of(queryRegistryValueCache( 127 USER_SHELL_FOLDERS_REGKEY, "Programs")); 128 Test.assertFileExists(dir.resolve(startMenuShortcutPath()), exists); 129 } 130 131 private void verifyFileAssociationsRegistry() { 132 Path faFile = cmd.getArgumentValue("--file-associations", 133 () -> (Path) null, Path::of); 134 if (faFile == null) { 135 return; 136 } 137 138 boolean appInstalled = cmd.launcherInstallationPath().toFile().exists(); 139 try { 140 Test.trace(String.format( 141 "Get file association properties from [%s] file", 142 faFile)); 143 Map<String, String> faProps = Files.readAllLines(faFile).stream().filter( 144 line -> line.trim().startsWith("extension=") || line.trim().startsWith( 145 "mime-type=")).map( 146 line -> { 147 String[] keyValue = line.trim().split("=", 2); 148 return Map.entry(keyValue[0], keyValue[1]); 149 }).collect(Collectors.toMap( 150 entry -> entry.getKey(), 151 entry -> entry.getValue())); 152 String suffix = faProps.get("extension"); 153 String contentType = faProps.get("mime-type"); 154 Test.assertNotNull(suffix, String.format( 155 "Check file association suffix [%s] is found in [%s] property file", 156 suffix, faFile)); 157 Test.assertNotNull(contentType, String.format( | 80 } 81 82 private Path desktopShortcutPath() { 83 return Path.of(cmd.name() + ".lnk"); 84 } 85 86 private void verifySystemDesktopShortcut(boolean exists) { 87 Path dir = Path.of(queryRegistryValueCache( 88 SYSTEM_SHELL_FOLDERS_REGKEY, "Common Desktop")); 89 Test.assertFileExists(dir.resolve(desktopShortcutPath()), exists); 90 } 91 92 private void verifyUserLocalDesktopShortcut(boolean exists) { 93 Path dir = Path.of( 94 queryRegistryValueCache(USER_SHELL_FOLDERS_REGKEY, "Desktop")); 95 Test.assertFileExists(dir.resolve(desktopShortcutPath()), exists); 96 } 97 98 private void verifyStartMenuShortcut() { 99 boolean appInstalled = cmd.launcherInstallationPath().toFile().exists(); 100 if (cmd.hasArgument("--win-menu")) { 101 if (isUserLocalInstall(cmd)) { 102 verifyUserLocalStartMenuShortcut(appInstalled); 103 verifySystemStartMenuShortcut(false); 104 } else { 105 verifySystemStartMenuShortcut(appInstalled); 106 verifyUserLocalStartMenuShortcut(false); 107 } 108 } else { 109 verifySystemStartMenuShortcut(false); 110 verifyUserLocalStartMenuShortcut(false); 111 } 112 } 113 114 private Path startMenuShortcutPath() { 115 return Path.of(cmd.getArgumentValue("--win-menu-group", 116 () -> "Unknown"), cmd.name() + ".lnk"); 117 } 118 119 private void verifySystemStartMenuShortcut(boolean exists) { 120 Path dir = Path.of(queryRegistryValueCache( 121 SYSTEM_SHELL_FOLDERS_REGKEY, "Common Programs")); 122 Test.assertFileExists(dir.resolve(startMenuShortcutPath()), exists); 123 } 124 125 private void verifyUserLocalStartMenuShortcut(boolean exists) { 126 Path dir = Path.of(queryRegistryValueCache( 127 USER_SHELL_FOLDERS_REGKEY, "Programs")); 128 Test.assertFileExists(dir.resolve(startMenuShortcutPath()), exists); 129 } 130 131 private void verifyFileAssociationsRegistry() { 132 Stream.of(cmd.getAllArgumentValues("--file-associations")).map( 133 Path::of).forEach(this::verifyFileAssociationsRegistry); 134 } 135 136 private void verifyFileAssociationsRegistry(Path faFile) { 137 boolean appInstalled = cmd.launcherInstallationPath().toFile().exists(); 138 try { 139 Test.trace(String.format( 140 "Get file association properties from [%s] file", 141 faFile)); 142 Map<String, String> faProps = Files.readAllLines(faFile).stream().filter( 143 line -> line.trim().startsWith("extension=") || line.trim().startsWith( 144 "mime-type=")).map( 145 line -> { 146 String[] keyValue = line.trim().split("=", 2); 147 return Map.entry(keyValue[0], keyValue[1]); 148 }).collect(Collectors.toMap( 149 entry -> entry.getKey(), 150 entry -> entry.getValue())); 151 String suffix = faProps.get("extension"); 152 String contentType = faProps.get("mime-type"); 153 Test.assertNotNull(suffix, String.format( 154 "Check file association suffix [%s] is found in [%s] property file", 155 suffix, faFile)); 156 Test.assertNotNull(contentType, String.format( |