Check-in [0d2733deab]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add more tests for Canvas.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | wip-midlcdui
Files: files | file ages | folders
SHA1:0d2733deaba1b1838ed75496a9db0e94d9a32d8f
User & Date: stephanie.gawroriski 2020-08-02 16:18:06
Context
2020-08-02
16:20
Service repaints to force them to happen. check-in: 21d1c8a12a user: stephanie.gawroriski tags: wip-midlcdui
16:18
Add more tests for Canvas. check-in: 0d2733deab user: stephanie.gawroriski tags: wip-midlcdui
2020-08-01
16:19
Update from trunk. check-in: 410cfcb731 user: stephanie.gawroriski tags: wip-midlcdui
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/midp-lcdui/src/main/java/javax/microedition/lcdui/Canvas.java.

35
36
37
38
39
40
41

42



43
44
45
46
47
48
49
...
129
130
131
132
133
134
135

136



137
138
139

140



141
142
143

144



145
146
147
148
149
150
151
	
	public static final int ACTIONS_NAVIGATION =
		-1;
	
	public static final int ACTIONS_NONE =
		0;
	

	/** This is a game key for the down direction. */



	public static final int DOWN =
		6;
	
	/** This is a game key for the fire button. */
	public static final int FIRE =
		8;
	
................................................................................
	public static final int KEY_TAB =
		9;
	
	/** The up arrow key. */
	public static final int KEY_UP =
		-1;
	

	/** This is a game key for the left direction. */



	public static final int LEFT =
		2;
	

	/** This is a game key for the right direction. */



	public static final int RIGHT =
		5;
	

	/** This is a game key for the up direction. */



	public static final int UP =
		1;
	
	/** The key listener to use. */
	private KeyListener _keylistener;
	
	/** Is the rendering transparent or opaque? */







>
|
>
>
>







 







>
|
>
>
>



>
|
>
>
>



>
|
>
>
>







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
...
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
	
	public static final int ACTIONS_NAVIGATION =
		-1;
	
	public static final int ACTIONS_NONE =
		0;
	
	/**
	 * This is a game key for the down direction.
	 * 
	 * The bits of this key are {@code 0b110}, inverted from {@link #UP}.
	 */
	public static final int DOWN =
		6;
	
	/** This is a game key for the fire button. */
	public static final int FIRE =
		8;
	
................................................................................
	public static final int KEY_TAB =
		9;
	
	/** The up arrow key. */
	public static final int KEY_UP =
		-1;
	
	/** 
	 * This is a game key for the left direction.
	 * 
	 * The bits of this key are {@code 0b010}, inverted from {@link #RIGHT}.
	 */
	public static final int LEFT =
		2;
	
	/**
	 * This is a game key for the right direction.
	 * 
	 * The bits of this key are {@code 0b101}, inverted from {@link #LEFT}.
	 */
	public static final int RIGHT =
		5;
	
	/** 
	 * This is a game key for the up direction.
	 * 
	 * The bits of this key are {@code 0b001}, inverted from {@link #DOWN}.
	 */
	public static final int UP =
		1;
	
	/** The key listener to use. */
	private KeyListener _keylistener;
	
	/** Is the rendering transparent or opaque? */

Changes to modules/midp-lcdui/src/test/java/lcdui/canvas/BaseCanvas.java.

38
39
40
41
42
43
44


45
46




47


	@Override
	public final void test(Display __display)
		throws Throwable
	{
		CanvasPlatform platform = new CanvasPlatform();
		__display.setCurrent(platform);
		


		this.test(__display, platform);
	}




}









>
>
|
|
>
>
>
>
|
>
>
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
	@Override
	public final void test(Display __display)
		throws Throwable
	{
		CanvasPlatform platform = new CanvasPlatform();
		__display.setCurrent(platform);
		
		try
		{
			this.test(__display, platform);
		}
		finally
		{
			if (__display.getCurrent() == platform)
				__display.removeCurrent();
		}
	}
}

Changes to modules/midp-lcdui/src/test/java/lcdui/canvas/CanvasPlatform.java.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package lcdui.canvas;

import cc.squirreljme.runtime.cldc.debug.Debugging;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

/**
 * A platform for testing canvases.
 *
 * @since 2020/07/26







<







5
6
7
8
9
10
11

12
13
14
15
16
17
18
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package lcdui.canvas;


import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

/**
 * A platform for testing canvases.
 *
 * @since 2020/07/26

Added modules/midp-lcdui/src/test/java/lcdui/canvas/TestCanvasSize.java.

























































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package lcdui.canvas;

import javax.microedition.lcdui.Display;

/**
 * Tests that canvases have some size to them.
 *
 * @since 2020/08/02
 */
public class TestCanvasSize
	extends BaseCanvas
{
	@Override
	public void test(Display __display, CanvasPlatform __platform)
	{
		this.secondary("width", __platform.getWidth() > 0);
		this.secondary("height", __platform.getHeight() > 0);
	}
}

Added modules/midp-lcdui/src/test/java/lcdui/canvas/TestCanvasStandardKeyCodes.java.





































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
// ---------------------------------------------------------------------------
// Multi-Phasic Applications: SquirrelJME
//     Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
// ---------------------------------------------------------------------------
// SquirrelJME is under the GNU General Public License v3+, or later.
// See license.mkd for licensing and copyright information.
// ---------------------------------------------------------------------------

package lcdui.canvas;

import cc.squirreljme.runtime.cldc.debug.Debugging;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;

/**
 * Tests that the standard key codes do infact map to game keys.
 *
 * @since 2020/08/02
 */
public class TestCanvasStandardKeyCodes
	extends BaseCanvas
{
	/**
	 * {@inheritDoc}
	 * @since 2020/08/02
	 */
	@Override
	public void test(Display __display, CanvasPlatform __platform)
	{
		// Set bits within the mask
		long gameKeyMask = 0;
		for (int i = Canvas.KEY_SELECT; i <= Canvas.KEY_DELETE; i++)
			try
			{
				int gameKey = __platform.getGameAction(i);
				
				if (gameKey <= 0)
					continue;
				
				gameKeyMask |= (1 << gameKey);
			}
			catch (IllegalArgumentException ignored)
			{
			}
		
		// There should have been all the game keys in this
		this.secondary("mask", gameKeyMask);
	}
}

Added modules/midp-lcdui/src/test/resources/lcdui/canvas/TestCanvasRepaint.in.







>
>
>
1
2
3
result: NoResult
thrown: NoExceptionThrown
secondary-repainted: true

Added modules/midp-lcdui/src/test/resources/lcdui/canvas/TestCanvasSize.in.









>
>
>
>
1
2
3
4
result: NoResult
thrown: NoExceptionThrown
secondary-width: true
secondary-height: true

Added modules/midp-lcdui/src/test/resources/lcdui/canvas/TestCanvasStandardKeyCodes.in.







>
>
>
1
2
3
result: NoResult
thrown: NoExceptionThrown
secondary-mask: long:8038