Path: blob/master/test/jdk/tools/jpackage/share/MultiLauncherTwoPhaseTest.java
41149 views
/*1* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223import java.nio.file.Path;24import java.io.IOException;25import jdk.jpackage.test.AdditionalLauncher;26import jdk.jpackage.test.PackageTest;27import jdk.jpackage.test.PackageType;28import jdk.jpackage.test.TKit;29import jdk.jpackage.test.Annotations.Test;30import jdk.jpackage.test.JPackageCommand;3132/**33* Test multiple launchers in two phases. First test creates app image and then34* creates installer from this image. Output of the test should be35* MultiLauncherTwoPhaseTest*.* installer. The output installer should be basic36* installer with 3 launcher MultiLauncherTwoPhaseTest, bar and foo. On Windows37* we should have start menu integration under MultiLauncherTwoPhaseTest and38* desktop shortcuts for all 3 launchers. Linux should also create shortcuts for39* all launchers.40*/4142/*43* @test44* @summary Multiple launchers in two phases45* @library ../helpers46* @library /test/lib47* @key jpackagePlatformPackage48* @build jdk.jpackage.test.*49* @modules jdk.jpackage/jdk.jpackage.internal50* @compile MultiLauncherTwoPhaseTest.java51* @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main52* --jpt-run=MultiLauncherTwoPhaseTest53*/5455public class MultiLauncherTwoPhaseTest {5657@Test58public static void test() throws IOException {59Path appimageOutput = TKit.createTempDirectory("appimage");6061JPackageCommand appImageCmd = JPackageCommand.helloAppImage()62.setArgumentValue("--dest", appimageOutput);6364AdditionalLauncher launcher1 = new AdditionalLauncher("bar");65launcher1.setDefaultArguments().applyTo(appImageCmd);6667AdditionalLauncher launcher2 = new AdditionalLauncher("foo");68launcher2.applyTo(appImageCmd);6970PackageTest packageTest = new PackageTest()71.addLauncherName("bar") // Add launchers name for verification72.addLauncherName("foo")73.addRunOnceInitializer(() -> appImageCmd.execute())74.addBundleDesktopIntegrationVerifier(true)75.addInitializer(cmd -> {76cmd.addArguments("--app-image", appImageCmd.outputBundle());77cmd.removeArgumentWithValue("--input");78})79.forTypes(PackageType.WINDOWS)80.addInitializer(cmd -> {81cmd.addArguments("--win-shortcut", "--win-menu",82"--win-menu-group", "MultiLauncherTwoPhaseTest");83})84.forTypes(PackageType.LINUX)85.addInitializer(cmd -> {86cmd.addArguments("--linux-shortcut");87});8889packageTest.run();90}91}929394