From 9c9604cae594fc8b1e52c3ae5cdf8edfc6705fae Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Wed, 17 Sep 2014 15:33:39 -0700 Subject: [PATCH] Add test for setARGBColor and getAlphaComponent --- tests/gfx/ARGBColorTest.java | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/gfx/ARGBColorTest.java diff --git a/tests/gfx/ARGBColorTest.java b/tests/gfx/ARGBColorTest.java new file mode 100644 index 00000000..df2e7595 --- /dev/null +++ b/tests/gfx/ARGBColorTest.java @@ -0,0 +1,55 @@ +package gfx; + +import javax.microedition.lcdui.*; +import javax.microedition.midlet.*; +import com.nokia.mid.ui.*; + +public class ARGBColorTest extends MIDlet { + private Command quitCommand; + private Display display; + + class TestCanvas extends Canvas { + protected void paint(Graphics g) { + g.setColor(255, 0, 0); + g.fillRect(0, 0, getWidth(), getHeight()); + g.setColor(0, 0, 255); + g.fillRect(20, 30, 200, 80); + + DirectUtils.getDirectGraphics(g).setARGBColor(0x00FFFFFF); + if (DirectUtils.getDirectGraphics(g).getAlphaComponent() != 0) { + System.out.println("FAIL"); + } + g.fillRect(0, 0, getWidth(), getHeight()); + + // The alpha value is set to fully opaque when setColor is called + g.setColor(0, 0, 0); + if (DirectUtils.getDirectGraphics(g).getAlphaComponent() != 0xFF) { + System.out.println("FAIL"); + } + + DirectUtils.getDirectGraphics(g).setARGBColor(0xFF00FF00); + if (DirectUtils.getDirectGraphics(g).getAlphaComponent() != 0xFF) { + System.out.println("FAIL"); + } + g.fillRect(40, 50, 160, 40); + + System.out.println("PAINTED"); + } + } + + public ARGBColorTest() { + display = Display.getDisplay(this); + } + + public void startApp() { + TestCanvas test = new TestCanvas(); + display.setCurrent(test); + } + + public void pauseApp() { + } + + public void destroyApp(boolean unconditional) { + } +} +