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
1 change: 1 addition & 0 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 @@ -13,6 +13,7 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-21
Import-Package: org.eclipse.core.runtime;version="3.5.0",
org.junit.jupiter.api;version="[5.14.0,6.0.0)",
org.junit.jupiter.api.extension;version="[5.14.0,6.0.0)",
org.junit.jupiter.api.function;version="[5.14.0,6.0.0)",
org.junit.platform.suite.api;version="[1.14.0,2.0.0)",
org.osgi.framework;version="[1.7.0,2.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,31 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import org.eclipse.e4.ui.tests.css.swt.CSSSWTTestCase;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.tests.css.swt.CssSwtEngine;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.ToggleHyperlink;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class ExpandableCompositeTest extends CSSSWTTestCase {
public class ExpandableCompositeTest {

@RegisterExtension
CssSwtEngine css = new CssSwtEngine();

static final RGB RED = new RGB(255, 0, 0);
static final RGB GREEN = new RGB(0, 255, 0);
static final RGB BLUE = new RGB(0, 0, 255);

protected ExpandableComposite createTestExpandableComposite(String styleSheet) {
engine = createEngine(styleSheet, display);
Display display = css.getDisplay();
CSSEngine engine = css.createEngine(styleSheet);

// Create widgets
Shell shell = new Shell(display, SWT.SHELL_TRIM);
Expand Down Expand Up @@ -76,7 +83,7 @@ void testExpandableComposite_foregroundColorGetsReset_foregroundCollorIsNull() t
assertNotNull(compositeToTest.getTitleBarForeground());
assertEquals(RED, compositeToTest.getTitleBarForeground().getRGB());

engine.reset();
css.getEngine().reset();

assertNull(compositeToTest.getTitleBarForeground());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,32 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import org.eclipse.e4.ui.tests.css.swt.CSSSWTTestCase;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.tests.css.swt.CssSwtEngine;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.ToggleHyperlink;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class SectionTest extends CSSSWTTestCase {
public class SectionTest {

@RegisterExtension
CssSwtEngine css = new CssSwtEngine();

static final RGB RED = new RGB(255, 0, 0);
static final RGB GREEN = new RGB(0, 255, 0);
static final RGB BLUE = new RGB(0, 0, 255);

protected Section createTestSection(String styleSheet) {
engine = createEngine(styleSheet, display);
Display display = css.getDisplay();
CSSEngine engine = css.createEngine(styleSheet);

// Create widgets
Shell shell = new Shell(display, SWT.SHELL_TRIM);
Expand Down Expand Up @@ -91,7 +98,7 @@ void testSectionResetColors() throws Exception {
background-color-titlebar: #0000FF; \
border-color-titlebar: #00FF00}""");

engine.reset();
css.getEngine().reset();

assertNull(section.getTitleBarForeground());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

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

import org.eclipse.e4.ui.tests.css.swt.CSSSWTTestCase;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.tests.css.swt.CssSwtEngine;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
Expand All @@ -22,12 +23,17 @@
import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class TabbedPropertiesListTest extends CSSSWTTestCase {
public class TabbedPropertiesListTest {

@RegisterExtension
CssSwtEngine css = new CssSwtEngine();

static final RGB RED = new RGB(255, 0, 0);
private TabbedPropertySheetWidgetFactory factory;
private Shell shell;
private CSSEngine engine;


private TabbedPropertyList createTabbedPropertiesList(String stylesheet) {
Expand All @@ -37,9 +43,9 @@ private TabbedPropertyList createTabbedPropertiesList(String stylesheet) {
} else {
s = stylesheet;
}
engine = createEngine(s, display);
engine = css.createEngine(s);

shell = new Shell(display, SWT.SHELL_TRIM);
shell = new Shell(css.getDisplay(), SWT.SHELL_TRIM);
FillLayout layout = new FillLayout();
shell.setLayout(layout);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,23 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.eclipse.e4.ui.tests.css.swt.CSSSWTTestCase;
import org.eclipse.e4.ui.tests.css.swt.CssSwtEngine;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyTitle;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class TabbedPropertiesTitleTest extends CSSSWTTestCase {
public class TabbedPropertiesTitleTest {

@RegisterExtension
CssSwtEngine css = new CssSwtEngine();

static final RGB RED = new RGB(255, 0, 0);
private TabbedPropertySheetWidgetFactory factory;
Expand All @@ -39,9 +44,8 @@ private TabbedPropertyTitle createTabbedPropertiesTitle(String stylesheet) {
} else {
s = stylesheet;
}
engine = createEngine(
s,
display);
Display display = css.getDisplay();
css.createEngine(s);

shell = new Shell(display, SWT.SHELL_TRIM);
FillLayout layout = new FillLayout();
Expand All @@ -66,7 +70,7 @@ private void assertColor(RGB expected, String actualKey){
void titleBackgroundColorIsStyled() {
createTabbedPropertiesTitle(null);

engine.applyStyles(shell, true);
css.getEngine().applyStyles(shell, true);

assertColor(RED, IFormColors.H_GRADIENT_START);
assertColor(RED, IFormColors.H_GRADIENT_END);
Expand All @@ -83,8 +87,8 @@ void titleBackgroundColorIsStyledAndReset() {
RGB colorBottomKeylineOneBeforStyling = factory.getColors().getColor(IFormColors.H_BOTTOM_KEYLINE1).getRGB();
RGB colorBottomKeylineTwoBeforStyling = factory.getColors().getColor(IFormColors.H_BOTTOM_KEYLINE2).getRGB();

engine.applyStyles(shell, true);
engine.reset();
css.getEngine().applyStyles(shell, true);
css.getEngine().reset();
assertColor(colorGradStartBeforStyling, IFormColors.H_GRADIENT_START);
assertColor(colorGradEndBeforStyling, IFormColors.H_GRADIENT_END);
assertColor(colorBottomKeylineOneBeforStyling, IFormColors.H_BOTTOM_KEYLINE1);
Expand All @@ -101,7 +105,7 @@ void colorsAreNotChangedWhenNoStyleGivenInCss() {
RGB colorBottomKeylineOneBeforStyling = factory.getColors().getColor(IFormColors.H_BOTTOM_KEYLINE1).getRGB();
RGB colorBottomKeylineTwoBeforStyling = factory.getColors().getColor(IFormColors.H_BOTTOM_KEYLINE2).getRGB();

engine.applyStyles(shell, true);
css.getEngine().applyStyles(shell, true);
assertColor(colorGradStartBeforStyling, IFormColors.H_GRADIENT_START);
assertColor(colorGradEndBeforStyling, IFormColors.H_GRADIENT_END);
assertColor(colorBottomKeylineOneBeforStyling, IFormColors.H_BOTTOM_KEYLINE1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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

import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.RowLayout;
Expand All @@ -25,8 +26,12 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolBar;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class Bug419482Test extends CSSSWTTestCase {
public class Bug419482Test {

@RegisterExtension
CssSwtEngine css = new CssSwtEngine();

private static final RGB RGB_BLUE = new RGB(0, 0, 255);
private static final RGB RGB_RED = new RGB(255, 0, 0);
Expand All @@ -39,7 +44,7 @@ public class Bug419482Test extends CSSSWTTestCase {
void testTwoLevelsWildcard() {
String cssString = "Shell > * > * { color: red; } \n" + "Label { color: blue; }";

Label label = createTestLabel(cssString);
Label label = css.createTestLabel(cssString);

RGB rgb = label.getForeground().getRGB();
assertEquals(RGB_BLUE, rgb);
Expand All @@ -49,7 +54,7 @@ void testTwoLevelsWildcard() {
void testOneLevelWildcardOneSpecific() {
String cssString = "Shell > * > Label { color: red; } \n" + "Label { color: blue; }";

Label label = createTestLabel(cssString);
Label label = css.createTestLabel(cssString);

RGB rgb = label.getForeground().getRGB();
assertEquals(RGB_RED, rgb);
Expand All @@ -59,7 +64,7 @@ void testOneLevelWildcardOneSpecific() {
void testDescendentsWildcard() {
String cssString = "Shell * { color: red; } \n" + "Label { color: blue; }";

Label label = createTestLabel(cssString);
Label label = css.createTestLabel(cssString);

RGB rgb = label.getForeground().getRGB();
assertEquals(RGB_BLUE, rgb);
Expand All @@ -69,25 +74,25 @@ void testDescendentsWildcard() {
void testDescendentsSpecific() {
String cssString = "Shell Label { color: red; } \n" + "Label { color: blue; }";

Label label = createTestLabel(cssString);
Label label = css.createTestLabel(cssString);

RGB rgb = label.getForeground().getRGB();
assertEquals(RGB_RED, rgb);
}

@Test
void testOriginalBugReport() {
String css = """
String cssString = """
Shell, Shell > *, Shell > * > * {
background-color: red;
}
ToolBar {
background-color: blue;
}""";

engine = createEngine(css, display);
CSSEngine engine = css.createEngine(cssString);

Shell shell = createShellWithToolbars(display);
Shell shell = createShellWithToolbars(css.getDisplay());

// Apply styles
engine.applyStyles(shell, true);
Expand All @@ -99,7 +104,7 @@ void testOriginalBugReport() {

@Test
void testOriginalBugReportDifferentOrder() {
String css = """
String cssString = """
ToolBar {
background-color: blue;
}\
Expand All @@ -108,10 +113,10 @@ void testOriginalBugReportDifferentOrder() {
}
""";

engine = createEngine(css, display);
CSSEngine engine = css.createEngine(cssString);

// Create widgets
Shell shell = createShellWithToolbars(display);
Shell shell = createShellWithToolbars(css.getDisplay());

// Apply styles
engine.applyStyles(shell, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class Bug459961Test extends CSSSWTTestCase {
public class Bug459961Test {

@RegisterExtension
CssSwtEngine css = new CssSwtEngine();

@Test
void testRegularColorConstantReference() {
String cssString = "Label { background-color: COLOR-GREEN; }";

Label label = createTestLabel(cssString);
Label label = css.createTestLabel(cssString);

RGBA expected = Display.getDefault().getSystemColor(SWT.COLOR_GREEN).getRGBA();
RGBA actual = label.getBackground().getRGBA();
Expand All @@ -38,7 +42,7 @@ void testRegularColorConstantReference() {
void testTransparentColorConstantReference() {
String cssString = "Label { background-color: COLOR-TRANSPARENT; }";

Label label = createTestLabel(cssString);
Label label = css.createTestLabel(cssString);

RGBA expected = Display.getDefault().getSystemColor(SWT.COLOR_TRANSPARENT).getRGBA();
RGBA actual = label.getBackground().getRGBA();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,32 @@
*******************************************************************************/
package org.eclipse.e4.ui.tests.css.swt;

import static org.eclipse.e4.ui.tests.css.swt.CssSwtEngine.BLUE;
import static org.eclipse.e4.ui.tests.css.swt.CssSwtEngine.RED;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class ButtonTest extends CSSSWTTestCase {
public class ButtonTest {

@RegisterExtension
CssSwtEngine css = new CssSwtEngine();

protected Button createTestButton(String styleSheet, int buttonStyle) {
engine = createEngine(styleSheet, display);
Display display = css.getDisplay();
CSSEngine engine = css.createEngine(styleSheet);

// Create widgets
Shell shell = new Shell(display, SWT.SHELL_TRIM);
Expand Down Expand Up @@ -102,7 +111,7 @@ void testSelectedPseudo() {
SWT.CHECK);
assertEquals(RED, buttonToTest.getForeground().getRGB());
buttonToTest.setSelection(true);
engine.applyStyles(buttonToTest.getShell(), true);
css.getEngine().applyStyles(buttonToTest.getShell(), true);
assertEquals(BLUE, buttonToTest.getForeground().getRGB());
}

Expand Down
Loading
Loading