JUnit testing: strange problem with TableViewer [message #465428] |
Thu, 29 March 2007 12:48 |
Sebastien Pennec Messages: 31 Registered: July 2009 |
Member |
|
|
Hello,
I am testing my plugin, and have created a test-plugin for that purpose.
In a test, I am sending data to one of my plugin's components, and that component
displays this data in a virtual table.
To assert the fact that my TableViewer actually shows the data, I try to get the
TableItem objects that are in the viewer.
My code is:
TableViewer viewer = (TableViewer) my_view.getViewer();
TableItem[] items = viewer.getTable().getItems();
When I run this code, the items variable is always an empty array, although I have
seen with my own eyes that the data was displayed in the view.
Also, in Eclipse, when I debug in that code and want to check the content of the
array, I see this:
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has
not been loaded occurred while retrieving component type of array.
Could anybody help me?
Thanks a lot!
Sébastien
|
|
|
Re: JUnit testing: strange problem with TableViewer [message #465431 is a reply to message #465428] |
Thu, 29 March 2007 13:00 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Well I have seen strange things with Virtual-Viewers if the viewer is
not visible because drawing is delayed in this case. E.g. you can make
the JFace-Test-Suite fail some of the virtual-tests if you send the
windows in the background. The last tests i have written ensured 2 things:
1. Making sure that the shell containing the Table/Tree is on top can be
achieved using the SWT.ON_TOP-style e.g. in Junit-Tests
2. Calling viewer.update() to make sure all remaining GUI tasks are
executed.
Tom
Sebastien Pennec schrieb:
> Hello,
>
> I am testing my plugin, and have created a test-plugin for that purpose.
>
> In a test, I am sending data to one of my plugin's components, and that
> component displays this data in a virtual table.
>
> To assert the fact that my TableViewer actually shows the data, I try to
> get the TableItem objects that are in the viewer.
>
> My code is:
>
> TableViewer viewer = (TableViewer) my_view.getViewer();
> TableItem[] items = viewer.getTable().getItems();
>
> When I run this code, the items variable is always an empty array,
> although I have seen with my own eyes that the data was displayed in the
> view.
>
> Also, in Eclipse, when I debug in that code and want to check the
> content of the array, I see this:
>
> org.eclipse.debug.core.DebugException:
> com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred
> while retrieving component type of array.
>
> Could anybody help me?
>
> Thanks a lot!
>
> Sébastien
--
B e s t S o l u t i o n . a t EDV Systemhaus GmbH
----------------------------------------------------
tom schindl Eclipse JFace Committer
|
|
|
Re: JUnit testing: strange problem with TableViewer [message #465436 is a reply to message #465431] |
Thu, 29 March 2007 14:30 |
Sebastien Pennec Messages: 31 Registered: July 2009 |
Member |
|
|
Hello Tom,
Thanks for your answer :)
Well, I've solve the problem in a way that is a bit magical to me.
Doing this:
TableViewer viewer = (TableViewer) my_view.getViewer();
TableItem[] items = viewer.getTable().getItems();
Leads to an empty array of items. I just couldn't get, for example, the text
that the last TableItem object was displaying.
I tried this:
String lastItemText = view.getLastItemText();
with the getLastItemText() method that does:
if (viewer.getTable().getItemCount() == 0) {
return null;
}
TableItem item = viewer.getTable().getItem((viewer.getTable().getItemCount()- 1));
return item.getText();
And, believe it or not, it worked. If I try to get the objects and extract the
information I need, it does not work, and if I ask the view to get that information
for me, it works.
Do you have any explanation?
Of course, I'm happy that it works, but I'd like to understand better what was
wrong... or what is still wrong...
Sébastien
Tom Schindl wrote:
> Well I have seen strange things with Virtual-Viewers if the viewer is
> not visible because drawing is delayed in this case. E.g. you can make
> the JFace-Test-Suite fail some of the virtual-tests if you send the
> windows in the background. The last tests i have written ensured 2 things:
>
> 1. Making sure that the shell containing the Table/Tree is on top can be
> achieved using the SWT.ON_TOP-style e.g. in Junit-Tests
> 2. Calling viewer.update() to make sure all remaining GUI tasks are
> executed.
>
> Tom
>
> Sebastien Pennec schrieb:
>> Hello,
>>
>> I am testing my plugin, and have created a test-plugin for that purpose.
>>
>> In a test, I am sending data to one of my plugin's components, and that
>> component displays this data in a virtual table.
>>
>> To assert the fact that my TableViewer actually shows the data, I try to
>> get the TableItem objects that are in the viewer.
>>
>> My code is:
>>
>> TableViewer viewer = (TableViewer) my_view.getViewer();
>> TableItem[] items = viewer.getTable().getItems();
>>
>> When I run this code, the items variable is always an empty array,
>> although I have seen with my own eyes that the data was displayed in the
>> view.
>>
>> Also, in Eclipse, when I debug in that code and want to check the
>> content of the array, I see this:
>>
>> org.eclipse.debug.core.DebugException:
>> com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred
>> while retrieving component type of array.
>>
>> Could anybody help me?
>>
>> Thanks a lot!
>>
>> Sébastien
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.04064 seconds