TestCanvasSizingpublic class TestCanvasSizing extends com.sun.midp.i3test.TestCase This test case does extensive testing on the proper sizing
of Canvas. It validates the size reported to a Canvas under
various conditions, such as a canvas with a title, a ticker,
in standard screen mode, in fullscreen mode, as well as a
canvas which is newly created versus showing on the screen. |
Fields Summary |
---|
static final String | testNameTest Name | protected static int | STD_WIDTHScreen width in normal mode | protected static int | STD_HEIGHTScreen height in normal mode | protected static int | FS_WIDTHScreen width in fullsize mode | protected static int | FS_HEIGHTScreen height in fullsize mode | protected static int | TITLE_HEIGHTTitle height | protected static int | TICKER_HEIGHTTicker height | protected static int | SOFTBTN_HEIGHTSoftbutton height | protected Display | displayThe Display to use to view our test canvases | protected Ticker | tickerTest ticker, used for sizing only |
Constructors Summary |
---|
public TestCanvasSizing()Construct a new CanvasSizing test. The constructor
initializes all sizing constants from the chameleon
skin files.
// Initialize the constants
STD_WIDTH = ScreenSkin.WIDTH;
STD_HEIGHT = Constants.CHAM_HEIGHT;
FS_WIDTH = Constants.CHAM_FULLWIDTH;
FS_HEIGHT = Constants.CHAM_FULLHEIGHT;
TITLE_HEIGHT = TitleSkin.HEIGHT;
TICKER_HEIGHT = TickerSkin.HEIGHT;
SOFTBTN_HEIGHT = SoftButtonSkin.HEIGHT;
ticker = new Ticker("Canvas sizing test");
|
Methods Summary |
---|
protected void | checkCanvasSize(javax.microedition.lcdui.TestCanvasSizing$TestCanvas canvas, int WIDTH, int HEIGHT)This is a utility method which retrieves the canvas's size and
validates it against the passed in values after making sure
the canvas is visible on the screen.
display.setCurrent(canvas);
if (!canvas.awaitPaint()) {
fail("checkCanvasSize: canvas not visible");
return;
}
int w = canvas.getWidth();
int h = canvas.getHeight();
assertEquals("Checking canvas width (shown):", WIDTH, w);
assertEquals("Checking canvas height (shown):", HEIGHT, h);
| public void | runTests()Overridden from TestCase parent. This method will kick off each
individual test
try {
LcduiTestMIDlet.invoke();
display = LcduiTestMIDlet.getDisplay();
testOne();
testTwo();
testThree();
testFour();
testFive();
testSix();
testSeven();
testEight();
} finally {
LcduiTestMIDlet.cleanup();
}
| protected void | testEight()This test is for a canvas with no ticker and no title set in
fullscreen mode.
declare(testName + " 8: Fullsize screen mode, plain.");
TestCanvas canvas = new TestCanvas();
canvas.toggleFullscreen(true);
// NOTE: In fullscreen mode, the title and ticker shouldn't appear, as
// per the chameleon UI spec: that area is then used by the canvas
checkCanvasSize(canvas, FS_WIDTH, FS_HEIGHT);
| protected void | testFive()This test is for a canvas with a title and a ticker set in
fullscreen mode.
declare(testName + " 5: Fullsize screen mode with title and ticker.");
TestCanvas canvas = new TestCanvas();
canvas.setTitle("CanvasSizing Test 5");
canvas.setTicker(ticker);
canvas.toggleFullscreen(true);
// NOTE: In fullscreen mode, the title and ticker shouldn't appear, as
// per the chameleon UI spec: that area is then used by the canvas
checkCanvasSize(canvas, FS_WIDTH, FS_HEIGHT);
| protected void | testFour()This test is for a canvas with no title and no ticker set in
standard screen mode.
declare(testName + " 4: Standard screen mode, plain.");
TestCanvas canvas = new TestCanvas();
checkCanvasSize(canvas, STD_WIDTH, STD_HEIGHT - SOFTBTN_HEIGHT);
| protected void | testOne()This test is for a canvas with a title and a ticker set in
standard screen mode.
declare(testName + " 1: Standard screen mode with title and ticker.");
TestCanvas canvas = new TestCanvas();
canvas.setTitle("CanvasSizing Test 1");
canvas.setTicker(ticker);
checkCanvasSize(canvas, STD_WIDTH,
STD_HEIGHT - SOFTBTN_HEIGHT - TITLE_HEIGHT - TICKER_HEIGHT);
| protected void | testSeven()This test is for a canvas with a ticker but no title set in
fullscreen mode.
declare(testName + " 7: Fullsize screen mode with ticker.");
TestCanvas canvas = new TestCanvas();
canvas.setTicker(ticker);
canvas.toggleFullscreen(true);
// NOTE: In fullscreen mode, the title and ticker shouldn't appear, as
// per the chameleon UI spec: that area is then used by the canvas
checkCanvasSize(canvas, FS_WIDTH, FS_HEIGHT);
| protected void | testSix()This test is for a canvas with a title but no ticker set in
fullscreen mode.
declare(testName + " 6: Fullsize screen mode with title.");
TestCanvas canvas = new TestCanvas();
canvas.setTitle("CanvasSizing Test 6");
canvas.toggleFullscreen(true);
// NOTE: In fullscreen mode, the title and ticker shouldn't appear, as
// per the chameleon UI spec: that area is then used by the canvas
checkCanvasSize(canvas, FS_WIDTH, FS_HEIGHT);
| protected void | testThree()This test is for a canvas with a ticker but no title set in
standard screen mode.
declare(testName + " 3: Standard screen mode with ticker.");
TestCanvas canvas = new TestCanvas();
canvas.setTicker(ticker);
checkCanvasSize(canvas, STD_WIDTH,
STD_HEIGHT - SOFTBTN_HEIGHT - TICKER_HEIGHT);
| protected void | testTwo()This test is for a canvas with a title but no ticker set in
standard screen mode.
declare(testName + " 2: Standard screen mode with title.");
TestCanvas canvas = new TestCanvas();
canvas.setTitle("CanvasSizing Test 2");
checkCanvasSize(canvas, STD_WIDTH,
STD_HEIGHT - SOFTBTN_HEIGHT - TITLE_HEIGHT);
|
|