Skip to content

Commit

Permalink
Migrate o.e.e4.ui.tests.css.swt to JUnit 5
Browse files Browse the repository at this point in the history
  • Loading branch information
akurtakov committed Nov 6, 2022
1 parent c656b2c commit d179e6e
Show file tree
Hide file tree
Showing 43 changed files with 377 additions and 474 deletions.
37 changes: 0 additions & 37 deletions tests/org.eclipse.e4.ui.tests.css.swt/CSS SWT Test Suite.launch

This file was deleted.

6 changes: 4 additions & 2 deletions tests/org.eclipse.e4.ui.tests.css.swt/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.e4.ui.tests.css.swt; singleton:=true
Bundle-Version: 0.11.600.qualifier
Require-Bundle: org.junit,
org.eclipse.swt,
Require-Bundle: org.eclipse.swt,
org.eclipse.e4.ui.css.core,
org.eclipse.e4.ui.css.swt,
org.w3c.css.sac,
Expand All @@ -18,6 +17,9 @@ Require-Bundle: org.junit,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-11
Import-Package: org.eclipse.core.runtime;version="3.5.0",
org.junit.jupiter.api;version="5.9.1",
org.junit.jupiter.api.function,
org.junit.platform.suite.api;version="1.9.1",
org.osgi.framework;version="1.7.0";resolution:=optional,
org.osgi.service.event;version="1.3.0";resolution:=optional,
org.osgi.util.tracker;version="1.5.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,41 @@

import static org.eclipse.e4.ui.css.core.resources.CSSResourcesHelpers.getCSSFontPropertiesKey;
import static org.eclipse.e4.ui.css.core.resources.CSSResourcesHelpers.getCSSValueKey;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties;
import org.eclipse.e4.ui.css.swt.helpers.CSSSWTHelperTestCase;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.css.CSSPrimitiveValue;

