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
20 changes: 10 additions & 10 deletions debug/org.eclipse.debug.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.debug.tests;singleton:=true
Bundle-Version: 3.15.300.qualifier
Bundle-Version: 3.15.400.qualifier
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.29.0,4.0.0)",
org.eclipse.debug.ui;bundle-version="[3.10.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.3.0,2.0.0)",
org.eclipse.test.performance;bundle-version="3.6.0",
org.eclipse.ui.externaltools;bundle-version="[3.3.0,4.0.0)",
org.eclipse.ui.console;bundle-version="[3.7.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.15.100,4.0.0)"
Require-Bundle: org.eclipse.ui;bundle-version="[3.208.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.34.0,4.0.0)",
org.eclipse.debug.ui;bundle-version="[3.21.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="[1.11.0,2.0.0)",
org.eclipse.test.performance;bundle-version="[3.21.0,4.0.0)",
org.eclipse.ui.externaltools;bundle-version="[3.7.0,4.0.0)",
org.eclipse.ui.console;bundle-version="[3.17.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.30.0,4.0.0)",
org.eclipse.ui.workbench.texteditor;bundle-version="[3.20.0,4.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.debug.tests.breakpoint.BreakpointTests;
import org.eclipse.debug.tests.breakpoint.SerialExecutorTest;
import org.eclipse.debug.tests.console.ConsoleDocumentAdapterTests;
import org.eclipse.debug.tests.console.ConsoleShowHideTests;
import org.eclipse.debug.tests.console.ConsoleManagerTests;
import org.eclipse.debug.tests.console.ConsoleTests;
import org.eclipse.debug.tests.console.FileLinkTests;
Expand Down Expand Up @@ -117,6 +118,7 @@

// Console view
ConsoleDocumentAdapterTests.class, //
ConsoleShowHideTests.class, //
ConsoleManagerTests.class, //
ConsoleTests.class, //
IOConsoleTests.class, //
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2017 Andrey Loskutov and others.
* Copyright (c) 2016, 2026 Andrey Loskutov and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -21,33 +21,26 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

