Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[swtbot-dev] Button Click Hanging

Hello all,
I'm having an issue on windows (haven't checked any other OS) where I'm having the entire test hang when I try to click on the ok button of a MessageDialog. It works fine if I only find the button. When debugging it, the test was hanging on the button's notify of the Selection listeners. The log at this point is: 16:17:26,562 DEBUG SWTBotButton:158 - Sent event Selection [13]: SelectionEvent{Button {OK} time=-1574371166 data=null item=null detail=0 x=0 y=0 width=0 height=0 stateMask=0 text=null doit=true} to (of type 'Button' and with mnemonic 'OK' and with style 'SWT.PUSH')

I waited about a minute and nothing happened.

Here is the code I have:

TEST:
=======

package errors;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
import org.junit.Before;
import org.junit.Test;

public class ShowAppCodeAndSchemaMismatchErrorGuiTest {

    private SWTBot bot;
    private Display display;
    private Shell shell;

    @Before
    public void setupSWTBot() {
        System.out.println("Starting Test");
        new Thread() {

            public void run() {
                display = new Display();
                shell = new Shell(display);
                new ShowAppCodeAndSchemaMismatchErrorGui(shell).show();
            }
        }.start();
        bot = new SWTBot();
    }

    @Test
    public void testCanClickOk() throws Exception {
        SWTBotButton button = bot.button("OK");
        button.click();
    }
}

=======

Actual Class:

=======
package com.gaic.quoter.view.errors;

import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;

public class ShowAppCodeAndSchemaMismatchErrorGui {

    private MessageDialog box;

    public ShowAppCodeAndSchemaMismatchErrorGui(Shell shell) {
        String message = "Message";
        String title = "Title";
box = new MessageDialog(shell, title, null, message, MessageDialog.ERROR, new String[] { "OK" }, 0);
    }

    public void show() {
        box.open();
    }

}
=======

Am I even testing this right?

I this a bug?

Thanks,
	Mike Gaffney


Back to the top