abbot包的问题

sunner008 2011-09-20 08:25:40
tester.actionMouseMove(view,new ComponentLocation(new Point(425,175)));
tester.actionMouseRelease();
这两个方式actionMouseMove,actionMouseRelease存在错误,但是abbot包已经安装完毕,这是为什么呢?请求高手求助
错误信息
The method actionMouseMove(GuiView, ComponentLocation) is undefined for the type ComponentTester
The method actionMouseRelease() is undefined for the type ComponentTester
...全文
85 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
小笨熊 2011-09-21
  • 打赏
  • 举报
回复
我也不知道了,希望有人可以帮你看看。
sunner008 2011-09-21
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 sunner008 的回复:]

引用 9 楼 yangting_lisa 的回复:

我看了一个ComponentTester 的源码,两个方法都是public的,所以可以使用的,但是你说你不可以用。。。是不是你的abbot的包不完整?或者你是否重写了这些方法?或者就是你自己也定了一个ComponentTester类,覆盖了父类的方法。。。

我换了几个版本的abbot但是还是用不了,不知道为何?
[/Quote]
除了actionMouseMove和actionMouseRelease其他的类都有,不知道是为何?
sunner008 2011-09-21
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 yangting_lisa 的回复:]

我看了一个ComponentTester 的源码,两个方法都是public的,所以可以使用的,但是你说你不可以用。。。是不是你的abbot的包不完整?或者你是否重写了这些方法?或者就是你自己也定了一个ComponentTester类,覆盖了父类的方法。。。
[/Quote]
我换了几个版本的abbot但是还是用不了,不知道为何?
小笨熊 2011-09-21
  • 打赏
  • 举报
回复
我看了一个ComponentTester 的源码,两个方法都是public的,所以可以使用的,但是你说你不可以用。。。是不是你的abbot的包不完整?或者你是否重写了这些方法?或者就是你自己也定了一个ComponentTester类,覆盖了父类的方法。。。
小笨熊 2011-09-21
  • 打赏
  • 举报
回复
actionMouseRelease():
Release any currently held mouse buttons.

我很久不搞在这个东西了,actionMouseMove我看API好像是ButtonTester才有。。。对你的case我没有怎么看懂,testOperationOfClickAndDragSelection方法中tester.actionDrag(view, new ComponentLocation(new Point(105,105)));
你的作用是点击鼠标移动,还是什么?
sunner008 2011-09-21
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 yangting_lisa 的回复:]

给你一个网址,写的不错,你自己看看,应该可以解决你的问题http://bbs.chinaunix.net/viewthread.php?tid=1569110
[/Quote]
不好意思您给我的网页我没太看明白。
sunner008 2011-09-21
  • 打赏
  • 举报
回复
package pipe.test;

import java.awt.Component;
import java.awt.Point;
import java.io.File;
import java.util.Arrays;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JToggleButton;
import junit.extensions.abbot.ComponentTestFixture;
import pipe.common.dataLayer.PlaceTransitionObject;
import pipe.gui.CreateGui;
import pipe.gui.GuiFrame;
import pipe.gui.GuiView;
import abbot.finder.Matcher;
import abbot.tester.ComponentLocation;
import abbot.tester.ComponentTester;




