Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-04-02 10:07:26 -0400
committerLars Vogel2019-04-16 05:21:47 -0400
commit2fc5cb27e8492e4d3b1a2a95be8e521d9706b08f (patch)
treea06c5582e0d92a04ec11e5ba923bbbf39e3eb90b
parent289aa70e87506a076e6382b229a38a281a52a1de (diff)
downloadeclipse.platform.ui-2fc5cb27e8492e4d3b1a2a95be8e521d9706b08f.tar.gz
eclipse.platform.ui-2fc5cb27e8492e4d3b1a2a95be8e521d9706b08f.tar.xz
eclipse.platform.ui-2fc5cb27e8492e4d3b1a2a95be8e521d9706b08f.zip
Bug 539661 - Adds Unit test for classes and Ids priority
Change-Id: Iac62b3a99dfb602b37cb4d3c5e40de82f0e4642f Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
-rw-r--r--tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/CascadeTest.java45
1 files changed, 43 insertions, 2 deletions
diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/CascadeTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/CascadeTest.java
index e48130ec8b..a964c6d7b5 100644
--- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/CascadeTest.java
+++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/CascadeTest.java
@@ -30,6 +30,20 @@ import org.w3c.dom.css.CSSStyleDeclaration;
import org.w3c.dom.css.CSSStyleSheet;
import org.w3c.dom.css.ViewCSS;
+/**
+ * Test to ensure the that CSS honors the CSS cascading rules, i.e.:
+ *
+ * <p>
+ * !important after CSS properties.
+ * </p>
+ * <p>
+ * Specificity of CSS rule selectors
+ * </p>
+ * <p>
+ * Sequence of declaration.
+ * </p>
+ *
+ **/
public class CascadeTest {
@@ -53,8 +67,7 @@ public class CascadeTest {
TestElement button = new TestElement("Button", engine);
CSSStyleDeclaration style = viewCSS.getComputedStyle(button, null);
assertEquals("black", style.getPropertyCSSValue("color").getCssText());
- assertEquals("bold", style.getPropertyCSSValue("font-weight")
- .getCssText());
+ assertEquals("bold", style.getPropertyCSSValue("font-weight").getCssText());
}
@Test
@@ -77,6 +90,34 @@ public class CascadeTest {
}
@Test
+ public void ensureThatClassAndIdareConsideredIfOnTheSameLevel() throws Exception {
+ // Rules for elements with children. The first should take
+ // precedence because of its higher specificity
+ String css = "CTabFolder > Composite > Toolbar { color: black; }\n"
+ + "CTabFolder > Composite > .special { color: blue; font-weight: bold; }\n"
+ + "CTabFolder > Composite > #special { color: red; font-weight: bold; }\n";
+ ViewCSS viewCSS = createViewCss(css);
+
+ TestElement tabFolder = new TestElement("CTabFolder", engine);
+ TestElement composite = new TestElement("Composite", tabFolder, engine);
+ TestElement toolbar = new TestElement("Toolbar", composite, engine);
+
+ CSSStyleDeclaration style = viewCSS.getComputedStyle(toolbar, null);
+ assertEquals("black", style.getPropertyCSSValue("color").getCssText());
+
+ toolbar.setClass("special");
+ style = viewCSS.getComputedStyle(toolbar, null);
+ assertEquals("blue", style.getPropertyCSSValue("color").getCssText());
+
+ toolbar.setId("special");
+ style = viewCSS.getComputedStyle(toolbar, null);
+ assertEquals("red", style.getPropertyCSSValue("color").getCssText());
+
+ }
+
+
+
+ @Test
public void testSpecificities() throws Exception {
// Different specificities
String css = "* { color: black; }\n"

Back to the top