simpleinteractivetest.java.svn-base
来自「cqME :java framework for TCK test.」· SVN-BASE 代码 · 共 116 行
SVN-BASE
116 行
/*
* $Id$
*
* Copyright 1996-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 only, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License version 2 for more details (a copy is
* included at /legal/license.txt).
*
* You should have received a copy of the GNU General Public License
* version 2 along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 or visit www.sun.com if you need additional
* information or have any questions.
*
*/
package example;
import java.io.IOException;
import com.sun.tck.cldc.lib.Status;
import com.sun.tck.midp.lib.MidDistribInteractiveTest;
import javax.microedition.lcdui.Alert;
/**
* @test
* @id Test1
* @keywords positive runtime distributed interactive
* @executeClass example.SimpleInteractiveTest
* @executeArgs -msgSwitch $testMsgSwitch
* @source SimpleInteractiveTest.java
* @remoteSource server/InteractiveServer.java
* @remote networkAgent: example.server.InteractiveServer -msgSwitch $testMsgSwitch -TestDirURL $testURL
* @title Simple interactive example
*/
public class SimpleInteractiveTest extends MidDistribInteractiveTest {
private static final String INTERACTIVE_TEST_NAME
= "SimpleInteractiveTest";
private static final String INTERACTIVE_SERVER
= "InteractiveServer";
private String testCaseID;
public SimpleInteractiveTest() {
super(INTERACTIVE_TEST_NAME);
}
protected void runTestCases() {
if (isSelected("test1()")) {
addStatus(test1());
}
}
public Status test1() {
testCaseID = "test1";
try {
send(INTERACTIVE_SERVER, new String[] {"runTestCase", testCaseID});
} catch (IOException e) {
handleException("Cannot send runTestCase request", e);
return Status.failed("failed: " + e);
}
String instruction = "Please follow instructions in the main window.";
addInfo(instruction);
setFormTitle("SimplteInteractiveTest");
return Status.passed(""); // will be ignored
}
protected void handleMessage(String from, String[] args, byte[] data) {
if ("test1".equals(args[0])) {
handle_test1(from, args);
} else if ("done".equals(args[0])) {
handle_done(from, args);
} else if ("endRun".equals(args[0])) {
messageReceived();
} else if ("runTestCase".equals(args[0])) {
messageReceived();
} else {
handleUnknownMessage(from, args);
}
}
public void handle_test1(String from, String[] args) {
Alert testAlert = new Alert("Hello test");
testAlert.setTimeout(5000);
display.setCurrent(testAlert);
synchronized (this) {
while (!testAlert.isShown()) {
try {
wait(100);
} catch (InterruptedException ie) {
}
}
}
testAlert.setString("Hello test.");
try {
send(INTERACTIVE_SERVER, new String[] {"test1", "done"});
} catch (IOException e) {
handleException("Cannot send \"test1 done\" notification", e);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?