UISpec4J Capturing modal dialog, before the trigger finish

本小妞迷上赌 提交于 2019-12-24 12:35:13

问题


I have some code where I'm showing up a dialog with two textboxes and two buttons (as OK, and Cancel, typical login window). The execution of the main code after the ".setVisible(true)" is conditioned to the values entered on that modal window.

The problem that I'm facing now is that if I do something like this:

        WindowInterceptor.init(new Trigger() {
            @Override
            public void run() throws Exception {
                LoginModal loginWin=new LoginModal();
                loginWin.setVisible(true);
                if(loginWin.getPassword().equals("any")) {
                    System.out.println("password OK!");
                }
            }
        }).process(new WindowHandler() {
            @Override
            public Trigger process(Window window) {
                System.out.println("triggered!");
            }
        }).run();

Then, the password would never be ok, because the handler is not called until the trigger is not finished. I'd expect it to get called when I call the setVisible(true), because otherwise, I can't run my "trigger" based on something entered by the window handler.

What is the correct approach to test this?

Thanks!


回答1:


This seems to be a problem with UISpec4J and Java 1.6u38, with 1.6u37 it works fine.

For example, with this simple code:

    WindowInterceptor.init(new Trigger() {

        @Override
        public void run() throws Exception {
            String myValue=JOptionPane.showInputDialog("thisssss");
            System.out.println("value " + myValue);
        }
    }).process(new WindowHandler() {
        @Override
        public Trigger process(Window window) {
            System.out.println("tal tal");
            return null
        }
    }).run();

myValue is always null, and my handler never triggered. Again, in 1.6u37 it works fine.



来源:https://stackoverflow.com/questions/15788000/uispec4j-capturing-modal-dialog-before-the-trigger-finish

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