Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333512

Summary: A menu item is disabled when using SWTBot but it should be enabled.
Product: [Technology] SWTBot Reporter: Nick Chen <nchen>
Component: SWTBotAssignee: Project Inbox <swtbot-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 CC: chris.burguera, nchen
Version: 2.0.1   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Nick Chen CLA 2011-01-04 15:44:43 EST
Build Identifier: 20100917-0705

I've written up [a GUI test][1] using [SWTBot][2] to test the Extract Method refactoring. I use `editor.selectRange()` to select a statement to extract into a method. But, when I run the unit test, the Extract Method refactoring menu item is disabled. Thus, SWTBot fails to invoke the refactoring.

When we change `org.eclipse.jdt.ui.actions.ExtractMethodAction` so that the "Extract Method..." menu item is always enabled, our SWTBot passes. But, SWTBot should let us select the menu item without hacking the `org.eclipse.jdt.ui` plugin.

The whole project containing the above unit test is [available at github][3]. I've also reported the problem on [the Eclipse forum for SWTBot][4]. But, we haven't received a solution from the forum.


  [1]: https://github.com/vazexqi/CodingSpectator/blob/test-using-swtbot/edu.illinois.eclipsewatcher.ui.tests/src/edu/illinois/eclipsewatcher/tests/ExtractMethodTest.java
  [2]: http://www.eclipse.org/swtbot/
  [3]: https://github.com/vazexqi/CodingSpectator/tree/test-using-swtbot/edu.illinois.eclipsewatcher.ui.tests
  [4]: http://www.eclipse.org/forums/index.php?t=rview&goto=558874&th=175411

Reproducible: Always

Steps to Reproduce:
SWTBotEclipseEditor editor= bot.editorByTitle(TEST_FILE_NAME + ".java").toTextEditor();

editor.setFocus();

//Select a statement to extract into a method.
editor.selectRange(7, 8, 38 - 8);

SWTBotMenu refactorMenu= bot.menu("Refactor");
assertTrue(refactorMenu.isEnabled());

SWTBotMenu extractConstantMenuItem= refactorMenu.menu("Extract Method...");
assertTrue(extractConstantMenuItem.isEnabled()); //This assertion fails.