Skip to content

Commit afacf90

Browse files
committed
Derive slow-save sleep from getLongOperationTime()
The shutdown test hard-coded a 1200ms sleep based on the current 800ms default of IProgressService#getLongOperationTime(). Read the live value in postStartup() and add a fixed margin so the test still exercises the delayed-open path if the platform default changes.
1 parent 67d1730 commit afacf90

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

tests/org.eclipse.ui.ide.application.tests/src/org/eclipse/ui/internal/ide/application/IDEWorkbenchAdvisorTest.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.io.Closeable;
2222
import java.util.concurrent.atomic.AtomicInteger;
23+
import java.util.concurrent.atomic.AtomicLong;
2324

2425
import org.eclipse.core.resources.ISaveContext;
2526
import org.eclipse.core.resources.ISaveParticipant;
@@ -212,14 +213,16 @@ public void postShutdown() {
212213
@Test
213214
public void testShutdownWithSlowSave() throws CoreException {
214215
try (SaveHook saveHook = new SaveHook()) {
215-
// Exceeds the default IProgressService#getLongOperationTime (800ms),
216-
// so the new code path schedules and opens the progress dialog.
217-
final long sleepMillis = 1200L;
216+
// Sleep duration is derived from the live IProgressService#getLongOperationTime()
217+
// value in postStartup(), so the test exercises the delayed-open path even if
218+
// the platform default ever changes.
219+
final long sleepMarginMillis = 500L;
220+
final AtomicLong sleepMillis = new AtomicLong();
218221
workspace.addSaveParticipant(PLUGIN_ID + ".slow", new ISaveParticipant() {
219222
@Override
220223
public void saving(ISaveContext context) {
221224
try {
222-
Thread.sleep(sleepMillis);
225+
Thread.sleep(sleepMillis.get());
223226
} catch (InterruptedException e) {
224227
Thread.currentThread().interrupt();
225228
}
@@ -242,6 +245,9 @@ public void rollback(ISaveContext context) {
242245
@Override
243246
public void postStartup() {
244247
super.postStartup();
248+
long longOperationTime = PlatformUI.getWorkbench().getProgressService()
249+
.getLongOperationTime();
250+
sleepMillis.set(longOperationTime + sleepMarginMillis);
245251
display.asyncExec(() -> PlatformUI.getWorkbench().close());
246252
}
247253
};

0 commit comments

Comments
 (0)