public class GuiViewTest extends ComponentTestFixture {

private ComponentTester tester;
private GuiView view;
private String testFileString = "src/pipe/test/resources/ClassicGSPN.xml";
private File file = new File(testFileString);
public GuiViewTest(String name) {
super(name);
}

protected void setUp() throws Exception {
super.setUp();
tester = new ComponentTester();
CreateGui.init();
GuiFrame frame = CreateGui.getApp();
frame.createNewTab(file, false);
view = CreateGui.getView();
frame.setVisible(true);
}

protected void tearDown() throws Exception {
super.tearDown();
tester = null;
CreateGui.getApp().dispose();
int lastIndex = CreateGui.getFreeSpace();
while(lastIndex >= 0){
CreateGui.removeTab(0); //deletes static ref to net objects
lastIndex--; //kept by CreateGui
}
}

public void testOperationOfClickAndDragSelection() throws Exception {
Component button1 = getFinder().find(new Matcher(){
public boolean matches(Component c){
return JToggleButton.class.isInstance(c)
&& ((JToggleButton)c).getAction().getValue(Action.NAME)
.equals("Place");
}
});
Component button2 = getFinder().find(new Matcher(){
public boolean matches(Component c){
return JToggleButton.class.isInstance(c)
&& ((JToggleButton)c).getAction().getValue(Action.NAME)
.equals("Select");
}
});
tester.actionClick(button1);
tester.actionClick(button2);
tester.actionDrag(view, new ComponentLocation(new Point(105,105)));
tester.actionMouseMove(view,new ComponentLocation(new Point(425,175)));
tester.actionMouseRelease();

assertEquals("Expected number of objects not selected",3,
view.getSelectionObject().getSelectionCount());
}

public void testPositionOfComponentsAfterZoom() throws Exception {
Component[] components = view.getComponents();
int[][] expectedLocations = getComponentLocations(components);
for (int i = 0; i < components.length; i++){
expectedLocations[i][0] = (int)(expectedLocations[i][0] * 70 / 100.0);
expectedLocations[i][1] = (int)(expectedLocations[i][1] * 70 / 100.0);
}
Component button = getFinder().find(new Matcher(){
public boolean matches(Component c){
return JButton.class.isInstance(c)
&& ((JButton)c).getAction().getValue(Action.NAME)
.equals("Zoom out");
}
});
tester.actionClick(button);
tester.actionClick(button);
tester.actionClick(button);
components = view.getComponents();
int[][] actualLocations = getComponentLocations(components);
assertTrue(locationsMatch(actualLocations, expectedLocations));
}

private boolean locationsMatch(int[][] first, int[][] second) {
boolean match = true;
for (int i = 0; i < first.length; i++){
if (!Arrays.equals(first[i],second[i])){
match = false;
}
}
return match;
}

private int[][] getComponentLocations(Component[] components) {
int[][] locations = new int[components.length][2];
for (int i = 0; i < components.length; i++){
if (components[i] instanceof PlaceTransitionObject){
locations[i][0] = (int)(
(PlaceTransitionObject)components[i]).getPositionX();
locations[i][1] = (int)(
(PlaceTransitionObject)components[i]).getPositionY();
}
}
return locations;
}
}

这个是部分代码,在上面我说的地方出现了问题,而且在用tester.的时候tester的函数库里并没有actionMouseMove和actionMouseRelease,只有MouseMove和MouseRelease,太奇怪的问题了。请求高手帮助。
小笨熊 2011-09-21
  • 打赏
  • 举报
回复
给你一个网址,写的不错,你自己看看,应该可以解决你的问题http://bbs.chinaunix.net/viewthread.php?tid=1569110
小笨熊 2011-09-21
  • 打赏
  • 举报
回复
把你的代码贴出来。。。你的tester是怎么来得new还是mock?
sunner008 2011-09-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 yangting_lisa 的回复:]

import abbot.tester.ComponentTester;
[/Quote]
包正确导入了,在import abbot.tester.ComponentTester;这行没有任何问题。
但是在下面用的时候
tester.actionMouseMove(view,new ComponentLocation(new Point(425,175)));
tester.actionMouseRelease();
就出现问题了。
小笨熊 2011-09-21
  • 打赏
  • 举报
回复
import abbot.tester.ComponentTester;
小笨熊 2011-09-21
  • 打赏
  • 举报
回复
你把包导入正确了吗?
hanshuai888 2011-09-21
  • 打赏
  • 举报
回复
http://www.docjar.com/在这个网站下载。

58,454

社区成员

发帖
与我相关
我的任务
社区描述
Java Eclipse
社区管理员
  • Eclipse
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