Test framework for testing image encoders.
netscape.test.plugin.composer package
java.lang.Object
Image encoders allow image data to be encoded to match specific image formats. The encoder examines the input data, communicates with the user as necessary, and then writes the encoded image to the output stream.
This test framework class is designed to test image encoders. The ImageEncoderTest class is called by the main method in an image encoder in the same way as the Test class is called from the main method of a plug-in.
The image encoder test creates a test image with dimensions of 512 by 512 pixels. This size is large enough to help identify any performance issues for your image encoder.
For directions for writing and compiling image encoders, see "Writing and Using Image Encoders."
This table summarizes ImageEncoderTest class methods:
Constructor | Description |
---|---|
ImageEncoderTest( String[]) |
Creates an instance of the ImageEncoderTest class |
Methods | Description |
createImageProducer( boolean) |
Creates an image producer |
test(ImageEncoder) | Tests the image encoder |
Test(String[], ImageEncoder) |
Tests the image encoder |
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Creates an instance of the ImageEncoderTest class
ImageEncoderTest class
public ImageEncoderTest(String args[])
args |
String arguments. For values, see the Test class definition. |
This method is the default constructor for an image encoder test framework. A default constructor must be public to allow your image encoder to be instantiated by name.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Creates an image producer.
ImageEncoderTest class
protected ImageProducer createImageProducer( boolean needsQuantizedSource);
needsQuantizedSource |
Whether the source image should be quantized |
Quantizing reduces the number of required bits per pixel from 24 to 8 bits per pixel (reduces distinct colors in the document to 256 or fewer), and is used when image formats require a lower number of bits/colors. For more information, see ImageEncoder.needsQuantizedSource.
An image producer.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Tests the image encoder.
ImageEncoderTest class
public static void Test(String args[], ImageEncoder encoder)
args |
String arguments. For values, see the Test class definition. |
encoder | The image encoder to test |
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Tests the image encoder.
ImageEncoderTest class
public void test(ImageEncoder encoder);
encoder | The image encoder to test |
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Allows you to test your plug-in separately from Netscape Composer.
netscape.test.plugin.composer package
java.lang.Object
This class is the Composer Plug-in Testbed. Test is called by the main method of a plug-in. You can run Test from the command line with this code:
java -classpath classPath netscape.test.plugin.composer.Test ..args..
Where args can be one or more of the following:
-plugin plugin |
Use the named plug-in. Default: netscape.plugin.composer.Plugin. |
-in inArg | Use the named file as the input text document. |
-out outArg | Use the named file as the output text document. |
-string stringArg | Use the given string as the test document. Default: A small built-in test document. |
-workDir workDirArg | Use the given directory as the work directory. Default: Java's user.dir property. |
-eventName event | Simulate an event of the given name. |
You usually do not need to derive from or instantiate Test. You can simply run it from the command line. However, for special test purposes, it might make sense to derive from Test and override methods like createDocument and createPlugin.
This table summarizes the members of the Test class:
Variables | |
---|---|
Field | Description |
eventNameArg | Name of an event |
inArg | Name of the input text file |
outArg | Name of the output text file |
plugin | Name of the plug-in to use |
stringArg | Name of the test document |
workDirArg | Name of the work directory |
Constructor | Description |
Test(String[]) | Creates an instance of the Test class |
Methods | |
createDocument() | Creates a document |
createPlugin() | Creates a plug-in |
main(String[]) | Public main() method; runs plug-in from command line |
newText(String) | Called when the plug-in being tested has set some new text into the test document |
perform(String[],
Plugin) |
Hook for plug-ins to test themselves |
reportDirectDocumentOpen() | Called when the plug-in being tested has called redirectDocumentOpen |
setPlugin(Plugin) | Sets the plug-in programmatically |
test() | Performs the test |
usage(String) | Prints usage information, then exits |
writeDoc( String, File) |
Writes document text to the supplied file |
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Name of an event to simulate
protected String eventNameArg
This variable is the value for the -eventName parameter in the command line run code for the Testbed. If you do not supply an event name, the value of the parameter is considered null. For a list of events, see the event table in "Composer Plug-in Events."
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Name of the input text file.
protected String inArg
This variable is the value for the -in parameter in the command line run code for the Testbed. If you do not supply a value, the default is null.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Name of the output text file.
protected String outArg
This variable is the value for the -out parameter in the command line run code for the Testbed. If you do not supply a value, the default is null.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Name of the plug-in to test.
protected Plugin plugin
This variable is the value for the -plugin parameter in the command line run code for the Testbed. If you do not supply a plug-in name, the default is netscape.plugin.composer.Plugin.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Name of the test document.
protected String stringArg
This variable is the value for the -string parameter in the command line run code for the Testbed. If you do not supply a value, the default is a small built-in test document.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Name of the work directory.
protected String workDirArg
This variable is the value for the -workDir parameter in the command line run code for the Testbed. If you do not supply a value, the default is Java's user.dir property.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
AddApplet, AddButton, AddLayer, Colorize, DocInfo, DocInfoResources, EditRaw, IFCTest, IFCTestBundle, ImageEncoderTest, SmallCaps, Tableize, TagStrip, TextImageEncoder
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Creates an instance of the Test class.
Test class
protected Test(String args[])
args |
Command-line arguments. For values, see the Test class definition. |
This method parses the arguments in the command line run code for the Testbed.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Creates a document.
Test class
protected TestDocument createDocument() throws IOException
Override this method to create your own type of document.
IOException
The Composer Plug-in API uses standard Java exceptions and exception handling. For more information, see your Java documentation.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Override to create your own plug-in.
Test class
protected Plugin createPlugin()
Override this to create your own plug-in. In most cases, you use the -plugin command line option, or supply the argument to the Test.perform method.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Public main method that creates and runs the plug-in test.
Test class
public static void main(String args[])
This public main method is called from outside of the Composer window. If you derive a new class from Test, you can create your own version of main, as follows:
public static void main(String[] args){ int status = 0; try { MyTest test = new MyTest(args); status = test.test(); } catch (Throwable t) { t.printStackTrace(); status = -1; } System.exit(status); }
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Called when the plug-in being tested has set some new text into the test document.
Test class
protected void newText(String text)
text |
The new text of the test document |
The default implementation prints the text to System.out. If you want to do other things, for example, compare the old text with the new text, you must override this method.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Hook for plug-ins to test themselves.
Test class
public static void perform(String args[], Plugin plugin)
args |
Command-line arguments. For values, see the Test class introduction. |
plugin |
Plug-in to test |
The perform method performs the work of the plug-in. In this case, it tests the plug-in you pass to it.
If you want to execute a plug-in from the command line, you must add a main method with the following format to its perform method. In the example, myPlugin is the name of your plug-in. You can remove this code before shipping your plug-in if you like, but leaving it will not affect the operation of the plug-in.
static public void main(String[] args) { Test.perform(args, new MyPlugin()); }
For more information about writing main methods to test plug-ins, including the run code to enter at the command line, see "Preparing for Running in the Testbed." Also, see Test.Main and the main methods of each of the sample plug-in classes that are part of the Testbed package.
Note:
The perform method calls System.exit at the end
of the test. This ensures that any AWT threads that may have been started
are closed down. If they are not, the application will never finish running.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Called when the plug-in being tested has called redirectDocumentOpen.
Test class
public void reportRedirectDocumentOpen( String eventName, String newURL)
eventName |
The current event; should always be edit |
newURL |
The new URL to which the open should be redirected |
The default implementation prints the new URL to System.out. If you want to do other things, you must override this method. As its event parameter, this method must always use edit, or the plug-in behaves incorrectly.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Sets the plug-in programmatically.
Test class
public void setPlugin(Plugin plugin)
plugin |
The plug-in to set |
This method is used by the Test.perform method.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Performs the test.
Test class
protected int test() throws IOException
To implement an alternative test technique, override this method.
IOException
The Composer Plug-in API uses standard Java exceptions and exception handling. For more information, see your Java documentation.
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Prints usage information, then exits.
Test class
protected void usage(String error)
error |
A string to print to System.err just before printing the usage information |
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Writes the document text to the supplied file.
Test class
protected void writeDoc(String doc, File out)
doc |
A document file |
out | The file to which to write output |
[Top] [Testbed Package Classes] [Composer Plug-in API Reference]
Last Updated: 03/10/2007 11:22:42
Copyright © 1997 Netscape Communications Corporation