Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@
import org.eclipse.jdt.debug.tests.ui.DebugHoverTests;
import org.eclipse.jdt.debug.tests.ui.DebugViewTests;
import org.eclipse.jdt.debug.tests.ui.DetailPaneManagerTests;
import org.eclipse.jdt.debug.tests.ui.HotCodeReplaceErrorDialogTest;
import org.eclipse.jdt.debug.tests.ui.JavaSnippetEditorTest;
import org.eclipse.jdt.debug.tests.ui.NoLineNumberAttributesStatusHandlerTest;
import org.eclipse.jdt.debug.tests.ui.OpenFromClipboardTests;
import org.eclipse.jdt.debug.tests.ui.ViewManagementTests;
import org.eclipse.jdt.debug.tests.ui.VirtualThreadsDebugViewTests;
Expand Down Expand Up @@ -341,6 +343,12 @@ public AutomatedSuite() {
// Scrapbook editor tests
addTest(new TestSuite(JavaSnippetEditorTest.class));

// No Line Number Attributes Status Handler tests
addTest(new TestSuite(NoLineNumberAttributesStatusHandlerTest.class));

// Test that ErrorDialogWithToggle Override functionalities won't cause a Stackoverflow Exception
addTest(new TestSuite(HotCodeReplaceErrorDialogTest.class));

// Debug hover tests
addTest(new TestSuite(DebugHoverTests.class));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*******************************************************************************
* Copyright (c) 2025 Advantest Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Advantest Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.debug.tests;

import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IMemoryBlock;
import org.eclipse.debug.core.model.IProcess;
import org.eclipse.debug.core.model.IThread;

/**
* This is a test debug target which can be used to mimic an IDebugTarget instance.
*/
public class TestDebugTarget implements IDebugTarget {

@Override
public boolean supportsStorageRetrieval() {
return false;
}

@Override
public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException {
return null;
}

@Override
public boolean isDisconnected() {
return false;
}

@Override
public void disconnect() throws DebugException {

}

@Override
public boolean canDisconnect() {
return false;
}

@Override
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {

}

@Override
public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) {

}

@Override
public void breakpointAdded(IBreakpoint breakpoint) {

}

@Override
public void suspend() throws DebugException {

}

@Override
public void resume() throws DebugException {

}

@Override
public boolean isSuspended() {
return false;
}

@Override
public boolean canSuspend() {
return false;
}

@Override
public boolean canResume() {
return false;
}

@Override
public void terminate() throws DebugException {

}

@Override
public boolean isTerminated() {
return false;
}

@Override
public boolean canTerminate() {
return false;
}

@Override
public <T> T getAdapter(Class<T> adapter) {
return null;
}

@Override
public String getModelIdentifier() {
return null;
}

@Override
public ILaunch getLaunch() {
return null;
}

@Override
public IDebugTarget getDebugTarget() {
return null;
}

@Override
public boolean supportsBreakpoint(IBreakpoint breakpoint) {
return false;
}

@Override
public boolean hasThreads() throws DebugException {
return false;
}

@Override
public IThread[] getThreads() throws DebugException {
return null;
}

@Override
public IProcess getProcess() {
return null;
}

@Override
public String getName() throws DebugException {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*******************************************************************************
* Copyright (c) 2025 Advantest Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Advantest Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.debug.tests.ui;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.jdt.debug.tests.TestDebugTarget;
import org.eclipse.jdt.internal.debug.ui.DebugUIMessages;
import org.eclipse.jdt.internal.debug.ui.HotCodeReplaceErrorDialog;
import org.eclipse.jdt.internal.debug.ui.IJDIPreferencesConstants;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.widgets.Shell;
import org.junit.Test;

public class HotCodeReplaceErrorDialogTest extends AbstractDebugUiTests {

private final class HotCodeReplaceErrorDialogSimRunnable implements Runnable {
private final IStatus status;
private final String toggleMessage;
private final String prefAlertObsoleteMethods;
private final String toggleMessage2;
private final IPreferenceStore preferenceStore;
private final String message;
private final String dialogTitle;
private final Shell shell;

private HotCodeReplaceErrorDialogSimRunnable(IStatus status, String toggleMessage, String prefAlertObsoleteMethods, String toggleMessage2, IPreferenceStore preferenceStore, String message, String dialogTitle, Shell shell) {
this.status = status;
this.toggleMessage = toggleMessage;
this.prefAlertObsoleteMethods = prefAlertObsoleteMethods;
this.toggleMessage2 = toggleMessage2;
this.preferenceStore = preferenceStore;
this.message = message;
this.dialogTitle = dialogTitle;
this.shell = shell;
}

@Override
public void run() {
class HotCodeReplaceErrorDialogExtension extends HotCodeReplaceErrorDialog {
private HotCodeReplaceErrorDialogExtension(Shell parentShell, String dialogTitle, String message, IStatus status, String preferenceKey, String toggleMessage, String toggleMessage2, IPreferenceStore store, IDebugTarget target) {
super(parentShell, dialogTitle, message, status, preferenceKey, toggleMessage, toggleMessage2, store, target);
}

@Override
public void buttonPressed(int id) {
super.buttonPressed(id);
}
}

HotCodeReplaceErrorDialogExtension errorDialog = new HotCodeReplaceErrorDialogExtension(shell, dialogTitle, message, status, prefAlertObsoleteMethods, toggleMessage, toggleMessage2, preferenceStore, new TestDebugTarget());
final boolean originalMode = ErrorDialog.AUTOMATED_MODE;
ErrorDialog.AUTOMATED_MODE = false;
try {
errorDialog.create();
errorDialog.getShell().addShellListener(new ShellAdapter() {
@Override
public void shellActivated(ShellEvent e) {
// To see dialog: processUiEvents(500);
processUiEvents();
errorDialog.buttonPressed(IDialogConstants.OK_ID);
}
});
errorDialog.open();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
ErrorDialog.AUTOMATED_MODE = originalMode;
errorDialog.close();
}
}
}

public HotCodeReplaceErrorDialogTest(String name) {
super(name);
}

@Test
public void testHotCodeReplaceErrorDialog() {
Shell shell = JDIDebugUIPlugin.getActiveWorkbenchShell();
final String vmName = "Dummy VM";
final String dialogTitle = DebugUIMessages.JDIDebugUIPlugin_Obsolete_methods_remain_1;
final String message = NLS.bind(DebugUIMessages.JDIDebugUIPlugin__0__contains_obsolete_methods_1, new Object[] { vmName });
final IStatus status = new Status(IStatus.WARNING, JDIDebugUIPlugin.getUniqueIdentifier(), IStatus.WARNING, DebugUIMessages.JDIDebugUIPlugin_Stepping_may_be_hazardous_1, null);
final String toggleMessage = DebugUIMessages.JDIDebugUIPlugin_2;
final String toggleMessage2 = DebugUIMessages.JDIDebugUIPlugin_5;
IPreferenceStore preferenceStore = JDIDebugUIPlugin.getDefault().getPreferenceStore();
String prefAlertObsoleteMethods = IJDIPreferencesConstants.PREF_ALERT_OBSOLETE_METHODS;

Runnable dialogSimRunnable = new HotCodeReplaceErrorDialogSimRunnable(status, toggleMessage, prefAlertObsoleteMethods, toggleMessage2, preferenceStore, message, dialogTitle, shell);
sync(dialogSimRunnable);
}
}
Loading