Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable tests #1389

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public boolean isPseudoInstanceOf(String s) {
if ("checked".equalsIgnoreCase(s)) {
return this.isSelected;
}
if ("selected".equalsIgnoreCase(s)) {
return this.isSelected;
}
fedejeanne marked this conversation as resolved.
Show resolved Hide resolved
return super.isPseudoInstanceOf(s);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/org.eclipse.e4.ui.tests.css.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Export-Package: org.eclipse.e4.ui.tests.css.core;x-internal:=true,
Automatic-Module-Name: org.eclipse.e4.ui.tests.css.core
Import-Package: org.junit.jupiter.api,
org.junit.platform.suite.api,
org.w3c.css.sac;version="1.3.0"
org.w3c.css.sac;version="1.3.0",
org.assertj.core.api;version="3.24.2"
Bundle-Vendor: %Bundle-Vendor

Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
******************************************************************************/
package org.eclipse.e4.ui.tests.css.core.parser;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.stream.IntStream;
import java.util.stream.Stream;

import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.w3c.dom.css.CSSRuleList;
import org.w3c.dom.css.CSSStyleSheet;

/**
Expand All @@ -29,18 +30,30 @@
public class MediaRulesTest {

@Test
@Disabled("//THIS TEST KNOWN TO FAIL Dec 16/08")
void testMediaRule() throws Exception {
String css = """
@media screen, print {
BODY { line-height: 1.2 }
}
Label { background-color: #FF0000 }""";
@media screen, print {
BODY { line-height: 1.2 }
Label { background-color: #FFFFFF }
}
BODY { line-height: 1.3 }

@media screen, print {
BODY { line-height: 1.4 }
}
""";
CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css);
assertNotNull(styleSheet);
CSSRuleList rules = styleSheet.getCssRules();

// This one is provided only inside the @media so it shouldn't be there
assertThat(findCssRuleThatContains(styleSheet, "background-color")).isEmpty();
// This one is provided outside the @media and it shouldn't be overwritten by
// any of them
assertThat(findCssRuleThatContains(styleSheet, "line-height")).containsOnly("BODY { line-height: 1.3; }");
}

assertEquals(1, rules.getLength());
private Stream<String> findCssRuleThatContains(CSSStyleSheet styleSheet, String text) {
Stream<String> cssRulesText = IntStream.range(0, styleSheet.getCssRules().getLength())
.mapToObj(i -> styleSheet.getCssRules().item(i).getCssText());
return cssRulesText.filter(r -> r.contains(text));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

public class ButtonTest extends CSSSWTTestCase {
Expand All @@ -45,7 +45,7 @@ protected Button createTestButton(String styleSheet, int buttonStyle) {
buttonToTest.setText("Some button text");

// Apply styles
engine.applyStyles(shell, true);
engine.applyStyles(buttonToTest, true);

shell.pack();
return buttonToTest;
Expand Down Expand Up @@ -95,14 +95,13 @@ void testFontItalic() {
assertEquals(SWT.ITALIC, fontData.getStyle());
}

@Disabled
@Test
void testSelectedPseudo() {
Button buttonToTest = createTestButton("Button { color: #FF0000; }\n" + "Button:selected { color: #0000FF; }",
SWT.CHECK);
assertEquals(RED, buttonToTest.getForeground().getRGB());
buttonToTest.setSelection(true);
engine.applyStyles(buttonToTest.getShell(), true);
buttonToTest.notifyListeners(SWT.Selection, new Event());
assertEquals(BLUE, buttonToTest.getForeground().getRGB());
}

Expand Down
Loading