Java源码示例:org.netbeans.jemmy.operators.JTableOperator
示例1
public void testInvokeWindow() {
new Action("Window|Other|Application Actions",null).perform(); // NOI18N
waitAMoment();
// invoke edit dialog for first action in table
JTableOperator tableOp = new JTableOperator(getTopComponent());
tableOp.clickOnCell(1, 1); // select first row in table
// invoke edit dialog
new JButtonOperator(getTopComponent(), "Edit Action").pushNoBlock(); // NOI18N
waitAMoment();
// closing edit dialog
new JButtonOperator(new NbDialogOperator("Edit Action Properties"), "OK").pushNoBlock(); // NOI18N
}
示例2
/**
* Sets line 280 breakpoint, disables it and then continues to run to cursor
* at line 283.
*/
public void runToCursor() {
EditorOperator eo = new EditorOperator("MemoryView.java");
eo.setCaretPositionToLine(280);
new ToggleBreakpointAction().perform();
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(BREAKPOINTS_VIEW));
jTableOperator.waitCell("Line MemoryView.java:280", 1, 0);
new JPopupMenuOperator(jTableOperator.callPopupOnCell(1, 0)).pushMenu("Disable");
MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
stt.start();
eo.makeComponentVisible();
eo.setCaretPositionToLine(283);
new RunToCursorAction().perform();
stt.waitText("Thread main stopped at MemoryView.java:283.");
stt.stop();
assertEquals(new EditorOperator("MemoryView.java").getLineNumber(), 283);
}
示例3
/**
* Tests that it is possible to add watches.
*/
public void newWatch() throws IllegalAccessException, InvocationTargetException, InvalidExpressionException {
Node projectNode = new ProjectsTabOperator().getProjectRootNode(DEBUG_TEST_PROJECT_ANT);
Node testFile = new Node(new SourcePackagesNode(projectNode), "advanced|VariablesTest.java");
new OpenAction().perform(testFile);
EditorOperator eo = new EditorOperator("VariablesTest.java");
eo.setCaretPositionToLine(49);
new ToggleBreakpointAction().perform();
MainWindowOperator.StatusTextTracer stt = MainWindowOperator.getDefault().getStatusTextTracer();
stt.start();
new DebugJavaFileAction().perform(testFile);
stt.waitText("Thread main stopped at VariablesTest.java:49");
stt.stop();
new ActionNoBlock("Debug|New Watch...", null).perform();
NbDialogOperator newWatchDialog = new NbDialogOperator("New Watch");
new JEditorPaneOperator(newWatchDialog, 0).setText("n");
newWatchDialog.ok();
TopComponentOperator variablesView = new TopComponentOperator(new ContainerOperator(MainWindowOperator.getDefault(), VIEW_CHOOSER), "Variables");
JTableOperator variablesTable = new JTableOperator(variablesView);
assertEquals("n", variablesTable.getValueAt(0, 0).toString());
org.openide.nodes.Node.Property property = (org.openide.nodes.Node.Property) variablesTable.getValueAt(0, 2);
assertEquals("50", property.getValue());
JPopupMenuOperator menu = new JPopupMenuOperator(variablesTable.callPopupOnCell(0, 0));
menu.pushMenu("Delete All");
}
示例4
/**
* Evaluates simple expression during debugging session.
*/
public void evaluateExpression() throws IllegalAccessException, InvocationTargetException, InterruptedException, InvalidExpressionException {
TopComponentOperator variablesView = new TopComponentOperator(new ContainerOperator(MainWindowOperator.getDefault(), VIEW_CHOOSER), "Variables");
JToggleButtonOperator showEvaluationResultButton = new JToggleButtonOperator(variablesView, 0);
showEvaluationResultButton.clickMouse();
TopComponentOperator evaluationResultView = new TopComponentOperator("Evaluation Result");
new Action("Debug|Evaluate Expression...", null).perform();
TopComponentOperator expressionEvaluator = new TopComponentOperator("Evaluate Expression");
JEditorPaneOperator expressionEditor = new JEditorPaneOperator(expressionEvaluator);
new EventTool().waitNoEvent(1000);
expressionEditor.setText("\"If n is: \" + n + \", then n + 1 is: \" + (n + 1)");
JPanel buttonsPanel = (JPanel) expressionEvaluator.getComponent(2);
JButton expressionEvaluatorButton = (JButton) buttonsPanel.getComponent(1);
assertEquals("Evaluate code fragment (Ctrl + Enter)", expressionEvaluatorButton.getToolTipText());
expressionEvaluatorButton.doClick();
JTableOperator variablesTable = new JTableOperator(evaluationResultView);
assertValue(variablesTable, 0, 2, "\"If n is: 50, then n + 1 is: 51\"");
assertEquals("\"If n is: \" + n + \", then n + 1 is: \" + (n + 1)", variablesTable.getValueAt(0, 0).toString().trim());
}
示例5
/**
* Tests that table contains required value in cell with given coordinates.
*
* @param table Table to be used for the search.
* @param row Row of the cell.
* @param column Column of the cell.
* @param value Value to be searched for.
*/
private void assertValue(JTableOperator table, int row, int column, String value) throws IllegalAccessException, InvocationTargetException, InvalidExpressionException {
org.openide.nodes.Node.Property property = null;
for (int i = 0; i < 10; i++) {
property = (org.openide.nodes.Node.Property) table.getValueAt(row, column);
if (property != null)
if (!"Evaluating...".equals(property.getValue())) break;
new EventTool().waitNoEvent(1000);
}
assertNotNull(property);
if (property.getValue() instanceof ObjectVariable) {
assertEquals(value, ((ObjectVariable) property.getValue()).getToStringValue());
} else {
assertEquals(value, property.getValue().toString());
}
}
示例6
/**
*
*/
public void testFieldBreakpointCreation() {
//open source
Node beanNode = new Node(new SourcePackagesNode(Utilities.testProjectName), "examples.advanced|MemoryView.java"); //NOI18N
new OpenAction().performAPI(beanNode);
EditorOperator eo = new EditorOperator("MemoryView.java");
try {
eo.clickMouse(50,50,1);
} catch (Throwable t) {
System.err.println(t.getMessage());
}
NbDialogOperator dialog = Utilities.newBreakpoint(36, 36);
setBreakpointType(dialog, "Field");
new JEditorPaneOperator(dialog, 0).setText("examples.advanced.MemoryView");
new JEditorPaneOperator(dialog, 1).setText("msgMemory");
new JComboBoxOperator(dialog, 2).selectItem(Bundle.getString("org.netbeans.modules.debugger.jpda.ui.breakpoints.Bundle", "LBL_Field_Breakpoint_Type_Access"));
dialog.ok();
Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
assertEquals("Field breakpoint was not created.", "Field MemoryView.msgMemory access", jTableOperator.getValueAt(0, 0).toString());
}
示例7
/**
*
*/
public void testThreadBreakpointCreation() {
//open source
Node beanNode = new Node(new SourcePackagesNode(Utilities.testProjectName), "examples.advanced|MemoryView.java"); //NOI18N
new OpenAction().performAPI(beanNode);
EditorOperator eo = new EditorOperator("MemoryView.java");
try {
eo.clickMouse(50,50,1);
} catch (Throwable t) {
System.err.println(t.getMessage());
}
new NewBreakpointAction().perform();
NbDialogOperator dialog = new NbDialogOperator(Utilities.newBreakpointTitle);
setBreakpointType(dialog, "Thread");
dialog.ok();
Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
assertEquals("Thread breakpoint was not created.", "Thread started", jTableOperator.getValueAt(0, 0).toString());
}
示例8
public void testViewsHeapWalker1() {
EditorOperator eo = new EditorOperator("MemoryView.java");
new EventTool().waitNoEvent(500);
Utilities.toggleBreakpoint(eo, 92);
Utilities.startDebugger();
Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
Utilities.showDebuggerView(Utilities.classesViewTitle);
TopComponentOperator tco = new TopComponentOperator(Utilities.classesViewTitle);
JTableOperator jTableOperator = new JTableOperator(tco);
JComboBoxOperator filter = new JComboBoxOperator(tco);
filter.clearText();
filter.enterText("example");
filter.pushKey(KeyEvent.VK_ENTER);
new EventTool().waitNoEvent(500);
assertEquals("MemoryView class is not in classes", "examples.advanced.MemoryView", Utilities.removeTags(jTableOperator.getValueAt(0,0).toString()));
assertEquals("Instances number is wrong", "1 (0%)", Utilities.removeTags(jTableOperator.getValueAt(0,2).toString()));
}
示例9
public void testViewsHeapWalker2() {
EditorOperator eo = new EditorOperator("MemoryView.java");
new EventTool().waitNoEvent(500);
Utilities.toggleBreakpoint(eo, 92);
Utilities.startDebugger();
Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
Utilities.showDebuggerView(Utilities.classesViewTitle);
TopComponentOperator tco = new TopComponentOperator(Utilities.classesViewTitle);
JTableOperator jTableOperator = new JTableOperator(tco);
JComboBoxOperator filter = new JComboBoxOperator(tco);
JPopupMenuOperator popup = new JPopupMenuOperator(jTableOperator.callPopupOnCell(0, 0));
popup.pushMenuNoBlock("Show in Instances View");
filter.clearText();
filter.pushKey(KeyEvent.VK_ENTER);
new EventTool().waitNoEvent(500);
}
示例10
public void testViewsSessions() {
EditorOperator eo = new EditorOperator("MemoryView.java");
new EventTool().waitNoEvent(500);
Utilities.toggleBreakpoint(eo, 92);
Utilities.startDebugger();
Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
Utilities.showDebuggerView(Utilities.sessionsViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.sessionsViewTitle));
assertEquals("examples.advanced.MemoryView", Utilities.removeTags(jTableOperator.getValueAt(0,0).toString()));
try {
org.openide.nodes.Node.Property property = (org.openide.nodes.Node.Property)jTableOperator.getValueAt(0,1);
assertEquals("Stopped", Utilities.removeTags(property.getValue().toString()));
property = (org.openide.nodes.Node.Property)jTableOperator.getValueAt(0,2);
assertEquals("org.netbeans.api.debugger.Session localhost:examples.advanced.MemoryView", Utilities.removeTags(property.getValue().toString()));
} catch (Exception ex) {
ex.printStackTrace();
assertTrue(ex.getClass()+": "+ex.getMessage(), false);
}
}
示例11
public void testViewsSources() {
EditorOperator eo = new EditorOperator("MemoryView.java");
new EventTool().waitNoEvent(500);
Utilities.toggleBreakpoint(eo, 92);
Utilities.startDebugger();
Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
Utilities.showDebuggerView(Utilities.sourcesViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.sourcesViewTitle));
String debugAppSource = "debugTestProject" + java.io.File.separator + "src (Project debugTestProject)";
boolean jdk = false, project = false;
for (int i=0;i < jTableOperator.getRowCount();i++) {
String src = Utilities.removeTags(jTableOperator.getValueAt(i,0).toString());
if (src.endsWith("src.zip")) {
jdk=true;
} else if (src.endsWith(debugAppSource)) {
project = true;
}
}
assertTrue("JDK source root is not shown in threads view", jdk);
assertTrue("MemoryView source root is not shown in threads view", project);
}
示例12
/**
*
*/
public void testMethodBreakpointCreation() {
EditorOperator eo = new EditorOperator("MemoryView.java");
try {
eo.clickMouse(50,50,1);
} catch (Throwable t) {
System.err.println(t.getMessage());
}
NbDialogOperator dialog = Utilities.newBreakpoint(92);
setBreakpointType(dialog, "Method");
new JEditorPaneOperator(dialog, 0).setText("examples.advanced.MemoryView");
new JEditorPaneOperator(dialog, 1).setText("updateStatus()");
dialog.ok();
Utilities.showDebuggerView(Utilities.breakpointsViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.breakpointsViewTitle));
assertEquals("Method MemoryView.updateStatus", jTableOperator.getValueAt(0, 0).toString());
}
示例13
/** Waits for property with given name in specified property sheet.
* @param propSheetOper PropertySheetOperator where to find property.
* @param name property display name
*/
private Node.Property waitProperty(final PropertySheetOperator propSheetOper, final String name) {
try {
Waiter waiter = new Waiter(new Waitable() {
public Object actionProduced(Object param) {
Node.Property property = null;
JTableOperator table = propSheetOper.tblSheet();
for(int row=0;row<table.getRowCount();row++) {
if(table.getValueAt(row, 1) instanceof Node.Property) {
property = (Node.Property)table.getValueAt(row, 1);
if(propSheetOper.getComparator().equals(property.getDisplayName(), name)) {
return property;
}
}
}
return null;
}
public String getDescription() {
return("Wait property "+name);
}
});
return (Node.Property)waiter.waitAction(null);
} catch (InterruptedException e) {
throw new JemmyException("Interrupted.", e);
}
}
示例14
public boolean unassignAlternativeShortcutToAction(String actionName, String shortcutStr) {
System.out.println("[TEST_DEBUG]");
System.out.println("[TEST_DEBUG] ### Unassigning alternative shortcut for " + actionName + " - Started");
String tmpStr = actionSearchByName().getText();
searchActionName(actionName);
JTableOperator tab = actionsTable();
TableModel tm = tab.getModel();
String _str;
System.out.println("[TEST_DEBUG] Found " + tab.getRowCount() + " actions matching action pattern: " + actionName);
for (int i = 0; i < tab.getRowCount(); i++) {
_str = tm.getValueAt(i, 0).toString();
System.out.println("[TEST_DEBUG] Examining action " + _str + ", which is no. " + (i + 1) + "in the table...");
if (_str.toLowerCase().startsWith(actionName.toLowerCase()) && tm.getValueAt(i, 1).toString().toLowerCase().equals(shortcutStr.toLowerCase())) {
System.out.println("[TEST_DEBUG] Action " + actionName + "was found");
JListOperator jli = clickShortcutEllipsisButton(tab, i);
jli.clickOnItem("Clear");
sleep(100);
System.out.println("[TEST_DEBUG] ### Unassigning alternative shortcut for " + actionName + " - OK");
break;
}
}
searchActionName(tmpStr);
return true;
}
示例15
/**
* Calls Make Current popup on given session. It throws TimeoutExpiredException
* if session with given name not found.
*
* @param sessionName display name of session
*/
public void makeCurrent(final String sessionName) {
final JTableOperator table = new JTableOperator(this);
table.waitState(new ComponentChooser() {
@Override
public boolean checkComponent(Component comp) {
for (int i = 0; i < table.getRowCount(); i++) {
String text = table.getValueAt(i, 0).toString();
if (table.getComparator().equals(text, sessionName)) {
table.clickOnCell(i, 0, 2);
return true;
}
}
return false;
}
@Override
public String getDescription() {
return "Session " + sessionName + " in table of sessions";
}
});
}
示例16
@Override
public void editCell(ComponentOperator oper, int row, int column, Object value) {
JTableOperator toper = (JTableOperator) oper;
toper.scrollToCell(row, column);
if (!toper.isEditing()
|| toper.getEditingRow() != row
|| toper.getEditingColumn() != column) {
clickOnCell((JTableOperator) oper, row, column, 2);
}
JTextComponentOperator textoper
= new JTextComponentOperator((JTextComponent) toper.
waitSubComponent(new JTextComponentOperator.JTextComponentFinder()));
TextDriver text = DriverManager.getTextDriver(JTextComponentOperator.class);
text.clearText(textoper);
text.typeText(textoper, value.toString(), 0);
DriverManager.getKeyDriver(oper).
pushKey(textoper, KeyEvent.VK_ENTER, 0,
oper.getTimeouts().
create("ComponentOperator.PushKeyTimeout"));
}
示例17
/**
* Sets line 141 breakpoint and then steps over it.
*/
public void stepOver() {
EditorOperator eo = new EditorOperator("MemoryView.java");
eo.setCaretPositionToLine(141);
new ToggleBreakpointAction().perform();
new ContinueAction().perform();
waitThreadsNode("'AWT-EventQueue-0' at line breakpoint MemoryView.java : 141");
new StepOverAction().perform();
waitThreadsNode("'AWT-EventQueue-0' suspended at 'MemoryView.updateStatus:143'");
JTableOperator breakpoints = new JTableOperator(new TopComponentOperator(BREAKPOINTS_VIEW));
new JPopupMenuOperator(breakpoints.callPopupOnCell(1, 0)).pushMenu("Delete All");
}
示例18
/**
* Steps over expression at line 143.
*/
public void stepOverExpression() throws InterruptedException {
new StepOverExpressionAction().perform();
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(VARIABLES_VIEW));
jTableOperator.waitCell("Before call to '<init>()'", 1, 0);
jTableOperator.waitCell("Arguments", 2, 0);
jTableOperator.selectCell(2, 0);
pressKey(KeyEvent.VK_RIGHT);
Thread.sleep(3000); // Wait 3 seconds. Sometimes expanding Arguments node is slow.
jTableOperator.waitCell("total", 3, 0);
new StepOverExpressionAction().perform();
jTableOperator.waitCell("free", 3, 0);
jTableOperator.waitCell("Return values history", 4, 0);
jTableOperator.waitCell("return <init>()", 5, 0);
new StepOverExpressionAction().perform();
jTableOperator.waitCell("taken", 3, 0);
jTableOperator.waitCell("Return values history", 4, 0);
jTableOperator.waitCell("return <init>()", 5, 0);
jTableOperator.waitCell("return <init>()", 6, 0);
new StepOverExpressionAction().perform();
jTableOperator.waitCell("new Object[]{new Long(total), new Long(free), new Integer(taken)}", 3, 0);
jTableOperator.waitCell("Return values history", 4, 0);
jTableOperator.waitCell("return <init>()", 5, 0);
jTableOperator.waitCell("return <init>()", 6, 0);
jTableOperator.waitCell("return <init>()", 7, 0);
new StepOverExpressionAction().perform();
jTableOperator.waitCell("msgMemory.format(new Object[]{new Long(total), new Long(free), new Integer(taken)})", 3, 0);
jTableOperator.waitCell("Return values history", 4, 0);
jTableOperator.waitCell("return <init>()", 5, 0);
jTableOperator.waitCell("return <init>()", 6, 0);
jTableOperator.waitCell("return <init>()", 7, 0);
jTableOperator.waitCell("return format()", 8, 0);
}
示例19
/**
*
*/
public void testLocalVariablesValues() throws Throwable {
EditorOperator eo = new EditorOperator("MemoryView.java"); //NOI18N
new EventTool().waitNoEvent(500);
Utilities.toggleBreakpoint(eo, 104);
new EventTool().waitNoEvent(500);
Utilities.startDebugger();
Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:104.");
expandNodes();
Utilities.showDebuggerView(Utilities.variablesViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.variablesViewTitle));
try {
org.openide.nodes.Node.Property property;
property = (org.openide.nodes.Node.Property)jTableOperator.getValueAt(25, 2);
long free = Long.parseLong(property.getValue().toString());
property = (org.openide.nodes.Node.Property)jTableOperator.getValueAt(26, 2);
long total = Long.parseLong(property.getValue().toString());
property = (org.openide.nodes.Node.Property)jTableOperator.getValueAt(27, 2);
long taken = Long.parseLong(property.getValue().toString());
assertTrue("Local varaibles values does not seem to be correct (total != free + taken) - "+total+" != "+free+" + "+taken, (total == free + taken));
} catch (java.lang.IllegalAccessException e1) {
assertTrue(e1.getMessage(), false);
} catch (java.lang.reflect.InvocationTargetException e2) {
assertTrue(e2.getMessage(), false);
}
}
示例20
public void testViewsCallStack() {
EditorOperator eo = new EditorOperator("MemoryView.java");
new EventTool().waitNoEvent(500);
Utilities.toggleBreakpoint(eo, 92);
Utilities.startDebugger();
Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
Utilities.showDebuggerView(Utilities.callStackViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.callStackViewTitle));
assertEquals("MemoryView.updateStatus:92", Utilities.removeTags(jTableOperator.getValueAt(0,0).toString()));
assertEquals("MemoryView.updateConsumption:80", Utilities.removeTags(jTableOperator.getValueAt(1,0).toString()));
assertEquals("MemoryView.main:117", Utilities.removeTags(jTableOperator.getValueAt(2,0).toString()));
}
示例21
public void testViewsThreads() {
EditorOperator eo = new EditorOperator("MemoryView.java");
new EventTool().waitNoEvent(500);
Utilities.toggleBreakpoint(eo, 92);
Utilities.startDebugger();
Utilities.checkConsoleLastLineForText("Thread main stopped at MemoryView.java:92");
Utilities.showDebuggerView(Utilities.threadsViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(Utilities.threadsViewTitle));
assertTrue("Thread group system is not shown in threads view", "system".equals(Utilities.removeTags(jTableOperator.getValueAt(0,0).toString())));
assertTrue("Thread group main is not shown in threads view", "main".equals(Utilities.removeTags(jTableOperator.getValueAt(1,0).toString())));
assertTrue("Thread main is not shown in threads view", "main".equals(Utilities.removeTags(jTableOperator.getValueAt(2,0).toString())));
assertTrue("Thread Reference Handler is not shown in threads view", "Reference Handler".equals(Utilities.removeTags(jTableOperator.getValueAt(3,0).toString())));
assertTrue("Thread Finalizer is not shown in threads view", "Finalizer".equals(Utilities.removeTags(jTableOperator.getValueAt(4,0).toString())));
assertTrue("Thread Signal Dispatcher is not shown in threads view", "Signal Dispatcher".equals(Utilities.removeTags(jTableOperator.getValueAt(5,0).toString())));
}
示例22
public static void deleteAllBreakpoints() {
showDebuggerView(breakpointsViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(breakpointsViewTitle));
if (jTableOperator.getRowCount() > 0) {
new JPopupMenuOperator(jTableOperator.callPopupOnCell(0, 0)).pushMenu(Bundle.getString("org.netbeans.modules.debugger.ui.models.Bundle", "CTL_BreakpointAction_DeleteAll_Label"));
}
}
示例23
public static void deleteAllWatches() {
showDebuggerView(watchesViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(watchesViewTitle));
if (jTableOperator.getRowCount() > 0) {
new JPopupMenuOperator(jTableOperator.callPopupOnCell(0, 0)).pushMenu(Bundle.getString("org.netbeans.modules.debugger.ui.models.Bundle", "CTL_WatchAction_DeleteAll"));
}
}
示例24
public static void endAllSessions() {
showDebuggerView(sessionsViewTitle);
JTableOperator jTableOperator = new JTableOperator(new TopComponentOperator(sessionsViewTitle));
if (jTableOperator.getRowCount() > 0) {
new JPopupMenuOperator(jTableOperator.callPopupOnCell(0, 0)).pushMenu(Bundle.getString("org.netbeans.modules.debugger.ui.models.Bundle", "CTL_SessionAction_FinishAll_Label"));
}
}
示例25
public boolean selectTemplate(String abbrev) {
JTableOperator templatesTable1 = getTemplatesTable();
int row = templatesTable1.findCellRow(abbrev, 0, 0);
if(row==-1) return false;
templatesTable1.selectCell(row, 0);
return true;
}
示例26
public List<String[]> dumpTemplatesTable() {
List<String[]> res = new LinkedList<>();
JTableOperator tableOperator = getTemplatesTable();
for (int i = 0; i < tableOperator.getRowCount(); i++) {
String[] items = new String[3];
for (int j = 0; j < 3; j++) {
items[j] = (String) tableOperator.getValueAt(i, j);
}
res.add(items);
}
return res;
}
示例27
protected void selectProjectFromWS(WizardOperator wizz, String workspace, String projectToImport) {
JTextFieldOperator txtWorkspaceLocation = new JTextFieldOperator(wizz, 0);
String workspacePath = getDataDir().getAbsolutePath() + File.separatorChar + workspace;
txtWorkspaceLocation.setText(workspacePath);
wizz.next();
JTableOperator projectsTable = new JTableOperator(wizz);
TableModel model = projectsTable.getModel();
selectProjectByName(model, projectToImport);
}
示例28
public void CheckDownloaded( )
{
startTest( );
// Open
new JMenuBarOperator(MainWindowOperator.getDefault()).pushMenuNoBlock("Tools|Plugins");
JDialogOperator jdPlugins = new JDialogOperator( "Plugins" );
JTabbedPaneOperator jtTabs = new JTabbedPaneOperator( jdPlugins, 0 );
jtTabs.setSelectedIndex( jtTabs.findPage( "Downloaded" ) );
// Check buttons
JButtonOperator jbAdd = new JButtonOperator( jdPlugins, "Add Plugins..." );
JButtonOperator jbInstall = new JButtonOperator( jdPlugins, "Install" );
// Check table
JTableOperator jtTable = new JTableOperator( jdPlugins, 0 );
int iOriginalRows = jtTable.getRowCount( );
// Close by button
JButtonOperator jbClose = new JButtonOperator( jdPlugins, "Close" );
jbClose.push( );
jdPlugins.waitClosed( );
endTest( );
}
示例29
/**
* Test Profiler options.
*/
public void testOptions() {
OptionsOperator options = OptionsOperator.invoke();
options.selectJava();
JTabbedPaneOperator tabbedPane = new JTabbedPaneOperator(options);
tabbedPane.selectPage("Profiler");
JListOperator categoriesOper = new JListOperator(options);
// General category
assertEquals("Wrong profiling port.", 5140, new JSpinnerOperator(options).getValue());
// manage calibration data
new JButtonOperator(options, "Manage").pushNoBlock();
NbDialogOperator manageOper = new NbDialogOperator("Manage Calibration data");
JTableOperator platformsOper = new JTableOperator(manageOper);
platformsOper.selectCell(0, 0);
new JButtonOperator(manageOper, "Calibrate").pushNoBlock();
new NbDialogOperator("Information").ok();
manageOper.closeByButton();
// reset
new JButtonOperator(options, "Reset").push();
// Snapshots category
categoriesOper.selectItem("Snapshots");
JLabelOperator lblSnapshotOper = new JLabelOperator(options, "When taking snapshot:");
assertEquals("Wrong value for " + lblSnapshotOper.getText(), "Open snapshot", new JComboBoxOperator((JComboBox) lblSnapshotOper.getLabelFor()).getSelectedItem());
JLabelOperator lblOpenOper = new JLabelOperator(options, "Open automatically:");
assertEquals("Wrong value for " + lblOpenOper.getText(), "On first saved snapshot", new JComboBoxOperator((JComboBox) lblOpenOper.getLabelFor()).getSelectedItem());
// Engine category
categoriesOper.selectItem("Engine");
JLabelOperator lblSamplingOper = new JLabelOperator(options, "Sampling frequency");
assertEquals("Wrong value for " + lblSamplingOper.getText(), 10, new JSpinnerOperator((JSpinner) lblSamplingOper.getLabelFor()).getValue());
options.cancel();
}
示例30
/** Waits for index-th property in specified property sheet.
* @param propSheetOper PropertySheetOperator where to find property.
* @param index index (row number) of property inside property sheet
* (starts at 0). If there are categories shown in property sheet,
* rows occupied by their names must by added to index.
*/
private Node.Property waitProperty(final PropertySheetOperator propSheetOper, final int index) {
try {
Waiter waiter = new Waiter(new Waitable() {
public Object actionProduced(Object param) {
JTableOperator table = propSheetOper.tblSheet();
if(table.getRowCount() <= index) {
// If table is empty or index out of bounds,
// it returns null to wait until table is populated by values
return null;
}
Object property = table.getValueAt(index, 1);
if(property instanceof Node.Property) {
return (Node.Property)property;
} else {
throw new JemmyException("On row "+index+" in table there is no property");
}
}
public String getDescription() {
return("Wait property on row "+index+" in property sheet.");
}
});
//waiter.setOutput(TestOut.getNullOutput());
return (Node.Property)waiter.waitAction(null);
} catch (InterruptedException e) {
throw new JemmyException("Interrupted.", e);
}
}