Revert StaticDisplayState; For hosted only allow debug to be used.
[SquirrelJME.git] / modules / midp-lcdui / src / test / java / mleui / forms / TestItemDragging.java
blob3064ff04fe2bf9cfa027ba8f39ce23751ce27482
1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package mleui.forms;
12 import cc.squirreljme.jvm.mle.brackets.UIDisplayBracket;
13 import cc.squirreljme.jvm.mle.brackets.UIFormBracket;
14 import cc.squirreljme.jvm.mle.brackets.UIItemBracket;
15 import cc.squirreljme.jvm.mle.constants.UIItemPosition;
16 import cc.squirreljme.jvm.mle.constants.UIItemType;
17 import cc.squirreljme.runtime.lcdui.mle.UIBackend;
19 /**
20 * Drags an item across the form to ensure that it gets reassigned properly
21 * and the item only appears at the given index.
23 * @since 2020/07/19
25 public class TestItemDragging
26 extends BaseUIForm
28 /**
29 * {@inheritDoc}
30 * @since 2020/07/19
32 @Override
33 protected void test(UIBackend __backend, UIDisplayBracket __display,
34 UIFormBracket __form)
36 // This item will be dragged around
37 UIItemBracket item = __backend.itemNew(UIItemType.BUTTON);
39 // Move around each position!
40 int oldPos = UIItemPosition.NOT_ON_FORM;
41 for (int pos = UIItemPosition.MIN_VALUE; pos <= 0; pos++)
43 // Is the old position null?
44 if (oldPos != UIItemPosition.NOT_ON_FORM)
45 this.secondary("old-isnull-" + pos, __backend
46 .formItemAtPosition(__form, oldPos) == null);
48 // The position of the item then
49 this.secondary("then-pos-" + pos,
50 __backend.formItemPosition(__form, item));
52 // Set new item position
53 __backend.formItemPosition(__form, item, pos);
55 // Is the item at this position, this one?
56 this.secondary("now-isthis-" + pos,
57 __backend.equals(__backend.formItemAtPosition(__form, pos),
58 item));
60 // The position of the item now
61 this.secondary("now-pos-" + pos,
62 __backend.formItemPosition(__form, item));
64 // Old position becomes the current one
65 oldPos = pos;
68 this.secondary("zero-isthis", __backend.equals(
69 __backend.formItemAtPosition(__form, 0), item));
70 this.secondary("zero-pos",
71 __backend.formItemPosition(__form, item));