No recording of actions in a FileDialog

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

No recording of actions in a FileDialog

Postby f.ziesel » Sun Sep 09, 2007 11:25 pm

Hello everyone,

I have opened a org.eclipse.swt.widgets.FileDialog in my RCP application when recording. But the actions inside the dialog doesn´t occur in the test case. What can I do to make them run?

Felix

PS1: Oh, by the way I´m using the latest stable build (2007.08.29)
PS2: The dialog language is german
f.ziesel
 
Posts: 4
Joined: Wed Sep 05, 2007 2:48 am

Postby Mac » Mon Sep 10, 2007 4:23 am

Maybe the Dialog is a native Windows Dialog.
I do not know what the Eclipse FileDialog calls....

If it is it will not work with WindowTester, as it is a Platform dependant feature. The only chance you would have is to work around it or create your own FileDialog.
Mac
 
Posts: 14
Joined: Thu Apr 05, 2007 4:19 am

Postby keertip » Mon Sep 10, 2007 3:32 pm

Yes, the FileDialog is platform dependent on relies on native code. SWT does not provide the right kind of access for us to support native interactions. So there is no support for the FileDialog in WindowTester.

As Mac suggested, a workaround would be to create your own FileDialog.
keertip
Moderator
 
Posts: 221
Joined: Thu Mar 15, 2007 10:26 am

Postby f.ziesel » Wed Sep 12, 2007 1:05 am

Another workaround could be:

ui.enterText("C:/.../.../filel");
ui.keyClick(WT.TAB);
ui.keyClick(WT.TAB);
ui.keyClick(WT.CR);


In this case I have another problem:
The backslahes cannot be written, even if I use:

new abbot.tester.ComponentTester().actionKeyString("C:/.../.../filel");


Do you know a workaround to get backslashes for german keyboards?
f.ziesel
 
Posts: 4
Joined: Wed Sep 05, 2007 2:48 am

Postby Mac » Thu Sep 13, 2007 12:58 am

Hi,

we had the same problem with several special Characters.
We worked around it with a mapping and keyClicks.

This function will work with German Keyboard layout. if you use another one you will have to fix the mappings yourself.

bye,

Mac

===========================================

