Methods Summary |
---|
public void | midletAdded(MIDletProxy midlet)Called when a MIDlet is added to the list.
if (DUMMY_MIDLET1_CLASS_NAME.equals(midlet.getClassName())) {
synchronized (this) {
midlet1 = midlet;
notifyAll();
}
return;
}
if (DUMMY_MIDLET2_CLASS_NAME.equals(midlet.getClassName())) {
synchronized (this) {
midlet2 = midlet;
notifyAll();
}
return;
}
|
public void | midletRemoved(MIDletProxy midlet)Called when a MIDlet is removed from the list.
|
public void | midletStartError(int externalAppId, int suiteId, java.lang.String className, int errorCode, java.lang.String errorDetails)Called when error occurred while starting a MIDlet object.
|
public void | midletUpdated(MIDletProxy midlet, int fieldId)Called when the state of a MIDlet in the list is updated.
MIDletProxy foreground = proxyList.getForegroundMIDlet();
if (midlet1 != null && midlet1 == foreground) {
synchronized (midlet1) {
midlet2InForeground = false;
midlet1InForeground = true;
midlet1.notifyAll();
}
} else if (midlet2 != null && midlet2 == foreground) {
synchronized (midlet2) {
midlet1InForeground = false;
midlet2InForeground = true;
midlet2.notifyAll();
}
} else {
midlet1InForeground = false;
midlet2InForeground = false;
}
|
public void | runTests()
setUp();
try {
test1();
// test2() is obsolete
test3();
test4();
test5();
} finally {
tearDown();
}
|
private void | setUp()
proxyList = MIDletProxyList.getMIDletProxyList();
proxyList.addListener(this);
IndicatorManager.init(proxyList);
|
private void | startMIDlet1()
try {
// Start a new instance of DummyMIDlet1
MIDletSuiteUtils.execute(MIDletSuite.INTERNAL_SUITE_ID,
DUMMY_MIDLET1_CLASS_NAME, "DummyMIDlet1");
// Wait for async request to be processed
synchronized (this) {
if (midlet1 == null) {
// We only wait the full time on a failure
wait(10000);
}
}
assertTrue(DUMMY_MIDLET1_CLASS_NAME + " not started",
midlet1 != null);
} catch (Exception e) {
e.printStackTrace();
}
|
private void | startMIDlet2()
try {
// Start a new instance of DummyMIDlet2
MIDletSuiteUtils.execute(MIDletSuite.INTERNAL_SUITE_ID,
DUMMY_MIDLET2_CLASS_NAME, "DummyMIDlet2");
// Wait for async request to be processed
synchronized (this) {
if (midlet2 == null) {
// We only wait the full time on a failure
wait(10000);
}
}
assertTrue(DUMMY_MIDLET2_CLASS_NAME + " not started",
midlet2 != null);
} catch (Exception e) {
e.printStackTrace();
}
|
private void | tearDown()
proxyList.removeListener(this);
if (midlet1 != null) {
midlet1.destroyMidlet();
}
if (midlet2 != null) {
midlet2.destroyMidlet();
}
|
private void | test1()
declare("One");
// Launch MIDlet 1
startMIDlet1();
// Wait for async request to be processed
// Headless MIDlet also occupy foreground
synchronized (midlet1) {
if (!midlet1InForeground) {
waitForMIDletToGetForeground(midlet1);
}
assertTrue(DUMMY_MIDLET1_CLASS_NAME + " not in foreground",
midlet1InForeground);
}
/*
* Launching a headless MIDlet shouldn't trigger UNS
*/
assertTrue(IndicatorManager.getHomeIconState() == false);
|
private void | test3()
declare("Three");
// Launch MIDlet 2
startMIDlet2();
/*
* MIDlet 2 will automatically get foreground when it requests it
* in startApp and MIDlet 1 will be put in background
*/
// Wait for async request to be processed
synchronized (midlet2) {
if (!midlet2InForeground) {
waitForMIDletToGetForeground(midlet2);
}
assertTrue(DUMMY_MIDLET2_CLASS_NAME + " not in foreground",
midlet2InForeground);
}
// Merely moving MIDlet 1 to background shouldn't trigger home icon
assertTrue(IndicatorManager.getHomeIconState() == false);
|
private void | test4()
declare("Four");
/*
* Force MIDlet 1 in the background to request foreground,
* by getting startApp to be called a third time.
*/
midlet1.pauseMidlet();
// Give pauseApp time to get called before activating
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
// ignore
}
midlet1.activateMidlet();
// No foreground change so just wait 1 sec.
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
// ignore
}
// Home icon should be on upon background display foreground request
assertTrue(IndicatorManager.getHomeIconState() == true);
|
private void | test5()
declare("Five");
// Background Display requests for background
midlet1.pauseMidlet();
// The test manager may get the background so just wait 1 sec.
try {
Thread.sleep(1000);
} catch (InterruptedException ie) {
// ignore
}
// previous home icon request should be cancelled
assertTrue(IndicatorManager.getHomeIconState() == false);
|
private void | waitForMIDletToGetForeground(MIDletProxy midlet)
synchronized (midlet) {
try {
// We only wait the full time on a failure
midlet.wait(10000);
} catch (InterruptedException ie) {
// ignore
}
}
|