google / windowtester

Automatically exported from code.google.com/p/windowtester
Other
18 stars 23 forks source link

FilteredTreeMatcher could not resolve his parent correctly #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use FilteredTreeItemLocator with a parent
2. Add some element between TreeItem and FilteredTree 

This is our structure in the program which results in not finding the widget:

SomeView$6 {}<HC|17982827>
  XFilteredTree {}<HC|12606869>
    Composite {}<HC|10618321>
        Text {}<HC|24849305>
    Composite {}<HC|19658581>
        Tree {}<HC|23815485>
         Menu {}<HC|29596937>
         ScrollBar {}<HC|10747063>
         ScrollBar {}<HC|2380731>
         TreeItem {SomeElement}<HC|4516542>
          TreeItem {SomeSecondElement}<HC|9402810>
         [Text {}<HC|25016238>]->(invisible)
         [CCombo {}<HC|10889280>]->(invisible)
         [Text {}<HC|10272673>]->(invisible)

I thought the FilteredTreeItemLocator would match if I do it this way:

ui.click(new FilteredTreeItemLocator("SomeElement/SomeSecondElement",new 
ViewLocator("SomeView")));

But could not resolve the parent correctly so i changed some behavior in 
matching - see the diffs attached.

Maybe there is a better way - if so let me know :) 

Original issue reported on code.google.com by falk.z...@gmail.com on 23 Nov 2012 at 12:28

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Falk,

Could you add a minimal test case for this issue?

Regards,

Fred

Original comment by fred.g...@googlemail.com on 28 Nov 2012 at 1:06

GoogleCodeExporter commented 9 years ago
Hi Falk,

I attached a simple test case for your issue.
Apparently the new ".containedIn()" method that was added in 
https://code.google.com/p/windowtester/issues/detail?id=11 already does what 
you want (see attached test case).
Please check if this works for you and report back.

Regards,

Fred

Original comment by fred.g...@googlemail.com on 10 Dec 2012 at 12:27

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Fred,

sorry that i missed the test case for this issue.

I will try this and report you if it works - but i think it seems to be a 
possible way :)

Original comment by falk.z...@gmail.com on 10 Dec 2012 at 10:00

GoogleCodeExporter commented 9 years ago
It didn't worked :(

Tried following different lines:

FilteredTreeItemLocator tree = new 
FilteredTreeItemLocator("Root_Element/Leaf").containedIn(new 
ViewLocator("OurView")); 

FilteredTreeItemLocator tree = ((SWTWidgetLocator) new 
FilteredTreeItemLocator("Root_Element/Leaf").containedIn(new 
SWTWidgetLocator(OurSpecialFilteredTree.class))).containedIn(new 
ViewLocator("OurView"));

It fails with following error message:

com.windowtester.runtime.MultipleWidgetsFoundException: Multiple Widgets Found:
looking for
  FilteredTreeLocator()
and found:
  TreeReference - Tree {}
  TreeReference - Tree {}

Best regards,
Falk

Original comment by falk.z...@gmail.com on 10 Dec 2012 at 12:41

GoogleCodeExporter commented 9 years ago
Hi Falk,

I guess you have more than one of the FilteredTrees inside of your view.
Then you could use the .containedIn(int, SWTWidgetLocator) method and set the 
first parameter to 0 or 1 depending on whether you want the first or the second 
tree.

HTH,

Fred

Original comment by fred.g...@googlemail.com on 12 Dec 2012 at 12:27

GoogleCodeExporter commented 9 years ago
Didn't work :( 
Don't know where it goes wrong - i tried to debug it but couldn't get the right 
information.

Last Breakpoint in line 211 TreeItemLocator after that point the test reaches 
the exception output.

Original comment by falk.z...@gmail.com on 14 Dec 2012 at 12:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hi Falk,

Can you provide a minimal test case that can be used to reproduce the error 
you're currently seeing? Otherwise I'm only fishing in muddy waters. ;)

Regards,

Fred

Original comment by fred.g...@googlemail.com on 29 Dec 2012 at 6:56

GoogleCodeExporter commented 9 years ago
Hey Fred :)

Made some DummyRCP Application today which uses our structure for the view - i 
attached the eclipse project as zip and here is my test case for that:

public class TestingTheDummy extends UITestCaseSWT {

    /* @see junit.framework.TestCase#setUp()
     */
    protected void setUp() throws Exception {
        super.setUp();
        IUIContext ui = getUI();
        ui.ensureThat(new WorkbenchLocator().hasFocus());
    }

    /**
     * Main test method.
     */
    public void testTestingTheDummy() throws Exception {
        IUIContext ui = getUI();
        ui.click(new FilteredTreeItemLocator("Habelman", new ViewLocator("DummyTest.view")));
        new DebugHelper().printWidgets();
    }
}

Hope it will work for you to test :)

Regards,
Falk

Original comment by falk.z...@gmail.com on 4 Jan 2013 at 10:02

Attachments:

GoogleCodeExporter commented 9 years ago
Hi Falk,

Thanks for the test project and the test class.
The test class works for me without any problems.
I guess it also works for you?

I had to add a second view with the same filtered tree to see the problem
you've described ("Multiple Widgets Found").
In this case the containedIn() method does indeed not work as expected.

I found a workaround though:

ui.click(new FilteredTreeItemLocator("Habelman", 0, new 
ViewLocator("DummyTest.view")));

It magically works when you specify an index. This is still a bug, because it 
doesn't
seem to matter which index you provide ("1" also works!).

I will try to take a closer look at both bugs over the weekend.

Regards,

Fred

Original comment by fred.g...@googlemail.com on 9 Jan 2013 at 12:42

GoogleCodeExporter commented 9 years ago
Hi Fred,

yes you are right the problem begins with two views.

I thought i had tested it with an index .. but ok see you found different 
problems maybe it works after that - how is the progress so far ?

Regards,
Falk

Original comment by falk.z...@gmail.com on 14 Jan 2013 at 9:53