ImageEncoderTest


Test framework for testing image encoders.

Class of

netscape.test.plugin.composer package

Superclass

java.lang.Object

Description

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


See Also

Test, TextImageEncoder  

[Top] [Testbed Package Classes] [Composer Plug-in API Reference


Constructor


ImageEncoderTest

Creates an instance of the ImageEncoderTest class

Method of

ImageEncoderTest class

Syntax

public ImageEncoderTest(String args[])

Parameters

args
String arguments. For values, see the Test class definition.

Description

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


Methods


createImageProducer

Creates an image producer.

Method of

ImageEncoderTest class

Syntax

protected ImageProducer createImageProducer(
                boolean needsQuantizedSource);

Parameters

needsQuantizedSource
Whether the source image should be quantized

Description

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.

Returns

An image producer.

[Top] [Testbed Package Classes] [Composer Plug-in API Reference


Test

Tests the image encoder.

Method of

ImageEncoderTest class

Syntax

public static void Test(String args[],
                        ImageEncoder encoder)

Parameters

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


test

Tests the image encoder.

Method of

ImageEncoderTest class

Syntax

public void test(ImageEncoder encoder);

Parameters

encoder The image encoder to test

[Top] [Testbed Package Classes] [Composer Plug-in API Reference


Test


Allows you to test your plug-in separately from Netscape Composer.

Class of

netscape.test.plugin.composer package

Superclass

java.lang.Object

Description

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


Variables


eventNameArg

Name of an event to simulate

Syntax

protected String eventNameArg

Description

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


inArg

Name of the input text file.

Syntax

protected String inArg

Description

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


outArg

Name of the output text file.

Syntax

protected String outArg

Description

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


plugin

Name of the plug-in to test.

Syntax

protected Plugin plugin

Description

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


stringArg

Name of the test document.

Syntax

protected String stringArg

Description

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


workDirArg

Name of the work directory.

Syntax

protected String workDirArg

Description

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


See Also

AddApplet, AddButton, AddLayer, Colorize, DocInfo, DocInfoResources, EditRaw, IFCTest, IFCTestBundle, ImageEncoderTest, SmallCaps, Tableize, TagStrip, TextImageEncoder

[Top] [Testbed Package Classes] [Composer Plug-in API Reference


Constructors


Test

Creates an instance of the Test class.

Method of

Test class

Syntax

protected Test(String args[])

Parameters

args
Command-line arguments. For values, see the Test class definition.

Description

This method parses the arguments in the command line run code for the Testbed.

[Top] [Testbed Package Classes] [Composer Plug-in API Reference


Methods


createDocument

Creates a document.

Method of

Test class

Syntax

protected TestDocument createDocument() throws IOException

Description

Override this method to create your own type of document.

Throws

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]


createPlugin

Override to create your own plug-in.

Method of

Test class

Syntax

protected Plugin createPlugin()

Description

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


main

Public main method that creates and runs the plug-in test.

Method of

Test class

Syntax

public static void main(String args[])

Description

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


newText

Called when the plug-in being tested has set some new text into the test document.

Method of

Test class

Syntax

protected void newText(String text)

Parameters

text
The new text of the test document

Description

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]


perform

Hook for plug-ins to test themselves.

Method of

Test class

Syntax

public static void perform(String args[], Plugin plugin)

Parameters

args
Command-line arguments. For values, see the Test class introduction.
plugin
Plug-in to test

Description

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


reportRedirectDocumentOpen

Called when the plug-in being tested has called redirectDocumentOpen.

Method of

Test class

Syntax

public void reportRedirectDocumentOpen(
                    String eventName,
                    String newURL)

Parameters

eventName
The current event; should always be edit
newURL
The new URL to which the open should be redirected

Description

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


setPlugin

Sets the plug-in programmatically.

Method of

Test class

Syntax

public void setPlugin(Plugin plugin)

Parameters

plugin
The plug-in to set

Description

This method is used by the Test.perform method.

[Top] [Testbed Package Classes] [Composer Plug-in API Reference]


test

Performs the test.

Method of

Test class

Syntax

protected int test() throws IOException

Description

To implement an alternative test technique, override this method.

Returns

Throws

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]


usage

Prints usage information, then exits.

Method of

Test class

Syntax

protected void usage(String error)

Parameters

error
A string to print to System.err just before printing the usage information

[Top] [Testbed Package Classes] [Composer Plug-in API Reference


writeDoc

Writes the document text to the supplied file.

Method of

Test class

Syntax

protected void writeDoc(String doc, File out)

Parameters

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