| java.lang.Object com.sun.midp.i3test.TestCase javax.microedition.lcdui.TestNewSetCurrent
TestNewSetCurrent | public class TestNewSetCurrent extends TestCase (Code) | | Tests proper behavior of Display.setCurrent() for a single midlet in the
foreground. Various combinations of "normal" (i.e., non-Alert) Displayable
instances are tested with the one-arg and two-arg Alert forms of the
setCurrent() method.
The notation used to name tests is as follows.
The operations initiated by the tests are:
N setCurrent(normal [non-Alert] Displayable)
A setCurrent(Alert)
2 setCurrent(Alert, Displayable)
D dismiss the current Alert
Codes for context or waits for event processing are:
0 tests Display's initial state (current == null)
_ wait for a screen-change event to be processed
s suffix indicating a displayable is the same as a previous one
For example, testA_2 first calls setCurrent(alert1), waits for the alert to
become current, then calls setCurrent(alert2, disp1). Note that this
notation doesn't include an initial setCurrentWait() call that is typically
used to establish the initial state for the test. In such cases the initial
displayable will be numbered zero, that is, disp0 or cv0. This is in
contrast to displayables and alerts that are used in the operations being
tested, which are numbered starting at one.
Quite often it is necessary to execute code atomically on the event thread,
that is, ensuring that no events are processed within a group of
statements. Code running on the test thread is arbitrarily interleaved with
code running on the event thread. For example, suppose Displayable d0 is
current. If the following code were executed on the test thread,
dpy.setCurrent(d1);
dpy.setCurrent(alert);
there would be a race condition between d1 becoming current and the call to
setCurrent(alert). Runnable blocks are used to group a set of statements to
be executed atomically. Runnable blocks are used in two different ways:
using callSerially() and using await(). In both cases the run() method is
executed on the event thread. This prevents any other events from being
dispatched in the midst of the code of the run() method. For example:
dpy.callSerially(
new Runnable() {
public void run() {
// (1)
}
});
scl.await(
new Runnable() {
public void run() {
// (2)
}
});
The code (1) is executed atomically on the event thread, and the calling
thread continues. The code (2) is executed atomically on the event thread
immediately after the next screen change occurs. The calling thread is
blocked until the screen change occurs and the run() method has completed.
|
Method Summary | |
void | checkCurrent(String s, LcduiTestCanvas cv, boolean isCurrent) Checks a variety of invariants on test canvas cv, depending upon
whether the canvas should or should not be current. | void | checkCurrent(String s, Alert alert, boolean shouldBeCurrent) Checks a variety of invariants on an alert, depending upon
whether the alert should or should not be current. | void | dismiss(Alert alert) Simulates dismissing an alert from this display. | void | dismissWait(Alert alert) Dismisses the alert and then waits for the resulting screen-change
event to be processed. | void | fini() Cleans up the test MIDlet. | void | init() Creates the test MIDlet and get its display. | Alert | makeAlert(String title) Creates a new alert and sets its timeout to FOREVER so that it must be
dismissed explicitly. | public void | runTests() Runs all tests. | void | setCurrentWait(Displayable d) Sets the Displayable to be current, waits for it to become visible, and
returns. | void | test0A0A() Case: 0A0A. | void | test2() Case: 2. | void | test22() Case: 22. | void | test22s() Case 22s. | void | test2A() Case: 2A. | void | test2N() Case: 2N. | void | test2_2() Case: 2_2. | void | test2_2s() Case 2_2s. | void | test2_A() Case: 2_A. | void | test2_N() Case: 2_N. | void | testA() Case: A. | void | testA2() Case: A2. | void | testA2s() Case: A2s. | void | testAA() Case: AA. | void | testAAs() Case: AAs. | void | testAN() Case: AN. | void | testAND() Case: AND. | void | testA_2() Case: A_2. | void | testA_2s() Case: A_2s. | void | testA_A() Tests setCurrent(Alert) when an alert is already visible. | void | testA_As() Tests setCurrent on the same alert when it is already visible. | void | testA_N() Case: A_N. | void | testA_NA() Case: A_NA. | void | testAlertAlert() Tests setCurrent(alert, alert). | void | testInit() Tests whether the display has been initialized properly. | void | testN() Case: N. | void | testN2() Case: N2. | void | testNA() Case: NA. | void | testNN() Case: NN. | void | testNNsN() Case: NNsN. | void | testN_N() Case: N_N. | void | testN_NNs() Case: N_NNs. |
checkCurrent | void checkCurrent(String s, LcduiTestCanvas cv, boolean isCurrent)(Code) | | Checks a variety of invariants on test canvas cv, depending upon
whether the canvas should or should not be current.
|
checkCurrent | void checkCurrent(String s, Alert alert, boolean shouldBeCurrent)(Code) | | Checks a variety of invariants on an alert, depending upon
whether the alert should or should not be current.
|
dismiss | void dismiss(Alert alert)(Code) | | Simulates dismissing an alert from this display. The logic here mimics
the logic of what occurs when the Alert times out and executes its
default (DISMISS) command. This allows tests to set the alert timeout
to FOREVER and to call this function in the right sequence, without
having to deal with timing issues.
|
dismissWait | void dismissWait(Alert alert)(Code) | | Dismisses the alert and then waits for the resulting screen-change
event to be processed.
|
fini | void fini()(Code) | | Cleans up the test MIDlet.
|
init | void init() throws Throwable(Code) | | Creates the test MIDlet and get its display.
|
makeAlert | Alert makeAlert(String title)(Code) | | Creates a new alert and sets its timeout to FOREVER so that it must be
dismissed explicitly.
|
setCurrentWait | void setCurrentWait(Displayable d)(Code) | | Sets the Displayable to be current, waits for it to become visible, and
returns.
|
test0A0A | void test0A0A()(Code) | | Case: 0A0A. Tests whether the system returns to the original (null)
state after an alert. Does so twice in order to ensure that the first
setCurrent doesn't have any side effects. WARNING: this must be run on
a fresh display.
|
test2 | void test2()(Code) | | Case: 2.
|
test22 | void test22()(Code) | | Case: 22.
|
test22s | void test22s()(Code) | | Case 22s. Tests the behavior of two, two-arg setCurrent calls, where
the alert in question is the same in both cases.
|
test2A | void test2A()(Code) | | Case: 2A.
|
test2N | void test2N()(Code) | | Case: 2N.
|
test2_2 | void test2_2()(Code) | | Case: 2_2.
|
test2_2s | void test2_2s()(Code) | | Case 2_2s. Tests the behavior of two, two-arg setCurrent calls, where
the alert in question is the same in both cases.
|
test2_A | void test2_A()(Code) | | Case: 2_A.
|
test2_N | void test2_N()(Code) | | Case: 2_N.
|
testA | void testA()(Code) | | Case: A.
|
testA2 | void testA2()(Code) | | Case: A2.
|
testA2s | void testA2s()(Code) | | Case: A2s.
|
testAA | void testAA()(Code) | | Case: AA.
|
testAAs | void testAAs()(Code) | | Case: AAs.
|
testAN | void testAN()(Code) | | Case: AN.
|
testAND | void testAND()(Code) | | Case: AND.
Tests alert timeout while it's shown, while another screen change event
is in the queue.
|
testA_2 | void testA_2()(Code) | | Case: A_2.
|
testA_2s | void testA_2s()(Code) | | Case: A_2s.
|
testA_A | void testA_A()(Code) | | Tests setCurrent(Alert) when an alert is already visible.
Case: A_A.
|
testA_As | void testA_As()(Code) | | Tests setCurrent on the same alert when it is already visible.
Case: A_As.
|
testA_N | void testA_N()(Code) | | Case: A_N.
|
testA_NA | void testA_NA()(Code) | | Case: A_NA.
|
testAlertAlert | void testAlertAlert()(Code) | | Tests setCurrent(alert, alert). This is basically an API test.
|
testInit | void testInit()(Code) | | Tests whether the display has been initialized properly.
|
testN | void testN()(Code) | | Case: N.
|
testN2 | void testN2()(Code) | | Case: N2.
|
testNA | void testNA()(Code) | | Case: NA.
|
testNN | void testNN()(Code) | | Case: NN.
|
testNNsN | void testNNsN()(Code) | | Case: NNsN.
|
testN_N | void testN_N()(Code) | | Case: N_N.
|
testN_NNs | void testN_NNs()(Code) | | Case: N_NNs.
|
Methods inherited from com.sun.midp.i3test.TestCase | public void assertEquals(Object expected, Object actual)(Code)(Java Doc) public void assertEquals(String message, Object expected, Object actual)(Code)(Java Doc) public void assertEquals(int expected, int actual)(Code)(Java Doc) public void assertEquals(String message, int expected, int actual)(Code)(Java Doc) public void assertFalse(boolean condition)(Code)(Java Doc) public void assertFalse(String message, boolean condition)(Code)(Java Doc) public void assertNotNull(Object object)(Code)(Java Doc) public void assertNotNull(String message, Object object)(Code)(Java Doc) public void assertNotSame(Object expected, Object actual)(Code)(Java Doc) public void assertNotSame(String message, Object expected, Object actual)(Code)(Java Doc) public void assertNull(Object object)(Code)(Java Doc) public void assertNull(String message, Object object)(Code)(Java Doc) public void assertSame(Object expected, Object actual)(Code)(Java Doc) public void assertSame(String message, Object expected, Object actual)(Code)(Java Doc) public void assertTrue(String message, boolean condition)(Code)(Java Doc) public void assertTrue(boolean condition)(Code)(Java Doc) public void declare(String testName)(Code)(Java Doc) public void fail()(Code)(Java Doc) public void fail(String message)(Code)(Java Doc) protected SecurityToken getSecurityToken()(Code)(Java Doc) protected boolean getVerbose()(Code)(Java Doc) public void info(String s)(Code)(Java Doc) abstract public void runTests() throws Throwable(Code)(Java Doc)
|
|
|