|
|
|
|
Re: Browse For Folder dialog [message #490267 is a reply to message #34996] |
Thu, 08 October 2009 07:12 |
Eclipse User |
|
|
|
Ketan Padegaonkar schrieb:
> I suppose you just need the FolderDialog to 'return' a specific value:
>
> class FolderDialog{
>
> FolderDialog(Shell parent, int flags){
> this.shell = shell;
> this.flags = flags;
> }
>
> // return a 'special' value in test mode.
> String open(){
> if (System.getProperty('isTest').equals('true'))
> return System.getProperty('folderDialogValue');
> else
> return new org.eclipse...FolderDialog(shell, flags).open()
> }
> }
>
> This folder dialog is now a drop in replacement for swt's folder dialog.
> To drive this from the swtbot tests:
>
> @BeforeClass
> public void beforeClass(){
> System.setProperty('isTest');
> }
> ..
>
> @Test
> public void test(){
> System.setProperty('folderDialogValue', '/path/to/my/folder');
> bot.button('browse').click(); // the mock dialog will now return the
> folder above :)
> }
>
> -- Ketan
>
>
> Derek wrote:
>
>> I'm still fairly new to SWTBot, but so far it's been quite fun working
>> with it.
>> I'm having trouble with the Browse For Folder dialog.
>> It's found at:
>> Window->Preferences->Plug-in Development->Target Platform->Browse...
>
>> Below is part of the code I use to get to said dialog:
>
>> bot.menu("Window").menu("Preferences").click();
>> SWTBotTree preferencesSelectionTree = bot.tree();
>> preferencesSelectionTree.expandNode("Plug-in
>> Development").select("Target Platform");
>> bot.button("Browse...").click();
>> // Having trouble with below line
>> bot.textWithLabel("Folder:").setText("");
>
>
>> I tried using SpyView for this dialog but it doesn't spy it (I'm
>> guessing since it's a system dialog?)
>
>> Does anyone know the best way to find out how to focus on the Folder:
>> text field?
>
>
>
>> Much Appreciated,
>
>> Derek
>
I think its unnecessary to test the native dialogs, they just return
some value that I know before my test case runs. So one can use this
value to call text.setText("") directly and if you have some actions
which have to be performed after setting the text, just use the
ModifyListener on your Text widget.
hope it helps
|
|
|
Powered by
FUDForum. Page generated in 0.04108 seconds