Code: Select all
/**
     * Builds the List for characters that will be entered with the shift key down as e.g. / isnt entered
     * correctly by the IUIContext so shift+7 has to be pressed
     *
     * List of Characters that cannot be produced yet:
     * |
     * ~
     */
    private static void buildExceptionList() {
       //charcters that can be ctreated using the shift mask
        if (f_ShiftCharacters == null) {
            f_ShiftCharacters = new HashMap<Character, Character>();
            f_ShiftCharacters.put(new Character('°'), new Character('^'));
            f_ShiftCharacters.put(new Character('!'), new Character('1'));
            f_ShiftCharacters.put(new Character('"'), new Character('2'));
            f_ShiftCharacters.put(new Character('§'), new Character('3'));
            f_ShiftCharacters.put(new Character('$'), new Character('4'));
            f_ShiftCharacters.put(new Character('%'), new Character('5'));
            f_ShiftCharacters.put(new Character('&'), new Character('6'));
            f_ShiftCharacters.put(new Character('/'), new Character('7'));
            f_ShiftCharacters.put(new Character('('), new Character('8'));
            f_ShiftCharacters.put(new Character(')'), new Character('9'));
            f_ShiftCharacters.put(new Character('='), new Character('0'));
            f_ShiftCharacters.put(new Character('?'), new Character('ß'));
            f_ShiftCharacters.put(new Character('`'), new Character('´'));
            f_ShiftCharacters.put(new Character('>'), new Character('<'));
            f_ShiftCharacters.put(new Character(';'), new Character(','));
            f_ShiftCharacters.put(new Character(':'), new Character('.'));
            f_ShiftCharacters.put(new Character('_'), new Character('-'));
            f_ShiftCharacters.put(new Character('*'), new Character('+'));
            f_ShiftCharacters.put(new Character('\''), new Character('#'));
        }
        //Characters that can be created using the alt key mask
        if (f_altCharacters == null) {
            f_altCharacters = new HashMap<Character, Character>();
            f_altCharacters.put(new Character('^'), new Character('^'));
        }
        //List of Characters that can be created using the abbot Robot to simulate strg+alt (altgr)
        if (f_AltGrCharacters == null) {
            f_AltGrCharacters = new HashMap<Character, Character>();         
            f_AltGrCharacters.put(new Character('['), new Character('8'));
            f_AltGrCharacters.put(new Character(']'), new Character('9'));
            f_AltGrCharacters.put(new Character('{'), new Character('7'));
            f_AltGrCharacters.put(new Character('}'), new Character('0'));
            f_AltGrCharacters.put(new Character('\\'), new Character('ß'));
            f_AltGrCharacters.put(new Character('@'), new Character('q'));
            f_AltGrCharacters.put(new Character('€'), new Character('e'));
            f_AltGrCharacters.put(new Character('²'), new Character('2'));
            f_AltGrCharacters.put(new Character('³'), new Character('3'));
            f_AltGrCharacters.put(new Character('µ'), new Character('m'));
        }
        //List of characters that can be created using the strg+alt key masks
        if (f_AltGrCharacters2 == null) {
            f_AltGrCharacters2 = new HashMap<Character, Character>();
            f_AltGrCharacters2.put(new Character('<'), new Character('<'));           
            f_AltGrCharacters2.put(new Character('+'), new Character('+'));
            f_AltGrCharacters2.put(new Character('#'), new Character('#'));
        }
    }


    /**
     * Enters texts just like ui.enterText(), but uses some special treatments for special characters like
     * §$%&+*~# so they are corretly typed!
     * @param ui
     * @param aTextToParse
     */
    static public void enterTextParsed(IUIContext ui, String aTextToParse) {
        buildExceptionList();
        abbot.swt.Robot abbotRobot = new abbot.swt.Robot();

        for (int i = 0; i < aTextToParse.length(); i++) {
            char c = aTextToParse.charAt(i);
            if (f_ShiftCharacters.containsKey(new Character(c))) {
                // /The character has to be shifted
                ui.keyClick(WT.SHIFT, f_ShiftCharacters.get(new Character(c).charValue()));
            }
            else {
                if (f_altCharacters.containsKey(new Character(c))) {
                    ui.keyClick(WT.ALT, f_altCharacters.get(new Character(c).charValue()));
                }
                else {
                    if (f_AltGrCharacters.containsKey(new Character(c))) {
                       // workaround number 1 for entering characters in combination with AltGr,
                       // as keyClick has a bug using multiple key constants for the modifier mask 
                       abbotRobot.keyPress(SWT.CTRL | SWT.ALT);
                       ui.keyClick(f_AltGrCharacters.get(new Character(c).charValue()));
                       abbotRobot.keyRelease(SWT.CTRL | SWT.ALT);
                       
                    }
                    else {
                       if (f_AltGrCharacters2.containsKey(new Character(c))) {
                          //workaround number 2 for entering characters in combination with AltGr using key masks
                           ui.keyClick(WT.CTRL | WT.ALT, f_AltGrCharacters2.get(new Character(c).charValue()));
                            // those letters get entered like "2+" instead of +, thus we delete the 2 in front
                           ui.keyClick(WT.ARROW_LEFT);
                            ui.keyClick(WT.BS);
                            ui.keyClick(WT.ARROW_RIGHT);                           
                        }
                        else {
                            ui.keyClick(c);
                        }
                    }
                }
            }
        }
    }
Mac
 
Posts: 14
Joined: Thu Apr 05, 2007 4:19 am

Postby f.ziesel » Fri Sep 14, 2007 1:46 am

Thank you very much. Your workaround just works fine.
f.ziesel
 
Posts: 4
Joined: Wed Sep 05, 2007 2:48 am

Re:

Postby eren.aykin » Tue Nov 16, 2010 9:49 am

f.ziesel wrote:Another workaround could be:

ui.enterText("C:/.../.../filel");
ui.keyClick(WT.TAB);
ui.keyClick(WT.TAB);
ui.keyClick(WT.CR);


In this case I have another problem:
The backslahes cannot be written, even if I use:

new abbot.tester.ComponentTester().actionKeyString("C:/.../.../filel");


Do you know a workaround to get backslashes for german keyboards?


Thanks for the workaround, it worked for me. I used double backslashes (i.e. ui.enterText("C:\\...\\...\\filel"); )
eren.aykin
 
Posts: 3
Joined: Thu Sep 09, 2010 6:45 am

Re: No recording of actions in a FileDialog

Postby Phil Quitslund » Fri Nov 19, 2010 9:30 am

Good deal. Glad that worked!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest