【发布时间】:2013-06-10 15:24:56
【问题描述】:
我不知道如何解释。但我会尝试.. Fest 在使用 swingx 的 JXTreeTable 时会减速爬行。它最初并没有减速。它在一段时间内可以正常工作,但在重复相同的操作后,它会严重减慢速度。
我在 github 中为此提出了一个错误。请告诉我这是否是我做错的事情。当我尝试创建 SSCCE 时,我无法重现该问题。
不管怎样,这是一段慢下来的视频。
http://screencast.com/t/liNttCw2In0w
在 0.39 秒到 0.40 秒之间执行一组操作。这些是在 JXTreeTable 中有一行时完成的。
在时间 0.49 到记录结束时重复相同的操作,但现在表格中有 3 行,鼠标单击需要很长时间。
我附上了一张在 fest 变慢时截取的屏幕截图,试图对此进行更多解释
这是完成工作的代码:
步骤1)从树中选择一个节点如下:
JTreeFixture folioTreeFixture = importShareholders.panel("treePanel").tree("folioTree");
folioTreeFixture.separator("~");
folioTreeFixture.selectPath(new StringWrapper("Shareholders", true)+"~"+
(ShareType.isEquity(shareType) ? new StringWrapper("Equity Folios", true) : new StringWrapper("Preference Folios", true))+"~"+
new FolioTreeRep(folio.getName(),folioNo, shareType).toString());
步骤 2) 从 JXTreeTable 中搜索并选择一行
int selectRow=-1;
JTableFixture table=importShareholders.table("historyTable");
for(int i=0;i<table.rowCount();i++){
String certificateNumber = table.cell(TableCell.row(i).column(ShareholderHistoryTable.columnIndex(ShareholderHistoryTable.CERT_NO))).value();
String remarks=table.cell(TableCell.row(i).column(ShareholderHistoryTable.columnIndex(ShareholderHistoryTable.REMARKS))).value();
if(StringUtils.isEmpty(remarks) && StringUtils.isNotEmpty(certificateNumber) && Integer.parseInt(certificateNumber)==certNo){
selectRow=i;
break;
}
}
if(selectRow==-1){
fail("Couldn't find certificate number to transfer");
}
步骤 3) 显示弹出菜单并单击该行
table.showPopupMenuAt(TableCell.row(selectRow).column(0)).menuItem("btnTransfer").click();
我不确定它为什么会变慢。如果有更多信息可以提供帮助,请告诉我。将不胜感激解决问题的一些帮助
我已对应用程序进行了概要分析,但没有发现任何不愉快的事情发生。我没有很多分析应用程序的经验。如果有人可以再看看这个,我将不胜感激。我使用 yourkit 对其进行了分析,并在此处上传了快照转储:
任何帮助将不胜感激..
编辑:
我想我忘了提到手动操作时同样的事情。它只会随着节日而减慢。这让我相信 fest 可能存在问题?
对此感到抱歉。
编辑 2: 根据 Marcin 的要求(抱歉,Marcin 耽搁了).. 这是第一行拆分时的代码
public List<Integer> splitRowEqually(ShareType shareType, String date, int folioNo, int certNo, int... certnos) throws NoSuchFieldException, TorqueException {
//select a tree node
selectFolioInTree(shareType, folioNo);
Pause.pause(new Condition("Wait until tab is created") {
@Override
public boolean test() {
return importShareholders.tabbedPane().tabTitles().length>0;
}
});
//select a row on the table to split
int row=selectRowWithCertNunber(certNo);
List<Integer> rowsIndexes=new ArrayList<Integer>();
JTableFixture table = importShareholders.table();
//show popup menu on that row and select split
table.showPopupMenuAt(row(row).column(columnIndex(TRANS_TYPE))).menuItem("btnSplit").click();
DialogFixture splitDialog=FinderUtilities.getDialogWithTitle("Split Share Certificate");
splitDialog.textBox("tfDateOfSplit").setText(date);
int noOfShares= Integer.parseInt(table.cell(row(row).column(columnIndex(NO_OF_SHARES))).value());
int distFrom= Integer.parseInt(table.cell(row(row).column(columnIndex(DIST_NO_FROM))).value());
int distTo= Integer.parseInt(table.cell(row(row).column(columnIndex(DIST_NO_TO))).value());
//split the row into the number of times decided by the certnos array
int noOfSharesInEachSplit=noOfShares/certnos.length;
for(int i=0;i<certnos.length;i++){
int distToInSplit = distFrom + noOfSharesInEachSplit-1;
enterSplitRowDetails(splitDialog, certnos[i], distFrom, distToInSplit<=distTo ? distToInSplit : distTo);
distFrom=distToInSplit+1;
rowsIndexes.add(row++);
}
splitDialog.button("btnSplit").click();
return rowsIndexes;
}
//selects a node from the left hand side tree
public void selectFolioInTree(final ShareType shareType,final int folioNo) throws TorqueException {
JTreeFixture folioTreeFixture = importShareholders.panel("treePanel").tree("folioTree");
folioTreeFixture.separator("~");
// I use these wrapper classes - StringWrapper and FolioTreeRep, so that I can get a html
// string for the tree node like <html><b>Shareholder</b></html>
String treePath = new StringWrapper("Shareholders", true) + "~" +
(ShareType.isEquity(shareType) ? new StringWrapper("Equity Folios", true) : new StringWrapper("Preference Folios", true)) + "~" +
new FolioTreeRep(mapOfFolioNames.get(folioNo), folioNo, shareType).toString();
folioTreeFixture.clickPath(treePath);
}
//search the table for a row that contains the cert no provided in the Certificate Number column.
private int selectRowWithCertNunber(int certNo) throws NoSuchFieldException {
int selectRow=-1;
JTableFixture table=importShareholders.table("historyTable");
for(int i=0;i<table.rowCount();i++){
String certificateNumber = table.cell(row(i).column(columnIndex(CERT_NO))).value();
String remarks=table.cell(row(i).column(columnIndex(REMARKS))).value();
if(StringUtils.isEmpty(remarks) && StringUtils.isNotEmpty(certificateNumber)
&& Integer.parseInt(certificateNumber)==certNo){
selectRow=i;
break;
}
}
if(selectRow==-1){
fail("Couldn't find certificate number to transfer");
}
return selectRow;
}
// enter details on the table in the SplitDialog
private void enterSplitRowDetails(DialogFixture splitDialog, int cert, int distFrom, int distTo) {
splitDialog.button("btnAdd").click();
int row = splitDialog.table().rowCount();
splitDialog.table().enterValue(row(row - 1).column(0), String.valueOf(cert));
splitDialog.table().enterValue(row(row - 1).column(1), String.valueOf(distFrom));
splitDialog.table().enterValue(row(row - 1).column(2), String.valueOf(distTo));
}
【问题讨论】:
-
FEST 可能会放大您的应用程序中的潜在问题; profile 确定。
-
除了不断尝试寻找原因之外别无他法......切换到另一个测试框架根本没有帮助(即使它看起来可能会意外工作;-)在你的鞋子里,我会从两端尝试:替换整个应用程序中的部分(用普通的 J/X/Tree、JXTable 等替换树表)并尝试使用 SSCCE 来测试较小部分的交互。
-
感谢克娄巴特拉。我已经编辑了这个问题。这只能通过节日发生。当我手动进行测试时不会发生这种情况。
-
手动?你能提供更多细节吗?
-
我有一个类似的问题 - 第一个测试运行正常,但下一个测试在 gui 事件之间运行时有中断(超过 10 秒)。看起来测试 gui 事件正在等待某些东西(并发问题?)我也从 jdk 1.6 迁移到 1.7。
标签: java swing swingx fest jxtreetable