benjamin84 / fest

Automatically exported from code.google.com/p/fest
0 stars 0 forks source link

JTreeFixture tree path not visible #200

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago

Hi,

I'm using FEST-Swing 1.0b1.
I want to pop up the context menu at a specific node in a JTree.
The path is OK, but I get a LocationUnavailableException.

I'm using TestNG to run my tests, here is the stack trace:

org.fest.swing.exception.LocationUnavailableException: The tree path
[Scenarios, Scenario1, Location, City, City4] is not visible
    at org.fest.swing.driver.JTreeLocation.pointAt(JTreeLocation.java:65)
    at org.fest.swing.driver.JTreeDriver.showPopupMenu(JTreeDriver.java:288)
    at org.fest.swing.fixture.JTreeFixture.showPopupMenuAt(JTreeFixture.java:286)
    at
ro.alcatel.art.test.acceptance.release1_3.TestCase13.execute03(TestCase13.java:9
8)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:580)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:478)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:617)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:885)
    at
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126
)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:110)
    at org.testng.TestRunner.runWorkers(TestRunner.java:712)
    at org.testng.TestRunner.privateRun(TestRunner.java:582)
    at org.testng.TestRunner.run(TestRunner.java:477)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
    at org.testng.SuiteRunner.run(SuiteRunner.java:198)
    at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:790)
    at org.testng.TestNG.run(TestNG.java:708)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)

I tried to find the source of the problem by debugging.
I got to a certain point in javax.swing.plaf.basic.BasicTreeUI, where in
the first line of the method
private Rectangle getPathBounds(TreePath, Insets, Rectangle)
the call
treeState.getBounds(path, bounds);
returns null.

I didn't debug any further, because I'm not really a Swing expert and it
seems that my JRE doesn't have proper debugging symbols, all local
variables have names like "arg0", "arg1", etc...

Here is the stack trace of the debug:

Thread [main] (Suspended)   
    PlasticTreeUI(BasicTreeUI).getPathBounds(TreePath, Insets, Rectangle)
line: 516   
    PlasticTreeUI(BasicTreeUI).getPathBounds(JTree, TreePath) line: 508 
    ObjectEditorTree(JTree).getPathBounds(TreePath) line: 2066  
    JTreeLocation.pointAt(JTree, TreePath) line: 62 
    JTreeDriver.showPopupMenu(JTree, String) line: 288  
    JTreeFixture.showPopupMenuAt(String) line: 286  
    TestCase13.execute03() line: 98 
    NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]   
    NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39  
    DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25  
    Method.invoke(Object, Object...) line: 597  
    MethodHelper.invokeMethod(Method, Object, Object[]) line: 580   
    Invoker.invokeMethod(Object[], int, ITestNGMethod, Object[], XmlSuite,
Map<String,String>, ITestClass, ITestNGMethod[], ITestNGMethod[],
ConfigurationGroupMethods) line: 478    
    Invoker.invokeTestMethod(Object[], ITestNGMethod, Object[], XmlSuite,
Map<String,String>, ITestClass, ITestNGMethod[], ITestNGMethod[],
ConfigurationGroupMethods) line: 617    
    Invoker.invokeTestMethods(ITestNGMethod, ITestNGMethod[], int, XmlSuite,
Map<String,String>, ConfigurationGroupMethods, Object[], ITestContext)
line: 885   
    TestMethodWorker.invokeTestMethods(ITestNGMethod, Object[], ITestContext)
line: 126   
    TestMethodWorker.run() line: 110    
    TestRunner.runWorkers(List<IMethodWorker>, String) line: 712    
    TestRunner.privateRun(XmlTest) line: 582    
    TestRunner.run() line: 477  
    SuiteRunner.runTest(TestRunner) line: 324   
    SuiteRunner.runSequentially() line: 319 
    SuiteRunner.privateRun() line: 292  
    SuiteRunner.run() line: 198 
    RemoteTestNG(TestNG).createAndRunSuiteRunners(XmlSuite) line: 823   
    RemoteTestNG(TestNG).runSuitesLocally() line: 790   
    RemoteTestNG(TestNG).run() line: 708    
    RemoteTestNG.run() line: 73 
    RemoteTestNG.main(String[]) line: 124   

I hope I gave you enough information to get you started and I'll be happy
to provide you with more.

Thank you,
Csabi

Original issue reported on code.google.com by csaba.ju...@gmail.com on 26 Aug 2008 at 9:14

GoogleCodeExporter commented 9 years ago
Many thanks Csabi!!!

-Alex

Original comment by Alex.Rui...@gmail.com on 26 Aug 2008 at 3:29

GoogleCodeExporter commented 9 years ago

Hi Alex,

It seems that #showPopupMenuAt works if I call JTreeFixture#selectPath just 
before
and with the same argument.

It seems to me that a call to JTreeDriver#makeVisible(JTree, TreePath, boolean) 
just
before the call to Robot#showPopupMenu in the JTreeFixture#showPopupMenuAt 
methods
would fix the issue.

I hope this helps, thanks,
Csabi

Original comment by csaba.ju...@gmail.com on 16 Sep 2008 at 12:33

GoogleCodeExporter commented 9 years ago

Hi again,

In the meantime I will add collapseAll and expandAll to JTreeFixture to avoid 
calling
#selectPath all the time. I think that they would be a useful addition to 
JTreeFixture.

And I don't want to just call JTree#expandPath because I would be accessing the 
tree
outside of the EDT. See issue 204.

Thanks,
Csabi

P.S. I apologize for spamming you all of a sudden with all these reports. :)

Original comment by csaba.ju...@gmail.com on 16 Sep 2008 at 1:52

GoogleCodeExporter commented 9 years ago
Method 'showPopupMenuAt(String)' in org.fest.swing.fixture.JTreeFixture now 
makes the
last node in the given path visible before showing a JPopupMenu.

Original comment by Alex.Rui...@gmail.com on 14 Oct 2008 at 2:56

GoogleCodeExporter commented 9 years ago
Thanks Alex,
Csabi

Original comment by csaba.ju...@gmail.com on 14 Oct 2008 at 9:47

GoogleCodeExporter commented 9 years ago
Set the module as a label, instead of being part of the title.

Original comment by Alex.Rui...@gmail.com on 1 Dec 2008 at 3:17

GoogleCodeExporter commented 9 years ago
Can someone plz provide an example of how to expand tree? 

It would be very cool ! I am stuck for days now ... :)

Cheers !

Original comment by krikk...@hotmail.com on 16 Nov 2012 at 5:24

GoogleCodeExporter commented 9 years ago
Please help me to fixed this:
   My problem I want want to rightclick on given tree path and delete that particular node of tree(once we rightclick it shows contents menu then click on delete option and then it shows popup "are you sure to delete" with yes no button)

here I have written code for it::

protected void workFlowVarification(String treeName){

    sleep(1000);

    JTreeFixture documentTree=frame.tree(treeName);
    documentTree.expandPath("Workflow Processes/My Workflow Processes");
    documentTree.selectPath("Workflow Processes/My Workflow Processes");

    documentTree.expandPath("Workflow Processes/My Workflow  Processes/GaneshWF")
    documentTree.selectPath("Workflow Processes/My Workflow Processes/GaneshWF");

    documentTree.rightClick().component().getSelectionRows();
    } 

AFTER executing this test it gives me error
org.fest.swing.exception.LocationUnavailableException:

Original comment by girikord...@gmail.com on 27 Aug 2014 at 6:58