import org.eclipse.debug.tests.DebugTestExtension;
import org.eclipse.debug.tests.TestUtil;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.IConsoleView;
import org.eclipse.ui.internal.console.ConsoleManager;
import org.eclipse.ui.part.IPageBookViewPage;
import org.eclipse.ui.part.MessagePage;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* Tests console manager
* Tests console manager behavior when multiple consoles are shown at the same
* time.
*/
@ExtendWith(DebugTestExtension.class)
public class ConsoleManagerTests {
Expand All @@ -58,6 +51,8 @@ public class ConsoleManagerTests {
private CountDownLatch latch;
private ConsoleMock[] consoles;
ConsoleMock firstConsole;
private IViewPart consoleView;
private IWorkbenchPage activePage;

@BeforeEach
public void setUp(TestInfo testInfo) throws Exception {
Expand All @@ -66,7 +61,7 @@ public void setUp(TestInfo testInfo) throws Exception {
latch = new CountDownLatch(count);
executorService = Executors.newFixedThreadPool(count);
manager = ConsolePlugin.getDefault().getConsoleManager();
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
TestUtil.processUIEvents(100);
consoles = new ConsoleMock[count];
for (int i = 0; i < count; i++) {
Expand All @@ -76,7 +71,7 @@ public void setUp(TestInfo testInfo) throws Exception {
// register consoles (this does *not* show anything)
manager.addConsoles(consoles);

IViewPart consoleView = activePage.showView("org.eclipse.ui.console.ConsoleView"); //$NON-NLS-1$
consoleView = activePage.showView("org.eclipse.ui.console.ConsoleView");
activePage.activate(consoleView);
TestUtil.processUIEvents(100);

Expand All @@ -96,6 +91,7 @@ public void tearDown() throws Exception {
executorService.shutdownNow();
manager.removeConsoles(consoles);
manager.removeConsoles(new ConsoleMock[] { firstConsole });
activePage.hideView(consoleView);
TestUtil.processUIEvents(100);
}

Expand Down Expand Up @@ -168,73 +164,4 @@ private void showConsole(final ConsoleMock console, String testName) {
});
}

/**
* Dummy console page showing mock number and counting the numbers its
* control was shown in the console view.
*/
static final class ConsoleMock implements IConsole {
MessagePage page;
final AtomicInteger showCalled;
final int number;
final static AtomicInteger allShownConsoles = new AtomicInteger();

public ConsoleMock(int number) {
this.number = number;
showCalled = new AtomicInteger();
}

@Override
public void removePropertyChangeListener(IPropertyChangeListener listener) {
}

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

@Override
public String getName() {
return toString();
}

@Override
public ImageDescriptor getImageDescriptor() {
return null;
}

@Override
public void addPropertyChangeListener(IPropertyChangeListener listener) {
}

/**
* Just a page showing the mock console name
*/
@Override
public IPageBookViewPage createPage(IConsoleView view) {
page = new MessagePage() {
@Override
public void createControl(Composite parent) {
super.createControl(parent);
// This listener is get called if the page is really shown
// in the console view
getControl().addListener(SWT.Show, event -> {
int count = showCalled.incrementAndGet();
if (count == 1) {
count = allShownConsoles.incrementAndGet();
System.out.println("Shown: " + ConsoleMock.this + ", overall: " + count); //$NON-NLS-1$ //$NON-NLS-2$
}
});
}

};
page.setMessage(toString());
return page;
}

@Override
public String toString() {
return "mock #" + number; //$NON-NLS-1$
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*******************************************************************************
* Copyright (c) 2026 Andrey Loskutov 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:
* Andrey Loskutov <loskutov@gmx.de> - initial API and implementation
*******************************************************************************/
package org.eclipse.debug.tests.console;

import java.util.concurrent.atomic.AtomicInteger;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.console.IConsole;
import org.eclipse.ui.console.IConsoleView;
import org.eclipse.ui.part.IPageBookViewPage;
import org.eclipse.ui.part.MessagePage;

/**
* Dummy console page showing mock number and counting the numbers its
* control was shown in the console view.
*/
final class ConsoleMock implements IConsole {
MessagePage page;
final AtomicInteger showCalled;
final AtomicInteger pageShownCalled;
final AtomicInteger pageHiddenCalled;
final int number;
final static AtomicInteger allShownConsoles = new AtomicInteger();

public ConsoleMock(int number) {
this.number = number;
showCalled = new AtomicInteger();
pageShownCalled = new AtomicInteger();
pageHiddenCalled = new AtomicInteger();
}

@Override
public void pageShown() {
pageShownCalled.incrementAndGet();
}

@Override
public void pageHidden() {
pageHiddenCalled.incrementAndGet();
}

@Override
public void removePropertyChangeListener(IPropertyChangeListener listener) {
}

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

@Override
public String getName() {
return toString();
}

@Override
public ImageDescriptor getImageDescriptor() {
return null;
}

@Override
public void addPropertyChangeListener(IPropertyChangeListener listener) {
}

/**
* Just a page showing the mock console name
*/
@Override
public IPageBookViewPage createPage(IConsoleView view) {
page = new MessagePage() {
@Override
public void createControl(Composite parent) {
super.createControl(parent);
// This listener is get called if the page is really shown
// in the console view
getControl().addListener(SWT.Show, event -> {
int count = showCalled.incrementAndGet();
if (count == 1) {
count = allShownConsoles.incrementAndGet();
System.out.println("Shown: " + ConsoleMock.this + ", overall: " + count); //$NON-NLS-1$ //$NON-NLS-2$
}
});
}

};
page.setMessage(toString());
return page;
}

@Override
public String toString() {
return "mock #" + number; //$NON-NLS-1$
}
}
Loading
Loading