Skip to content
Draft
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 @@ -30,11 +30,12 @@
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.swt.DisplayUISynchronize;
import org.eclipse.swt.widgets.Display;
import org.junit.rules.MethodRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.jupiter.api.extension.TestInstancePostProcessor;

public class WorkbenchContextRule implements MethodRule {
public class WorkbenchContextRule implements BeforeEachCallback, AfterEachCallback, TestInstancePostProcessor {

private IEclipseContext context;
private E4Workbench wb;
Expand All @@ -52,19 +53,18 @@ public void spinEventLoop() {
}

@Override
public Statement apply(final Statement base, final FrameworkMethod method, final Object target) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
createContext();
ContextInjectionFactory.inject(target, context);
try {
base.evaluate();
} finally {
dispose();
}
}
};
public void beforeEach(ExtensionContext extensionContext) throws Exception {
createContext();
}

@Override
public void afterEach(ExtensionContext extensionContext) throws Exception {
dispose();
}

@Override
public void postProcessTestInstance(Object testInstance, ExtensionContext extensionContext) throws Exception {
ContextInjectionFactory.inject(testInstance, this.context);
}

protected void createContext() throws Throwable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

package org.eclipse.e4.ui.tests.workbench;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

import jakarta.inject.Inject;
import org.eclipse.e4.ui.model.application.MApplication;
Expand All @@ -28,13 +28,13 @@
import org.eclipse.e4.ui.tests.rules.WorkbenchContextRule;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.Test;

public class CompositePartClosingTest {

@Rule
public WorkbenchContextRule contextRule = new WorkbenchContextRule();
@RegisterExtension
WorkbenchContextRule contextRule = new WorkbenchContextRule();

@Inject
private EModelService ems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

package org.eclipse.e4.ui.tests.workbench;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import jakarta.inject.Inject;
import jakarta.inject.Named;
Expand Down Expand Up @@ -60,14 +60,14 @@
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Widget;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class MMenuItemTest {

@Rule
public WorkbenchContextRule contextRule = new WorkbenchContextRule();
@RegisterExtension
WorkbenchContextRule contextRule = new WorkbenchContextRule();

@Inject
private EModelService ems;
Expand All @@ -78,7 +78,7 @@ public class MMenuItemTest {
@Inject
private MApplication application;

@Before
@BeforeEach
public void setUp() {
ContextInjectionFactory.make(CommandServiceAddon.class, appContext);
ContextInjectionFactory.make(ContextServiceAddon.class, appContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

package org.eclipse.e4.ui.tests.workbench;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import jakarta.inject.Inject;
import org.eclipse.e4.core.contexts.IEclipseContext;
Expand All @@ -32,13 +32,13 @@
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class MPartTest {

@Rule
public WorkbenchContextRule contextRule = new WorkbenchContextRule();
@RegisterExtension
WorkbenchContextRule contextRule = new WorkbenchContextRule();

@Inject
private IEclipseContext appContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

package org.eclipse.e4.ui.tests.workbench;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

import jakarta.inject.Inject;
import org.eclipse.e4.ui.model.application.MApplication;
Expand All @@ -28,13 +28,13 @@
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.Test;

public class MSaveablePartTest {

@Rule
public WorkbenchContextRule contextRule = new WorkbenchContextRule();
@RegisterExtension
WorkbenchContextRule contextRule = new WorkbenchContextRule();

@Inject
private EModelService ems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

package org.eclipse.e4.ui.tests.workbench;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import jakarta.inject.Inject;
import org.eclipse.e4.ui.model.application.MApplication;
Expand All @@ -33,13 +33,13 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.ToolItem;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.Test;

public class MToolItemTest {

@Rule
public WorkbenchContextRule contextRule = new WorkbenchContextRule();
@RegisterExtension
WorkbenchContextRule contextRule = new WorkbenchContextRule();

@Inject
private EModelService ems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@

package org.eclipse.e4.ui.tests.workbench;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.Assume.assumeFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assumptions.assumeFalse;

import jakarta.inject.Inject;
import org.eclipse.core.runtime.Platform;
Expand Down Expand Up @@ -51,14 +51,14 @@
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.tests.harness.util.DisplayHelper;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class MWindowTest {

@Rule
public WorkbenchContextRule contextRule = new WorkbenchContextRule();
@RegisterExtension
WorkbenchContextRule contextRule = new WorkbenchContextRule();

@Inject
private IEclipseContext appContext;
Expand Down Expand Up @@ -250,7 +250,7 @@ public void testWindow_Name() {
assertEquals("windowName2", shell.getText());
}

@Ignore
@Disabled
@Test
public void TODOtestWindow_X() {
final MWindow window = ems.createModelElement(MWindow.class);
Expand Down Expand Up @@ -283,7 +283,7 @@ public void TODOtestWindow_X() {
assertEquals(300, bounds.x);
}

@Ignore
@Disabled
@Test
public void TODOtestWindow_Y() {
final MWindow window = ems.createModelElement(MWindow.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

package org.eclipse.e4.ui.tests.workbench;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
Expand All @@ -31,23 +31,23 @@
import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.e4.ui.tests.rules.WorkbenchContextRule;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

public class ModelServiceImplTest {
private static final String DUMMY_EDITOR_ID = "dummyEditor";

@Rule
public WorkbenchContextRule contextRule = new WorkbenchContextRule();
@RegisterExtension
WorkbenchContextRule contextRule = new WorkbenchContextRule();

@Inject
private EModelService modelService;

private MPart editor;

@Before
@BeforeEach
public void setUp() throws Exception {
editor = modelService.createModelElement(MPart.class);
editor.setElementId(DUMMY_EDITOR_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

package org.eclipse.e4.ui.tests.workbench;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import jakarta.inject.Inject;
import org.eclipse.e4.ui.internal.workbench.PartOnTopManager;
Expand All @@ -33,17 +33,17 @@
import org.eclipse.e4.ui.workbench.IWorkbench;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.Test;

/**
* This test class is used to validate the correctness of the
* {@link PartOnTopManager}.
*/
public class PartOnTopManagerTest {

@Rule
public WorkbenchContextRule contextRule = new WorkbenchContextRule();
@RegisterExtension
WorkbenchContextRule contextRule = new WorkbenchContextRule();

@Inject
private EModelService ems;
Expand Down
Loading
Loading