mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
GP-4296 - Fixed screen reader support of tooltips using html
This commit is contained in:
parent
dffb5fd859
commit
0b0356528d
43 changed files with 349 additions and 342 deletions
|
@ -15,14 +15,6 @@
|
|||
*/
|
||||
package help.screenshot;
|
||||
|
||||
import help.GHelpBuilder;
|
||||
import help.HelpBuildUtils;
|
||||
import help.validator.UnusedHelpImageFileFinder;
|
||||
import help.validator.location.DirectoryHelpModuleLocation;
|
||||
import help.validator.location.HelpModuleLocation;
|
||||
import help.validator.model.HelpTopic;
|
||||
import help.validator.model.IMG;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -36,6 +28,14 @@ import java.util.Map.Entry;
|
|||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import help.GHelpBuilder;
|
||||
import help.HelpBuildUtils;
|
||||
import help.validator.UnusedHelpImageFileFinder;
|
||||
import help.validator.location.DirectoryHelpModuleLocation;
|
||||
import help.validator.location.HelpModuleLocation;
|
||||
import help.validator.model.HelpTopic;
|
||||
import help.validator.model.IMG;
|
||||
|
||||
public class HelpMissingScreenShotReportGenerator {
|
||||
|
||||
private static boolean debugEnabled;
|
||||
|
@ -68,17 +68,17 @@ public class HelpMissingScreenShotReportGenerator {
|
|||
generator.generateReport();
|
||||
}
|
||||
|
||||
private Set<HelpModuleLocation> helpDirectories = new HashSet<HelpModuleLocation>();
|
||||
private Map<String, HelpTopic> topicNameToTopic = new HashMap<String, HelpTopic>();
|
||||
private Set<HelpTestCase> testCases = new HashSet<HelpTestCase>();
|
||||
private Map<String, HelpTestCase> imageNameToTestCase = new HashMap<String, HelpTestCase>();
|
||||
private Set<HelpModuleLocation> helpDirectories = new HashSet<>();
|
||||
private Map<String, HelpTopic> topicNameToTopic = new HashMap<>();
|
||||
private Set<HelpTestCase> testCases = new HashSet<>();
|
||||
private Map<String, HelpTestCase> imageNameToTestCase = new HashMap<>();
|
||||
|
||||
private SortedSet<String> badlyNamedTestFiles = new TreeSet<String>();
|
||||
private SortedSet<HelpTestCase> badlyNamedTestCases = new TreeSet<HelpTestCase>();
|
||||
private SortedSet<String> badlyNamedTestFiles = new TreeSet<>();
|
||||
private SortedSet<HelpTestCase> badlyNamedTestCases = new TreeSet<>();
|
||||
// private Map<HelpDirectory, IMG> untestedImages = new TreeMap<HelpDirectory, IMG>();
|
||||
private Map<HelpTopic, Set<IMG>> untestedImages = new TreeMap<HelpTopic, Set<IMG>>();
|
||||
private Map<HelpTopic, Set<IMG>> untestedImages = new TreeMap<>();
|
||||
|
||||
private Set<Path> examinedImageFiles = new HashSet<Path>();
|
||||
private Set<Path> examinedImageFiles = new HashSet<>();
|
||||
|
||||
private File outputFile;
|
||||
|
||||
|
@ -125,8 +125,8 @@ public class HelpMissingScreenShotReportGenerator {
|
|||
writer.write("<P>\n");
|
||||
|
||||
//
|
||||
// Total Image File Count
|
||||
//
|
||||
// Total Image File Count
|
||||
//
|
||||
int untestedCount = 0;
|
||||
Collection<Set<IMG>> values = untestedImages.values();
|
||||
for (Set<IMG> set : values) {
|
||||
|
@ -141,7 +141,7 @@ public class HelpMissingScreenShotReportGenerator {
|
|||
|
||||
//
|
||||
// All Tested Images
|
||||
//
|
||||
//
|
||||
writer.write("<H3>\n");
|
||||
writer.write("Total Tested Images: " + imageNameToTestCase.size() + "\n");
|
||||
writer.write("</H3>\n");
|
||||
|
@ -432,7 +432,7 @@ public class HelpMissingScreenShotReportGenerator {
|
|||
|
||||
Set<IMG> set = untestedImages.get(topic);
|
||||
if (set == null) {
|
||||
set = new TreeSet<IMG>();
|
||||
set = new TreeSet<>();
|
||||
untestedImages.put(topic, set);
|
||||
}
|
||||
|
||||
|
@ -619,7 +619,7 @@ public class HelpMissingScreenShotReportGenerator {
|
|||
}
|
||||
|
||||
private void writeHeader(BufferedWriter writer) throws IOException {
|
||||
writer.write("<HTML>\n");
|
||||
writer.write("<html>\n");
|
||||
writer.write("<HEAD>\n");
|
||||
createStyleSheet(writer);
|
||||
writer.write("</HEAD>\n");
|
||||
|
@ -635,7 +635,7 @@ public class HelpMissingScreenShotReportGenerator {
|
|||
writer.write("<BR>\n");
|
||||
|
||||
writer.write("</BODY>\n");
|
||||
writer.write("</HTML>\n");
|
||||
writer.write("</html>\n");
|
||||
}
|
||||
|
||||
private void createStyleSheet(BufferedWriter writer) throws IOException {
|
||||
|
@ -643,11 +643,16 @@ public class HelpMissingScreenShotReportGenerator {
|
|||
writer.write("<!--\n");
|
||||
|
||||
writer.write("body { font-family:arial; font-size:22pt }\n");
|
||||
writer.write("h1 { color:#000080; font-family:times new roman; font-size:28pt; font-weight:bold; text-align:center; }\n");
|
||||
writer.write("h2 { color:#984c4c; font-family:times new roman; font-size:28pt; font-weight:bold; }\n");
|
||||
writer.write("h2.title { color:#000080; font-family:times new roman; font-size:14pt; font-weight:bold; text-align:center;}\n");
|
||||
writer.write("h3 { color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; margin-left:.5in }\n");
|
||||
writer.write("table { margin-left:1in; margin-right:1in; min-width:20em; width:90%; background-color:#EEEEFF }\n");
|
||||
writer.write(
|
||||
"h1 { color:#000080; font-family:times new roman; font-size:28pt; font-weight:bold; text-align:center; }\n");
|
||||
writer.write(
|
||||
"h2 { color:#984c4c; font-family:times new roman; font-size:28pt; font-weight:bold; }\n");
|
||||
writer.write(
|
||||
"h2.title { color:#000080; font-family:times new roman; font-size:14pt; font-weight:bold; text-align:center;}\n");
|
||||
writer.write(
|
||||
"h3 { color:#0000ff; font-family:times new roman; font-size:14pt; font-weight:bold; margin-left:.5in }\n");
|
||||
writer.write(
|
||||
"table { margin-left:1in; margin-right:1in; min-width:20em; width:90%; background-color:#EEEEFF }\n");
|
||||
writer.write("th { text-align:center; }\n");
|
||||
writer.write("td { text-align:left; padding: 20px }\n");
|
||||
|
||||
|
@ -665,7 +670,8 @@ public class HelpMissingScreenShotReportGenerator {
|
|||
private Path filePath;
|
||||
private HelpTopic helpTopic;
|
||||
|
||||
HelpTestFile(HelpModuleLocation helpDir, HelpTopic helpTopic, Path filePath, String filename) {
|
||||
HelpTestFile(HelpModuleLocation helpDir, HelpTopic helpTopic, Path filePath,
|
||||
String filename) {
|
||||
this.helpDir = helpDir;
|
||||
this.helpTopic = helpTopic;
|
||||
this.filePath = filePath;
|
||||
|
|
|
@ -146,7 +146,7 @@ public class HelpScreenShotReportGenerator {
|
|||
}
|
||||
|
||||
private void writeHeader(BufferedWriter writer) throws IOException {
|
||||
writer.write("<HTML>\n");
|
||||
writer.write("<html>\n");
|
||||
writer.write("<HEAD>\n");
|
||||
createStyleSheet(writer);
|
||||
writer.write("</HEAD>\n");
|
||||
|
@ -178,7 +178,7 @@ public class HelpScreenShotReportGenerator {
|
|||
writer.write("</P>\n");
|
||||
|
||||
writer.write("</BODY>\n");
|
||||
writer.write("</HTML>\n");
|
||||
writer.write("</html>\n");
|
||||
}
|
||||
|
||||
private void createStyleSheet(BufferedWriter writer) throws IOException {
|
||||
|
|
|
@ -94,8 +94,8 @@ public abstract class AbstractHelpTest extends AbstractGenericTest {
|
|||
Path file = Files.createFile(fullTOCPath);
|
||||
|
||||
//@formatter:off
|
||||
String TOCXML = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
|
||||
"<!-- Auto-generated on Fri Apr 03 09:37:08 EDT 2015 -->\n\n" +
|
||||
String TOCXML = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n" +
|
||||
"<!-- Auto-generated on Fri Apr 03 09:37:08 EDT 2015 -->\n\n" +
|
||||
|
||||
"<tocroot>\n" +
|
||||
"</tocroot>\n";
|
||||
|
@ -114,14 +114,14 @@ public abstract class AbstractHelpTest extends AbstractGenericTest {
|
|||
}
|
||||
|
||||
//@formatter:off
|
||||
String HTML =
|
||||
"<HTML>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
String HTML =
|
||||
"<html>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
"<LINK rel=\"stylesheet\" type=\"text/css\" href=\"help/shared/DefaultStyle.css\">\n" +
|
||||
"</HEAD>\n" +
|
||||
|
||||
"<BODY>\n" +
|
||||
"<BODY>\n" +
|
||||
" <H1><A name=\""+anchor+"\"></A>Configure Tool</H1>\n" +
|
||||
" Some text with reference to shared image <IMG src=\"help/shared/note.png\">\n" +
|
||||
" \n" +
|
||||
|
@ -140,19 +140,19 @@ public abstract class AbstractHelpTest extends AbstractGenericTest {
|
|||
assertNotNull("Must specify the A tag HREF attribute", HREF);
|
||||
|
||||
//@formatter:off
|
||||
String HTML =
|
||||
"<HTML>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
String HTML =
|
||||
"<html>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
"<LINK rel=\"stylesheet\" type=\"text/css\" href=\"help/shared/DefaultStyle.css\">\n" +
|
||||
"</HEAD>\n" +
|
||||
|
||||
"<BODY>\n" +
|
||||
"<BODY>\n" +
|
||||
" <H1><A name=\"Fake_Anchor\"></A>Configure Tool</H1>\n" +
|
||||
" And this is a link <A HREF=\""+HREF+"\">Click Me</A>" +
|
||||
" And this is a link <A HREF=\""+HREF+"\">Click Me</A>" +
|
||||
" \n" +
|
||||
"</BODY>\n" +
|
||||
"</HTML>\n";
|
||||
"</html>\n";
|
||||
//@formatter:on
|
||||
|
||||
Files.write(file, HTML.getBytes(), StandardOpenOption.CREATE);
|
||||
|
@ -167,19 +167,19 @@ public abstract class AbstractHelpTest extends AbstractGenericTest {
|
|||
assertNotNull("Must specify the A tag SRC attribute", SRC);
|
||||
|
||||
//@formatter:off
|
||||
String HTML =
|
||||
"<HTML>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
String HTML =
|
||||
"<html>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
"<LINK rel=\"stylesheet\" type=\"text/css\" href=\"help/shared/DefaultStyle.css\">\n" +
|
||||
"</HEAD>\n" +
|
||||
|
||||
"<BODY>\n" +
|
||||
"<BODY>\n" +
|
||||
" <H1><A name=\"Fake_Anchor\"></A>Configure Tool</H1>\n" +
|
||||
" Some text with reference to shared image <IMG src=\""+SRC+"\">\n" +
|
||||
" Some text with reference to shared image <IMG src=\""+SRC+"\">\n" +
|
||||
" \n" +
|
||||
"</BODY>\n" +
|
||||
"</HTML>\n";
|
||||
"</html>\n";
|
||||
//@formatter:on
|
||||
|
||||
Files.write(file, HTML.getBytes(), StandardOpenOption.CREATE);
|
||||
|
|
|
@ -150,7 +150,7 @@ public class HelpFileTest extends AbstractHelpTest {
|
|||
assertTrue(hrefs.isEmpty());
|
||||
}
|
||||
|
||||
// @Test
|
||||
// @Test
|
||||
// for debugging a real help file
|
||||
public void test() throws Exception {
|
||||
|
||||
|
@ -183,18 +183,18 @@ public class HelpFileTest extends AbstractHelpTest {
|
|||
String badAttr = "bob=1";
|
||||
|
||||
//@formatter:off
|
||||
String HTML =
|
||||
"<HTML>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
String HTML =
|
||||
"<html>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
"<LINK rel=\"stylesheet\" type=\"text/css\" href=\"help/shared/DefaultStyle.css\">\n" +
|
||||
"</HEAD>\n" +
|
||||
"<BODY>\n" +
|
||||
"<BODY>\n" +
|
||||
"<H1><A name=\"ManagePluginsDialog\"></A>Configure Tool</H1>\n" +
|
||||
"Some text with reference to shared image <a "+badAttr+">Click me</a>\n" +
|
||||
"\n" +
|
||||
"</BODY>\n" +
|
||||
"</HTML>\n";
|
||||
"</html>\n";
|
||||
//@formatter:on
|
||||
|
||||
Files.write(file, HTML.getBytes(), StandardOpenOption.CREATE);
|
||||
|
@ -208,18 +208,18 @@ public class HelpFileTest extends AbstractHelpTest {
|
|||
String badAttr = "bob=1";
|
||||
|
||||
//@formatter:off
|
||||
String HTML =
|
||||
"<HTML>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
String HTML =
|
||||
"<html>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
"<LINK rel=\"stylesheet\" type=\"text/css\" href=\"help/shared/DefaultStyle.css\">\n" +
|
||||
"</HEAD>\n" +
|
||||
"<BODY>\n" +
|
||||
"<BODY>\n" +
|
||||
"<H1><A name=\"ManagePluginsDialog\"></A>Configure Tool</H1>\n" +
|
||||
"Some text with reference to shared image <IMG "+badAttr+"s>\n" +
|
||||
"\n" +
|
||||
"</BODY>\n" +
|
||||
"</HTML>\n";
|
||||
"</html>\n";
|
||||
//@formatter:on
|
||||
|
||||
Files.write(file, HTML.getBytes(), StandardOpenOption.CREATE);
|
||||
|
@ -233,18 +233,18 @@ public class HelpFileTest extends AbstractHelpTest {
|
|||
String badURI = ":baduri"; // no scheme name on this URI
|
||||
|
||||
//@formatter:off
|
||||
String HTML =
|
||||
"<HTML>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
String HTML =
|
||||
"<html>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
"<LINK rel=\"stylesheet\" type=\"text/css\" href=\"help/shared/DefaultStyle.css\">\n" +
|
||||
"</HEAD>\n" +
|
||||
"<BODY>\n" +
|
||||
"<BODY>\n" +
|
||||
"<H1><A name=\"ManagePluginsDialog\"></A>Configure Tool</H1>\n" +
|
||||
"Some text with reference to shared image <a href=\""+badURI+"\">Click me</a>\n" +
|
||||
"\n" +
|
||||
"</BODY>\n" +
|
||||
"</HTML>\n";
|
||||
"</html>\n";
|
||||
//@formatter:on
|
||||
|
||||
Files.write(file, HTML.getBytes(), StandardOpenOption.CREATE);
|
||||
|
@ -258,18 +258,18 @@ public class HelpFileTest extends AbstractHelpTest {
|
|||
String badName = "bad_name";
|
||||
|
||||
//@formatter:off
|
||||
String HTML =
|
||||
"<HTML>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
String HTML =
|
||||
"<html>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
"<LINK rel=\"stylesheet\" type=\"text/css\" href=\"../../shared/"+badName+".css\">\n" +
|
||||
"</HEAD>\n" +
|
||||
"<BODY>\n" +
|
||||
"<BODY>\n" +
|
||||
"<H1><A name=\"ManagePluginsDialog\"></A>Configure Tool</H1>\n" +
|
||||
"Some text with reference to shared image <IMG src=\"help/shared/DefaultStyle.css\">\n" +
|
||||
"\n" +
|
||||
"</BODY>\n" +
|
||||
"</HTML>\n";
|
||||
"</html>\n";
|
||||
//@formatter:on
|
||||
|
||||
Files.write(file, HTML.getBytes(), StandardOpenOption.CREATE);
|
||||
|
@ -284,20 +284,20 @@ public class HelpFileTest extends AbstractHelpTest {
|
|||
String badURI = ":baduri"; // no scheme name on this URI
|
||||
|
||||
//@formatter:off
|
||||
String HTML =
|
||||
"<HTML>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
String HTML =
|
||||
"<html>\n" +
|
||||
"<HEAD>\n" +
|
||||
"<TITLE>Configure Tool</TITLE>\n" +
|
||||
"<LINK rel=\"stylesheet\" type=\"text/css\" href=\"help/shared/DefaultStyle.css\">\n" +
|
||||
"</HEAD>\n" +
|
||||
"<BODY>\n" +
|
||||
"<BODY>\n" +
|
||||
"<H1><A name=\"ManagePluginsDialog\"></A>Configure Tool</H1>\n" +
|
||||
" <!--" +
|
||||
" Some text with reference to shared image <a href=\""+badURI+"\">Click me</a>\n" +
|
||||
" -->" +
|
||||
" -->" +
|
||||
"\n" +
|
||||
"</BODY>\n" +
|
||||
"</HTML>\n";
|
||||
"</html>\n";
|
||||
//@formatter:on
|
||||
|
||||
Files.write(file, HTML.getBytes(), StandardOpenOption.CREATE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue