FEST Swing new frame on click, can't make new frame fixture

拈花ヽ惹草 提交于 2019-12-08 01:56:40

问题


I am trying to write a Fest Swing test but am having trouble making / finding a frame fixture. I have two JFrames, one opens the other on click, and I'd like to either:

1.) find the frame fixture of the new JFrame opened

2.) make a new frame fixture out of the the new JFrame object created (I can get the object from the original JFrame Object.)

I have tried using

    GenericTypeMatcher<secondGUI> matcher = new GenericTypeMatcher<secondGUI>(secondGUI.class) {
        protected boolean isMatching(secondGUI frame) {
            System.out.println("0".equals(frame.getTitle()) && frame.isShowing());
            return "0".equals(frame.getTitle()) && frame.isShowing();
        }
    };
    Robot robot = BasicRobot.robotWithCurrentAwtHierarchy();

to find the frame, but run into an EdtViolationException.

I have also tried

    secondGUI secGUI = GuiActionRunner.execute(new GuiQuery<secondGUI>() {
        @Override
        protected secondGUI executeInEDT() throws Throwable {
            return firstGUI.getController().getWindows().get("0");
        }
    });
    FrameFixture secondWindow = new FrameFixture(secGUI);

But the last line gave an EdtViolationException as well. Any suggestions? Thanks!


回答1:


Try finding your frame using the title of the frame:

Robot robot = BasicRobot.robotWithCurrentAwtHierarchy();
FrameFixture frame = WindowFinder.findFrame("Title of my frame").using(robot);

Also, secondGUI should be SecondGUI since it's a class name.

BTW, glad to see another FEST user.



来源:https://stackoverflow.com/questions/10626357/fest-swing-new-frame-on-click-cant-make-new-frame-fixture

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!