public class CSSResourcesHelpersTest extends CSSSWTHelperTestCase {
@Test
public void testGetCSSValueKeyWhenFont() {
void testGetCSSValueKeyWhenFont() {
CSS2FontProperties fontProperties = fontProperties("Arial", 10, null, null);
String result = getCSSValueKey(fontProperties);
assertNotNull(result);
assertEquals(getCSSFontPropertiesKey(fontProperties), result);
}

@Test
public void testGetCSSValueKeyWhenDefinitionAsFontFamily() {
void testGetCSSValueKeyWhenDefinitionAsFontFamily() {
CSS2FontProperties fontProperties = fontProperties(addFontDefinitionMarker("symbolicName"), 10, null, null);
String result = getCSSValueKey(fontProperties);
assertNotNull(result);
assertEquals(getCSSFontPropertiesKey(fontProperties), result);
}

@Test
public void testGetCSSValueKeyWhenRgbAsColorValue() {
void testGetCSSValueKeyWhenRgbAsColorValue() {
CSSPrimitiveValue colorValue = colorValue("rgb(255,0,0)");
String result = getCSSValueKey(colorValue);
assertNotNull(result);
assertEquals("rgb(255,0,0)", result);
}

@Test
public void testGetCSSValueKeyWhenDefinitionAsColorValue() {
void testGetCSSValueKeyWhenDefinitionAsColorValue() {
CSSPrimitiveValue colorValue = colorValue(addColorDefinitionMarker("symbolicName"));

String result = getCSSValueKey(colorValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
*******************************************************************************/
package org.eclipse.e4.ui.css.core.resources;

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

import org.eclipse.e4.ui.css.core.dom.properties.css2.CSS2FontProperties;
import org.eclipse.e4.ui.css.swt.helpers.CSSSWTHelperTestCase;
import org.eclipse.e4.ui.css.swt.resources.ResourceByDefinitionKey;
import org.eclipse.e4.ui.css.swt.resources.SWTResourceRegistryKeyFactory;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.css.CSSPrimitiveValue;

public class SWTResourceRegistryKeyFactoryTest extends CSSSWTHelperTestCase {
private SWTResourceRegistryKeyFactory factory = new SWTResourceRegistryKeyFactory();

@Test
public void testCreateKeyWhenFontProperty() {
void testCreateKeyWhenFontProperty() {
CSS2FontProperties fontProperties = fontProperties("Arial", 12, CSS_ITALIC, CSS_BOLD);
Object result = factory.createKey(fontProperties);

Expand All @@ -37,7 +37,7 @@ public void testCreateKeyWhenFontProperty() {
}

@Test
public void testCreateKeyWhenColorValue() {
void testCreateKeyWhenColorValue() {
CSSPrimitiveValue colorValue = colorValue("red");

Object result = factory.createKey(colorValue);
Expand All @@ -47,7 +47,7 @@ public void testCreateKeyWhenColorValue() {
}

@Test
public void testCreateKeyWhenFontByDefinition() {
void testCreateKeyWhenFontByDefinition() {
CSS2FontProperties fontProperties = null;
try {
fontProperties = fontProperties("#font-by-definition", 12, CSS_ITALIC, CSS_BOLD);
Expand All @@ -62,7 +62,7 @@ public void testCreateKeyWhenFontByDefinition() {
}

@Test
public void testCreateKeyWhenColorByDefinition() {
void testCreateKeyWhenColorByDefinition() {
CSSPrimitiveValue colorValue = colorValue("#color-by-definition");

Object result = factory.createKey(colorValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*******************************************************************************/
package org.eclipse.e4.ui.css.core.resources;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
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.spy;
Expand All @@ -28,11 +28,11 @@
import org.eclipse.e4.ui.css.swt.resources.SWTResourcesRegistry;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Resource;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class SWTResourcesRegistryTest {
@Test
public void testRemoveResourcesByKeyTypeAndType() {
void testRemoveResourcesByKeyTypeAndType() {
//given
final Resource resource1 = mock(Resource.class);
final Resource resource2 = mock(Resource.class);
Expand Down Expand Up @@ -62,8 +62,7 @@ public void testRemoveResourcesByKeyTypeAndType() {
assertTrue(resources.containsKey("key1"));
}

public static class SWTResourcesRegistryTestable extends
SWTResourcesRegistry {
public static class SWTResourcesRegistryTestable extends SWTResourcesRegistry {
public SWTResourcesRegistryTestable() {
super(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,45 @@
package org.eclipse.e4.ui.css.swt.helpers;

import static org.eclipse.e4.ui.css.swt.helpers.CSSSWTColorHelper.getSWTColor;
import static org.junit.Assert.assertEquals;
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.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.w3c.dom.css.CSSValue;

public class CSSSWTColorHelperTest extends CSSSWTHelperTestCase {
private Display display;

@Before
@BeforeEach
public void setUp() {
display = Display.getDefault();
}

@Test
public void testGetSWTColor() {
void testGetSWTColor() {
Color result = getSWTColor(colorValue("red"), display);
assertNotNull(result);
Assertions.assertNotNull(result);
assertEquals(255, result.getRed());
assertEquals(0, result.getBlue());
assertEquals(0, result.getGreen());
}

@Test
public void testGetSWTColorWhenNotSupportedColorType() {
void testGetSWTColorWhenNotSupportedColorType() {
Color result = getSWTColor(colorValue("123213", CSSValue.CSS_CUSTOM),
display);

assertNull(result);
}

@Test
public void testGetSWTColorWhenInvalidColorValue() {
void testGetSWTColorWhenInvalidColorValue() {
Color result = getSWTColor(colorValue("asdsad12"), display);

assertNotNull(result);
Expand All @@ -62,7 +63,7 @@ public void testGetSWTColorWhenInvalidColorValue() {
}

@Test
public void testGetSWTColorWhenColorFromDefinition() {
void testGetSWTColorWhenColorFromDefinition() {
registerColorProviderWith("org.eclipse.jdt.debug.ui.InDeadlockColor", new RGB(0, 255, 0));

Color result = getSWTColor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
package org.eclipse.e4.ui.css.swt.helpers;

import static org.eclipse.e4.ui.css.swt.helpers.CSSSWTFontHelper.getFontData;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.junit.Test;
import org.junit.jupiter.api.Test;

public class CSSSWTFontHelperTest extends CSSSWTHelperTestCase {

@Test
public void testGetFontData() {
void testGetFontData() {
FontData result = getFontData(fontProperties("Times", 11, CSS_ITALIC, CSS_BOLD),
new FontData());

Expand All @@ -34,7 +34,7 @@ public void testGetFontData() {
}

@Test
public void testGetFontDataWithoutOldFont() {
void testGetFontDataWithoutOldFont() {
FontData result = getFontData(fontProperties("Times", 11, CSS_ITALIC, CSS_BOLD),
null);

Expand All @@ -44,7 +44,7 @@ public void testGetFontDataWithoutOldFont() {
}

@Test
public void testGetFontDataStyledFont() {
void testGetFontDataStyledFont() {
FontData result = getFontData(fontProperties("Times", 11, "normal", "normal"),
new FontData("Courier", 11, SWT.ITALIC | SWT.BOLD));

Expand All @@ -54,7 +54,7 @@ public void testGetFontDataStyledFont() {
}

@Test
public void testGetFontDataWhenMissingFamilyInCss() {
void testGetFontDataWhenMissingFamilyInCss() {
FontData result = getFontData(fontProperties(null, 11, CSS_ITALIC, CSS_BOLD),
new FontData("Courier", 5, SWT.NORMAL));

Expand All @@ -64,7 +64,7 @@ public void testGetFontDataWhenMissingFamilyInCss() {
}

@Test
public void testGetFontDataWhenMissingSizeInCss() {
void testGetFontDataWhenMissingSizeInCss() {
FontData result = getFontData(fontProperties("Arial", null, CSS_ITALIC, CSS_BOLD),
new FontData("Courier", 5, SWT.NORMAL));

Expand All @@ -74,7 +74,7 @@ public void testGetFontDataWhenMissingSizeInCss() {
}

@Test
public void testGetFontDataWhenMissingStyleInCss() {
void testGetFontDataWhenMissingStyleInCss() {
FontData result = getFontData(fontProperties("Times", 11, null, CSS_BOLD),
new FontData("Courier", 5, SWT.ITALIC));

Expand All @@ -84,7 +84,7 @@ public void testGetFontDataWhenMissingStyleInCss() {
}

@Test
public void testGetFontDataWhenMissingWeightInCss() {
void testGetFontDataWhenMissingWeightInCss() {
FontData result = getFontData(fontProperties("Times", 11, CSS_ITALIC, null),
new FontData("Courier", 5, SWT.BOLD));

Expand All @@ -94,7 +94,7 @@ public void testGetFontDataWhenMissingWeightInCss() {
}

@Test
public void testGetFontDataWhenMissingAllInCss() {
void testGetFontDataWhenMissingAllInCss() {
FontData result = getFontData(fontProperties(null, null, null, null),
new FontData("Courier", 11, SWT.ITALIC | SWT.BOLD));

Expand All @@ -104,7 +104,7 @@ public void testGetFontDataWhenMissingAllInCss() {
}

@Test
public void testGetFontDataWhenFontFamilyFromDefinitionAndOverwritingSize() {
void testGetFontDataWhenFontFamilyFromDefinitionAndOverwritingSize() {
registerFontProviderWith("org.eclipse.jface.bannerfont", "Arial", 15, SWT.ITALIC | SWT.BOLD);

FontData result = getFontData(
Expand All @@ -117,7 +117,7 @@ public void testGetFontDataWhenFontFamilyFromDefinitionAndOverwritingSize() {
}

@Test
public void testGetFontDataWhenFontFamilyFromDefinitionAndOverwritingStyle() {
void testGetFontDataWhenFontFamilyFromDefinitionAndOverwritingStyle() {
registerFontProviderWith("org.eclipse.jface.bannerfont", "Arial", 15, SWT.BOLD);

FontData result = getFontData(
Expand All @@ -130,7 +130,7 @@ public void testGetFontDataWhenFontFamilyFromDefinitionAndOverwritingStyle() {
}

@Test
public void testGetFontDataWhenFontFamilyFromDefinitionAndOverwritingWeight() {
void testGetFontDataWhenFontFamilyFromDefinitionAndOverwritingWeight() {
registerFontProviderWith("org.eclipse.jface.bannerfont", "Arial", 15, SWT.ITALIC);

FontData result = getFontData(
Expand All @@ -143,7 +143,7 @@ public void testGetFontDataWhenFontFamilyFromDefinitionAndOverwritingWeight() {
}

@Test
public void testGetFontDataFromFontDefinition() {
void testGetFontDataFromFontDefinition() {
registerFontProviderWith("org.eclipse.jface.bannerfont", "Arial", 15, SWT.ITALIC | SWT.BOLD);

FontData result = getFontData(
Expand Down
Loading

0 comments on commit d179e6e

Please sign in to comment.