mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 09:15:38 +02:00
Added protection against opening a dialog in JUnit test.
This commit is contained in:
parent
9742045d4a
commit
56c7e8b130
2 changed files with 6 additions and 0 deletions
|
@ -91,6 +91,7 @@ public class AddIncludeTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertAddIncludeResult() throws Exception {
|
private void assertAddIncludeResult() throws Exception {
|
||||||
|
AddIncludeOnSelectionAction.sIsJUnitTest= true;
|
||||||
new AddIncludeOnSelectionAction(fEditor).run();
|
new AddIncludeOnSelectionAction(fEditor).run();
|
||||||
|
|
||||||
String file= createFileName(".expected");
|
String file= createFileName(".expected");
|
||||||
|
|
|
@ -96,6 +96,8 @@ import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
|
||||||
* selected name.
|
* selected name.
|
||||||
*/
|
*/
|
||||||
public class AddIncludeOnSelectionAction extends TextEditorAction {
|
public class AddIncludeOnSelectionAction extends TextEditorAction {
|
||||||
|
public static boolean sIsJUnitTest = false;
|
||||||
|
|
||||||
private ITranslationUnit fTu;
|
private ITranslationUnit fTu;
|
||||||
private IProject fProject;
|
private IProject fProject;
|
||||||
private String[] fIncludePath;
|
private String[] fIncludePath;
|
||||||
|
@ -251,6 +253,9 @@ public class AddIncludeOnSelectionAction extends TextEditorAction {
|
||||||
|
|
||||||
final ArrayList<IncludeCandidate> candidates = new ArrayList<IncludeCandidate>(candidatesMap.values());
|
final ArrayList<IncludeCandidate> candidates = new ArrayList<IncludeCandidate>(candidatesMap.values());
|
||||||
if (candidates.size() > 1) {
|
if (candidates.size() > 1) {
|
||||||
|
if (sIsJUnitTest) {
|
||||||
|
throw new RuntimeException("ambiguous input"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
runInUIThread(new Runnable() {
|
runInUIThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
ElementListSelectionDialog dialog=
|
ElementListSelectionDialog dialog=
|
||||||
|
|
Loading…
Add table
Reference in a new issue