/hg/icedtea-web: 2 new changesets
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Tue Jun 9 15:53:00 UTC 2015
changeset d0a5b33cf779 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=d0a5b33cf779
author: Jiri Vanek <jvanek at redhat.com>
date: Tue Jun 09 14:28:18 2015 +0200
Fixed bug when generated desktop icon was not matched and user was asked for recreation
* netx/net/sourceforge/jnlp/util/XDesktopEntry.java: (getShortcutTmpFile) (getLinuxDesktopIconFile) (getLinuxMenuIconFile) now generate file name by same way. By new method getDesktopIconFileName which is using sanitizing getDesktopIconName.
changeset f721899863b5 in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=f721899863b5
author: Jiri Vanek <jvanek at redhat.com>
date: Tue Jun 09 17:52:28 2015 +0200
Fixed issue, when desktop/menu shortcut created during -html mode, was not created like it
diffstat:
ChangeLog | 91 +++++---
netx/net/sourceforge/jnlp/runtime/Boot.java | 3 +
netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java | 11 +
netx/net/sourceforge/jnlp/util/FileUtils.java | 12 +-
netx/net/sourceforge/jnlp/util/XDesktopEntry.java | 43 ++-
tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java | 111 +++++++++-
6 files changed, 213 insertions(+), 58 deletions(-)
diffs (498 lines):
diff -r 9b3cfdc71c60 -r f721899863b5 ChangeLog
--- a/ChangeLog Tue Jun 09 13:02:00 2015 +0200
+++ b/ChangeLog Tue Jun 09 17:52:28 2015 +0200
@@ -1,3 +1,24 @@
+2015-06-09 Jiri Vanek <jvanek at redhat.com>
+
+ Fixed issue, when desktop/menu shortcut created during -html mode, was not created like it
+ * netx/net/sourceforge/jnlp/runtime/Boot.java: setHtml(true) used when
+ commandline contains html switch
+ * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: added html field and setter and getter
+ * netx/net/sourceforge/jnlp/util/XDesktopEntry.java: (getContentsAsReader) now
+ add -html if jnlpruntime.isHtml. Partially reworked logging of this method.
+ * tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java: added tests for new
+ functionality
+ * Changelog: occurence of tab asterix slash replaced by tab asterix space in file
+ declarations
+
+2015-06-09 Jiri Vanek <jvanek at redhat.com>
+
+ Fixed bug when generated desktop icon was not matched and user was asked for recreation
+ * netx/net/sourceforge/jnlp/util/XDesktopEntry.java: (getShortcutTmpFile)
+ (getLinuxDesktopIconFile) (getLinuxMenuIconFile) now generate file name by
+ same way. By new method getDesktopIconFileName which is using sanitizing
+ getDesktopIconName.
+
2015-06-01 Jiri Vanek <jvanek at redhat.com>
SecurityDialog return type changed from Object (mostly int) to regular type
@@ -81,26 +102,26 @@
2015-06-01 Jiri Vanek <jvanek at redhat.com>
Remember panel extracted so it can be reused
- */netx/net/sourceforge/jnlp/security/SecurityDialogs.java: now correctly behaves on Xtrustall
- */netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java:
+ * netx/net/sourceforge/jnlp/security/SecurityDialogs.java: now correctly behaves on Xtrustall
+ * netx/net/sourceforge/jnlp/security/appletextendedsecurity/UnsignedAppletTrustConfirmation.java:
result is using diamond
- */netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningDialog.java:
+ * netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningDialog.java:
Simplified constructors, getting dialogue and jnlpfile is all they need
- */netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanel.java:
+ * netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanel.java:
extracted remember panel and related stuff. Made to use extracted one
- */netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/MatchingALACAttributePanel.java:
+ * netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/MatchingALACAttributePanel.java:
same
- */netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/PartiallySignedAppTrustWarningPanel.java:
+ * netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/PartiallySignedAppTrustWarningPanel.java:
same
- */netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/UnsignedAppletTrustWarningPanel.java:
+ * netx/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/UnsignedAppletTrustWarningPanel.java:
same
- */netx/net/sourceforge/jnlp/security/dialogs/remember/ActionChoiceListener.java:
+ * netx/net/sourceforge/jnlp/security/dialogs/remember/ActionChoiceListener.java:
new class. Extracted stuff from AppTrustWarningPanel
- */netx/net/sourceforge/jnlp/security/dialogs/remember/AppSigningWarningAction.java:
+ * netx/net/sourceforge/jnlp/security/dialogs/remember/AppSigningWarningAction.java:
new class. Extracted stuff from AppTrustWarningPanel
- */netx/net/sourceforge/jnlp/security/dialogs/remember/RememberPanel.java:
+ * netx/net/sourceforge/jnlp/security/dialogs/remember/RememberPanel.java:
new class. Extracted stuff from AppTrustWarningPanel
- */tests/netx/unit/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanelTest.java:
+ * tests/netx/unit/net/sourceforge/jnlp/security/dialogs/apptrustwarningpanel/AppTrustWarningPanelTest.java:
minor, adapted to match current codebase
2015-05-27 Jiri Vanek <jvanek at redhat.com>
@@ -332,25 +353,25 @@
2015-04-13 Jiri Vanek <jvanek at redhat.com>
set single place for keystore operations
- */netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: usage of keystore moved
+ * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: usage of keystore moved
to utility method
- */netx/net/sourceforge/jnlp/security/CertificateUtils.java: same
- */netx/net/sourceforge/jnlp/security/KeyStores.java: same
- */netx/net/sourceforge/jnlp/security/dialogs/CertWarningPane.java: same
- */netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java: same
- */netx/net/sourceforge/jnlp/security/SecurityUtil.java: added five new methods
+ * netx/net/sourceforge/jnlp/security/CertificateUtils.java: same
+ * netx/net/sourceforge/jnlp/security/KeyStores.java: same
+ * netx/net/sourceforge/jnlp/security/dialogs/CertWarningPane.java: same
+ * netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java: same
+ * netx/net/sourceforge/jnlp/security/SecurityUtil.java: added five new methods
wrapping work on keystores
2015-04-13 Jiri Vanek <jvanek at redhat.com>
Removed redundant occurrence of default keystore password
- */netx/net/sourceforge/jnlp/security/KeyStores.java: removed redundant DEFAULT_PASSWORD
- */netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: call to KeyStores.getPassword
+ * netx/net/sourceforge/jnlp/security/KeyStores.java: removed redundant DEFAULT_PASSWORD
+ * netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java: call to KeyStores.getPassword
replaced by SecurityUtil.getTrustedCertsPassword
- */netx/net/sourceforge/jnlp/security/CertificateUtils.java: same
- */netx/net/sourceforge/jnlp/security/SecurityUtil.java: same
- */netx/net/sourceforge/jnlp/security/dialogs/CertWarningPane.java: same
- */netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java: same
+ * netx/net/sourceforge/jnlp/security/CertificateUtils.java: same
+ * netx/net/sourceforge/jnlp/security/SecurityUtil.java: same
+ * netx/net/sourceforge/jnlp/security/dialogs/CertWarningPane.java: same
+ * netx/net/sourceforge/jnlp/security/viewer/CertificatePane.java: same
2015-04-13 Jiri Vanek <jvanek at redhat.com>
@@ -1166,34 +1187,34 @@
2014-12-05 Jiri Vanek <jvanek at redhat.com>
Added support for menu shortcuts.
- */netx/net/sourceforge/jnlp/Parser.java: used setMenu instead of addMenu
- */netx/net/sourceforge/jnlp/ShortcutDesc.java: removed isOnline support,
+ * netx/net/sourceforge/jnlp/Parser.java: used setMenu instead of addMenu
+ * netx/net/sourceforge/jnlp/ShortcutDesc.java: removed isOnline support,
added onDesktop and toMenu support. addMenu renamed to setMenu.
Added deploymentJavawsShortcutToString, just for comfortableness.
- */netx/net/sourceforge/jnlp/config/PathsAndFiles.java: Added support for
+ * netx/net/sourceforge/jnlp/config/PathsAndFiles.java: Added support for
XDG_DATA_HOME, declared ICONS_DIR and MENUS_DIR
- */netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java: removed
+ * netx/net/sourceforge/jnlp/controlpanel/DesktopShortcutPanel.java: removed
duplicated logic of deploymentJavawsShortcutToString/comboboxItem and
hardcoded calls to depolyment.
- */netx/net/sourceforge/jnlp/resources/Messages.properties: added
+ * netx/net/sourceforge/jnlp/resources/Messages.properties: added
CPTabMenuShortcuts, FILEicons, FILEmenus. adapted SDesktopShortcut
- */netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java:
+ * netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java:
removed retired fixme, now it do not ask for shortcut creation if menu or
desktop entry exists. Added menu support and removed not-implemented call.
Added temporary IconsCreationDescriptor qiockfix for dialog->logic information
rtransfer. Used where needed.
- */netx/net/sourceforge/jnlp/security/SecurityDialogs.java: Added boolean
+ * netx/net/sourceforge/jnlp/security/SecurityDialogs.java: Added boolean
and integer workarounds around showAccessWarningDialog
- */netx/net/sourceforge/jnlp/security/dialogs/AccessWarningPane.java: Added
+ * netx/net/sourceforge/jnlp/security/dialogs/AccessWarningPane.java: Added
menu support.
Is now coding more sophisticated return value if are about desktop creations.
- */netx/net/sourceforge/jnlp/services/ServiceUtil.java: Adapted to
+ * netx/net/sourceforge/jnlp/services/ServiceUtil.java: Adapted to
showAccessWarningDialog changes
- */netx/net/sourceforge/jnlp/util/FileUtils.java: INVALID_CHARS extended
+ * netx/net/sourceforge/jnlp/util/FileUtils.java: INVALID_CHARS extended
for more linux one and most windows ones.
- */netx/net/sourceforge/jnlp/util/XDesktopEntry.java: added logic to place
+ * netx/net/sourceforge/jnlp/util/XDesktopEntry.java: added logic to place
menu shortcut.
- */tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java: Is now testing only
+ * tests/netx/unit/net/sourceforge/jnlp/ParserBasic.java: Is now testing only
presence of isOnline instead if it is used.
diff -r 9b3cfdc71c60 -r f721899863b5 netx/net/sourceforge/jnlp/runtime/Boot.java
--- a/netx/net/sourceforge/jnlp/runtime/Boot.java Tue Jun 09 13:02:00 2015 +0200
+++ b/netx/net/sourceforge/jnlp/runtime/Boot.java Tue Jun 09 17:52:28 2015 +0200
@@ -177,6 +177,9 @@
if (optionParser.hasOption(OptionsDefinitions.OPTIONS.TRUSTALL)) {
JNLPRuntime.setTrustAll(true);
}
+ if (optionParser.hasOption(OptionsDefinitions.OPTIONS.HTML)) {
+ JNLPRuntime.setHtml(true);
+ }
if (optionParser.hasOption(OptionsDefinitions.OPTIONS.TRUSTNONE)) {
JNLPRuntime.setTrustNone(true);
}
diff -r 9b3cfdc71c60 -r f721899863b5 netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java
--- a/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Tue Jun 09 13:02:00 2015 +0200
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPRuntime.java Tue Jun 09 17:52:28 2015 +0200
@@ -151,6 +151,9 @@
/** all security dialogs will be consumed and pretented as being verified by user and allowed.*/
private static boolean trustAll=false;
+
+ /** flag keeping rest of jnlpruntime live that javaws was lunched as -html */
+ private static boolean html=false;
/** all security dialogs will be consumed and we will pretend the Sandbox option was chosen */
private static boolean trustNone = false;
@@ -830,6 +833,14 @@
}
}
+ public static void setHtml(boolean html) {
+ JNLPRuntime.html = html;
+ }
+
+ public static boolean isHtml() {
+ return html;
+ }
+
static void setTrustAll(boolean b) {
trustAll=b;
}
diff -r 9b3cfdc71c60 -r f721899863b5 netx/net/sourceforge/jnlp/util/FileUtils.java
--- a/netx/net/sourceforge/jnlp/util/FileUtils.java Tue Jun 09 13:02:00 2015 +0200
+++ b/netx/net/sourceforge/jnlp/util/FileUtils.java Tue Jun 09 17:52:28 2015 +0200
@@ -30,6 +30,7 @@
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;
+import java.io.Reader;
import java.io.Writer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
@@ -575,8 +576,15 @@
* @throws IOException if connection can't be established or resource does not exist
*/
public static String getContentOfStream(InputStream is, String encoding) throws IOException {
+ try {
+ return getContentOfReader(new InputStreamReader(is, encoding));
+ } finally {
+ is.close();
+ }
+ }
+ public static String getContentOfReader(Reader r) throws IOException {
try {
- BufferedReader br = new BufferedReader(new InputStreamReader(is, encoding));
+ BufferedReader br = new BufferedReader(r);
StringBuilder sb = new StringBuilder();
while (true) {
String s = br.readLine();
@@ -588,7 +596,7 @@
}
return sb.toString();
} finally {
- is.close();
+ r.close();
}
}
diff -r 9b3cfdc71c60 -r f721899863b5 netx/net/sourceforge/jnlp/util/XDesktopEntry.java
--- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java Tue Jun 09 13:02:00 2015 +0200
+++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java Tue Jun 09 17:52:28 2015 +0200
@@ -40,6 +40,7 @@
import net.sourceforge.jnlp.IconDesc;
import net.sourceforge.jnlp.JNLPFile;
+import net.sourceforge.jnlp.OptionsDefinitions;
import net.sourceforge.jnlp.PluginBridge;
import net.sourceforge.jnlp.StreamEater;
import net.sourceforge.jnlp.cache.CacheUtil;
@@ -149,36 +150,42 @@
if (file.getInformation().getVendor() != null) {
fileContents += "Vendor=" + sanitize(file.getInformation().getVendor()) + "\n";
}
-
+ String exec;
+ String title = "xdesktop writing";
if (JNLPRuntime.isWebstartApplication()) {
- fileContents += "Exec="
- + getJavaWsBin() + " \"" + file.getSourceLocation() + "\"\n";
- OutputController.getLogger().log("Using " + getJavaWsBin() + " as binary for " + file.getSourceLocation());
+ String htmlSwitch = "";
+ if (JNLPRuntime.isHtml()){
+ htmlSwitch = " "+OptionsDefinitions.OPTIONS.HTML.option;
+ }
+ exec = "Exec="
+ + getJavaWsBin() + htmlSwitch + " \"" + file.getSourceLocation() + "\"\n";
+ fileContents += exec;
} else {
if (info.getShortcutType() == AccessWarningPaneComplexReturn.ShortcutResult.Shortcut.BROWSER) {
String browser = info.getBrowser();
if (browser == null) {
browser = getBrowserBin();
}
- fileContents += "Exec="
+ exec = "Exec="
+ browser + " \"" + file.getSourceLocation() + "\"\n";
- OutputController.getLogger().log("Using " + browser + " as binary for " + file.getSourceLocation());
+ fileContents += exec;
} else if ((info.getShortcutType() == AccessWarningPaneComplexReturn.ShortcutResult.Shortcut.GENERATED_JNLP
|| info.getShortcutType() == AccessWarningPaneComplexReturn.ShortcutResult.Shortcut.JNLP_HREF) && generatedJnlp != null) {
- fileContents += "Exec="
+ exec = "Exec="
+ getJavaWsBin() + " \"" + generatedJnlp.getAbsolutePath() + "\"\n";
- OutputController.getLogger().log("Using " + getJavaWsBin() + " (generated) as binary for " + file.getSourceLocation() + " to " + generatedJnlp.getAbsolutePath());
+ fileContents += exec;
+ title = title + " (generated jnlp)";
} else if (info.getShortcutType() == AccessWarningPaneComplexReturn.ShortcutResult.Shortcut.JAVAWS_HTML) {
- fileContents += "Exec="
+ exec = "Exec="
+ getJavaWsBin() + " -html \"" + file.getSourceLocation() + "\"\n";
- OutputController.getLogger().log("Using " + getJavaWsBin() + " -html as binary for " + file.getSourceLocation());
+ fileContents += exec;
} else {
- fileContents += "Exec="
+ exec = "Exec="
+ getBrowserBin() + " \"" + file.getSourceLocation() + "\"\n";
- OutputController.getLogger().log("Using " + getBrowserBin() + " as binary for " + file.getSourceLocation());
+ fileContents += exec;
}
}
-
+ OutputController.getLogger().log(title + " " + exec);
return new StringReader(fileContents);
}
@@ -266,7 +273,7 @@
public File getShortcutTmpFile() {
String userTmp = PathsAndFiles.TMP_DIR.getFullPath();
- File shortcutFile = new File(userTmp + File.separator + FileUtils.sanitizeFileName(file.getTitle()) + ".desktop");
+ File shortcutFile = new File(userTmp + File.separator + getDesktopIconFileName());
return shortcutFile;
}
@@ -497,11 +504,15 @@
}
public File getLinuxDesktopIconFile() {
- return new File(findFreedesktopOrgDesktopPathCatch() + "/" + getDesktopIconName() + ".desktop");
+ return new File(findFreedesktopOrgDesktopPathCatch() + "/" + getDesktopIconFileName());
}
public File getLinuxMenuIconFile() {
- return new File(findAndVerifyJavawsMenuDir() + "/" + getDesktopIconName() + ".desktop");
+ return new File(findAndVerifyJavawsMenuDir() + "/" + getDesktopIconFileName());
+ }
+
+ private String getDesktopIconFileName() {
+ return getDesktopIconName() + ".desktop";
}
private static String findAndVerifyGeneratedJnlpDir() {
diff -r 9b3cfdc71c60 -r f721899863b5 tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java Tue Jun 09 13:02:00 2015 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/util/XDesktopEntryTest.java Tue Jun 09 17:52:28 2015 +0200
@@ -37,15 +37,25 @@
package net.sourceforge.jnlp.util;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
+import java.io.Reader;
import java.io.StringReader;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.net.MalformedURLException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import net.sourceforge.jnlp.InformationDesc;
+import net.sourceforge.jnlp.JNLPFile;
+import net.sourceforge.jnlp.PluginBridgeTest;
import net.sourceforge.jnlp.ServerAccess;
import net.sourceforge.jnlp.annotations.KnownToFail;
+import net.sourceforge.jnlp.mock.DummyJNLPFileWithJar;
+import net.sourceforge.jnlp.runtime.JNLPRuntime;
+import net.sourceforge.jnlp.security.dialogresults.AccessWarningPaneComplexReturn;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
@@ -74,6 +84,32 @@
private static final String src8 = XDesktopEntry.XDG_DESKTOP_DIR + " = " + des8;
private static final String src9 = XDesktopEntry.XDG_DESKTOP_DIR + " = " + des9;
private static Map<String, String> backupedEnv;
+ private static boolean wasHtml;
+ private static boolean wasJavaws;
+
+ @BeforeClass
+ public static void saveJnlpRuntimeHtml() {
+ wasHtml = JNLPRuntime.isHtml();
+ wasJavaws = JNLPRuntime.isWebstartApplication();
+ }
+
+ private static void setIsWebstart(boolean value) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
+ Field field = JNLPRuntime.class.getDeclaredField("isWebstartApplication");
+ field.setAccessible(true);
+ field.set(null, value);
+ }
+
+ @After
+ public void restoreJnlpRuntimeHtml() throws Exception {
+ JNLPRuntime.setHtml(wasHtml);
+ setIsWebstart(wasJavaws);
+ }
+
+ @AfterClass
+ public static void restoreJnlpRuntimeHtmlFinally() throws Exception {
+ JNLPRuntime.setHtml(wasHtml);
+ setIsWebstart(wasJavaws);
+ }
@BeforeClass
public static void ensureHomeVaribale() throws NoSuchFieldException, IllegalAccessException, IllegalArgumentException, ClassNotFoundException {
@@ -84,7 +120,7 @@
backupedEnv = null;
} else {
backupedEnv = env;
- Map<String,String> m = new HashMap<String,String>(env);
+ Map<String, String> m = new HashMap<>(env);
m.put(HOME, System.getProperty("user.home"));
fakeEnvironment(m);
ServerAccess.logOutputReprint("Hacked environment");
@@ -102,7 +138,7 @@
}
}
- private static void fakeEnvironment(Map<String,String> m) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
+ private static void fakeEnvironment(Map<String, String> m) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, ClassNotFoundException {
Class<?> processEnvironmentClass = Class.forName("java.lang.ProcessEnvironment");
Field env = processEnvironmentClass.getDeclaredField("theUnmodifiableEnvironment");
env.setAccessible(true);
@@ -123,13 +159,13 @@
@Test
public void getFreedesktopOrgDesktopPathFromtestSimple() throws IOException {
String s = XDesktopEntry.getFreedesktopOrgDesktopPathFrom(new BufferedReader(new StringReader(src1)));
- Assert.assertEquals(s, des1);
+ Assert.assertEquals(des1, s);
}
@Test
public void getFreedesktopOrgDesktopPathFromtestSpaced() throws IOException {
String s = XDesktopEntry.getFreedesktopOrgDesktopPathFrom(new BufferedReader(new StringReader(src2)));
- Assert.assertEquals(s, des1);
+ Assert.assertEquals(des1, s);
}
@Test(expected = IOException.class)
@@ -160,6 +196,7 @@
String s = XDesktopEntry.getFreedesktopOrgDesktopPathFrom(new BufferedReader(new StringReader(src8)));
Assert.assertEquals(s, des8res);
}
+
@Test
public void getFreedesktopOrgDesktopPathFromtestSpacedWithHomeAndMixedQuotes() throws IOException {
String s = XDesktopEntry.getFreedesktopOrgDesktopPathFrom(new BufferedReader(new StringReader(src9)));
@@ -181,4 +218,68 @@
ServerAccess.logOutputReprint(entry.getKey() + " = " + entry.getValue());
}
}
-}
\ No newline at end of file
+
+ @Test
+ public void allFilesHaveSameName() throws IOException {
+ JNLPFile jnlpf = new DummyJnlpWithTitle();
+ XDesktopEntry xde = new XDesktopEntry(jnlpf);
+ File f1 = xde.getShortcutTmpFile();
+ File f2 = xde.getLinuxDesktopIconFile();
+ File f3 = xde.getLinuxMenuIconFile();
+ Assert.assertEquals(f1.getName(), f2.getName());
+ Assert.assertEquals(f2.getName(), f3.getName());
+ }
+
+ private void testHtmlOccurences(boolean html, boolean javaws, boolean menu, AccessWarningPaneComplexReturn.ShortcutResult.Shortcut type, int occurences) throws Exception {
+ JNLPRuntime.setHtml(html);
+ setIsWebstart(javaws);
+ JNLPFile jnlpf = new DummyJnlpWithTitle();
+ XDesktopEntry xde = new XDesktopEntry(jnlpf);
+ AccessWarningPaneComplexReturn.ShortcutResult a = new AccessWarningPaneComplexReturn.ShortcutResult(true);
+ a.setBrowser("blah");
+ a.setFixHref(false);
+ a.setShortcutType(type);
+ Reader r = xde.getContentsAsReader(menu, a, true);
+ String s = FileUtils.getContentOfReader(r);
+ Assert.assertEquals(occurences, PluginBridgeTest.countOccurences(s, "-html"));
+ }
+
+ @Test
+ public void htmlSwitchCorrectAccordingToJnlpRuntimeAndShortcutType() throws Exception {
+ AccessWarningPaneComplexReturn.ShortcutResult.Shortcut[] v = AccessWarningPaneComplexReturn.ShortcutResult.Shortcut.values();
+ for (AccessWarningPaneComplexReturn.ShortcutResult.Shortcut w : v) {
+ int var1 = 0;
+ if (w == AccessWarningPaneComplexReturn.ShortcutResult.Shortcut.JAVAWS_HTML) {
+ var1 = 1;
+ }
+ testHtmlOccurences(true, true, true, w, 1);
+ testHtmlOccurences(true, false, false, w, var1);
+ testHtmlOccurences(true, false, true, w, var1);
+ testHtmlOccurences(true, true, false, w, 1);
+ testHtmlOccurences(false, true, true, w, 0);
+ testHtmlOccurences(false, false, false, w, var1);
+ testHtmlOccurences(false, true, false, w, 0);
+ testHtmlOccurences(false, false, true, w, var1);
+ }
+ }
+
+ private static class DummyJnlpWithTitle extends DummyJNLPFileWithJar {
+
+ public DummyJnlpWithTitle() throws MalformedURLException {
+ super(new File("/some/path/blah.jar"));
+ }
+
+ @Override
+ public InformationDesc getInformation() {
+ return new InformationDesc(null, false) {
+
+ @Override
+ public String getTitle() {
+ return "Demo App";
+ }
+
+ };
+ }
+
+ };
+}
More information about the distro-pkg-dev
mailing list