diff options
author | Dejan Gloszic | 2006-02-09 21:44:55 +0000 |
---|---|---|
committer | Dejan Gloszic | 2006-02-09 21:44:55 +0000 |
commit | 63cc677f794e4c2179aa894af4c2693b1fc93720 (patch) | |
tree | 58b364f4e232df4ebdd62ec4d5ea0f0af95095d7 /org.eclipse.ua.tests/base | |
parent | 834e3d487a039eabb087a1e601194b6a4c0f2ed4 (diff) | |
download | eclipse.platform.ua-63cc677f794e4c2179aa894af4c2693b1fc93720.tar.gz eclipse.platform.ua-63cc677f794e4c2179aa894af4c2693b1fc93720.tar.xz eclipse.platform.ua-63cc677f794e4c2179aa894af4c2693b1fc93720.zip |
Bug 127103[Help] Add filtering to TOC
Diffstat (limited to 'org.eclipse.ua.tests/base')
-rw-r--r-- | org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllTests.java | 4 | ||||
-rw-r--r-- | org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java | 95 |
2 files changed, 95 insertions, 4 deletions
diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllTests.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllTests.java index d1b6ec515..51e4e6b6e 100644 --- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllTests.java +++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.ua.tests.cheatsheet.AllCheatSheetTests; +import org.eclipse.ua.tests.help.AllHelpTests; import org.eclipse.ua.tests.intro.AllIntroTests; /* @@ -34,5 +35,6 @@ public class AllTests extends TestSuite { public AllTests() { addTest(AllCheatSheetTests.suite()); addTest(AllIntroTests.suite()); + addTest(AllHelpTests.suite()); } } diff --git a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java index 1d3867aa4..23dfc7433 100644 --- a/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java +++ b/org.eclipse.ua.tests/base/org/eclipse/ua/tests/util/FileUtil.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2004 IBM Corporation and others. + * Copyright (c) 2005, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,6 +15,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import org.eclipse.core.runtime.Platform; import org.osgi.framework.Bundle; /* @@ -24,8 +25,7 @@ public class FileUtil { /** * Gets the contents of the file with the given relative path in the given bundle, - * as a String (file must - * be encoded as UTF-8). + * as a String (file must be encoded as UTF-8). */ public static String getContents(Bundle bundle, String relativePath) throws IOException { return readString(bundle.getEntry(relativePath).openStream()); @@ -40,6 +40,95 @@ public class FileUtil { } /** + * Generates a filename with path to the result file that will be generated + * for the intro xml referred to by the string. + */ + public static String getResultFile(String in) { + return getResultFile(in, false); + } + + /** + * Same as above, but gives the option of appending os, ws, and arch. For example, + * myfile_serialized_macosx_carbon_ppc.txt. + */ + public static String getResultFile(String in, boolean env) { + StringBuffer buf = new StringBuffer(); + buf.append(in.substring(0, in.lastIndexOf('.')) + "_serialized"); + if (env) { + buf.append('_'); + buf.append(Platform.getOS()); + buf.append('_'); + buf.append(Platform.getWS()); + buf.append('_'); + buf.append(Platform.getOSArch()); + } + buf.append(".txt"); + return buf.toString(); + } + + /** + * Gets the contents of the result file with the given original relative path in + * the given bundle, as a String (file must be encoded as UTF-8). + */ + public static String getResultFileContents(Bundle bundle, String absolutePath) throws IOException { + /* + * Try [filename]_serialized_os_ws_arch.txt. If it's not there, try + * [filename]_serialized.txt. + * + * We use different files for os/ws/arch combinations in order to test dynamic content, + * specifically filtering. Some of the files have filters by os, ws, and arch so the + * result is different on each combination. + */ + String contents = null; + try { + contents = getContents(bundle, getResultFile(absolutePath, true)); + } + catch(Exception e) { + // didn't find the _serialized_os_ws_arch.txt file, try just _serialized.txt + } + if (contents == null) { + try { + contents = getContents(bundle, getResultFile(absolutePath, false)); + } + catch(IOException e) { + throw e; + } + } + return contents; + } + + /** + * Gets the contents of the result file with the given original absolute path as + * a String (file must be encoded as UTF-8). + */ + public static String getResultFileContents(String absolutePath) throws IOException { + /* + * Try [filename]_serialized_os_ws_arch.txt. If it's not there, try + * [filename]_serialized.txt. + * + * We use different files for os/ws/arch combinations in order to test dynamic content, + * specifically filtering. Some of the files have filters by os, ws, and arch so the + * result is different on each combination. + */ + String contents = null; + try { + contents = getContents(getResultFile(absolutePath, true)); + } + catch(Exception e) { + // didn't find the _serialized_os_ws_arch.txt file, try just _serialized.txt + } + if (contents == null) { + try { + contents = getContents(getResultFile(absolutePath, false)); + } + catch(IOException e) { + throw e; + } + } + return contents; + } + + /** * Reads the contents of the input stream as UTF-8 and constructs and returns * as a String. */ |