diff options
| author | Lars Vogel | 2014-09-02 12:36:01 +0000 |
|---|---|---|
| committer | Lars Vogel | 2014-09-02 14:09:32 +0000 |
| commit | 82f2dc5766efb2fa01d83fbd72f3025e5356adfa (patch) | |
| tree | f4d03dc2a58f565c7ff173afd6bc5af677f20896 | |
| parent | cd4844fc84fb9b8871e11f222f8d541625d632f1 (diff) | |
| download | eclipse.platform.ui-82f2dc5766efb2fa01d83fbd72f3025e5356adfa.tar.gz eclipse.platform.ui-82f2dc5766efb2fa01d83fbd72f3025e5356adfa.tar.xz eclipse.platform.ui-82f2dc5766efb2fa01d83fbd72f3025e5356adfa.zip | |
Bug 430468 - [CSS] Move org.eclipse.e4.ui.tests.css.core tests to
JUnit 4
Change-Id: I2241df0283266108713d7ffa6a5484d4455fead6
Signed-off-by: Lars Vogel <Lars.Vogel@gmail.com>
14 files changed, 211 insertions, 147 deletions
diff --git a/tests/org.eclipse.e4.ui.tests.css.core/CSS Core Test Suite.launch b/tests/org.eclipse.e4.ui.tests.css.core/CSS Core Test Suite.launch index e5b06ba9b94..ea1f649162e 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/CSS Core Test Suite.launch +++ b/tests/org.eclipse.e4.ui.tests.css.core/CSS Core Test Suite.launch @@ -25,7 +25,7 @@ <stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/> <booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/> <stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/> -<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/> +<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/> <stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.e4.ui.tests.css.core.CssCoreTestSuite"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.e4.ui.tests.css.core"/> diff --git a/tests/org.eclipse.e4.ui.tests.css.core/META-INF/MANIFEST.MF b/tests/org.eclipse.e4.ui.tests.css.core/META-INF/MANIFEST.MF index 0eeb7bc21fa..0c687eb0a2a 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/META-INF/MANIFEST.MF +++ b/tests/org.eclipse.e4.ui.tests.css.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: e4 css core tests (Incubation) Bundle-SymbolicName: org.eclipse.e4.ui.tests.css.core -Bundle-Version: 0.9.0.qualifier +Bundle-Version: 1.0.0.qualifier Require-Bundle: org.eclipse.core.runtime, org.junit, org.eclipse.swt, diff --git a/tests/org.eclipse.e4.ui.tests.css.core/pom.xml b/tests/org.eclipse.e4.ui.tests.css.core/pom.xml index 223e1bf8660..a4b43e61665 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/pom.xml +++ b/tests/org.eclipse.e4.ui.tests.css.core/pom.xml @@ -18,7 +18,7 @@ </parent> <groupId>org.eclipse.e4</groupId> <artifactId>org.eclipse.e4.ui.tests.css.core</artifactId> - <version>0.9.0-SNAPSHOT</version> + <version>1.0.0-SNAPSHOT</version> <packaging>eclipse-test-plugin</packaging> </project> diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/CSSEngineTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/CSSEngineTest.java index bfd588cbf19..5eccf46582a 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/CSSEngineTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/CSSEngineTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. + * Copyright (c) 2013, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,27 +7,32 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 *******************************************************************************/ package org.eclipse.e4.ui.tests.css.core; -import java.util.Date; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; -import junit.framework.TestCase; +import java.util.Date; import org.eclipse.e4.ui.css.core.dom.IElementProvider; import org.eclipse.e4.ui.css.core.engine.CSSEngine; import org.eclipse.e4.ui.css.core.impl.engine.CSSEngineImpl; import org.eclipse.e4.ui.tests.css.core.util.TestElement; +import org.junit.Test; import org.w3c.css.sac.SelectorList; import org.w3c.dom.Element; -public class CSSEngineTest extends TestCase { +public class CSSEngineTest { + private static class TestCSSEngine extends CSSEngineImpl { @Override public void reapply() { } } + @Test public void testSelectorMatch() throws Exception { TestCSSEngine engine = new TestCSSEngine(); SelectorList list = engine.parseSelectors("Date"); diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/CssCoreTestSuite.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/CssCoreTestSuite.java index 144f2ee1d52..ddfd43a998a 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/CssCoreTestSuite.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/CssCoreTestSuite.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. + * Copyright (c) 2013, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,40 +7,36 @@ * * Contributors: * IBM Corporation - initial API and implementation - * Stefan Winkler <stefan@winklerweb.net> - Bug 430052 + * Stefan Winkler <stefan@winklerweb.net> - Bug 430052 + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 *******************************************************************************/ package org.eclipse.e4.ui.tests.css.core; -import junit.framework.Test; -import junit.framework.TestSuite; - import org.eclipse.e4.ui.tests.css.core.parser.CascadeTest; import org.eclipse.e4.ui.tests.css.core.parser.FontFaceRulesTest; import org.eclipse.e4.ui.tests.css.core.parser.ImportTest; +import org.eclipse.e4.ui.tests.css.core.parser.MediaRulesTest; import org.eclipse.e4.ui.tests.css.core.parser.RGBColorImplTest; import org.eclipse.e4.ui.tests.css.core.parser.SelectorTest; import org.eclipse.e4.ui.tests.css.core.parser.StyleRuleTest; import org.eclipse.e4.ui.tests.css.core.parser.ValueTest; import org.eclipse.e4.ui.tests.css.core.parser.ViewCSSTest; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; -public class CssCoreTestSuite extends TestSuite { - - public static Test suite() { - return new CssCoreTestSuite(); - } - - public CssCoreTestSuite() { - // $JUnit-BEGIN$ - addTestSuite(CascadeTest.class); - addTestSuite(FontFaceRulesTest.class); -// addTestSuite(MediaRulesTest.class); - addTestSuite(RGBColorImplTest.class); - addTestSuite(StyleRuleTest.class); - addTestSuite(ViewCSSTest.class); - addTestSuite(ValueTest.class); - addTestSuite(SelectorTest.class); - addTestSuite(CSSEngineTest.class); - addTestSuite(ImportTest.class); - // $JUnit-END$ - } +@RunWith(Suite.class) +@SuiteClasses({ + CascadeTest.class, + FontFaceRulesTest.class, + MediaRulesTest.class, + RGBColorImplTest.class, + StyleRuleTest.class, + ViewCSSTest.class, + ValueTest.class, + SelectorTest.class, + CSSEngineTest.class, + ImportTest.class +}) +public class CssCoreTestSuite { } 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 ac3da43461f..344829b6785 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 @@ -1,17 +1,18 @@ /******************************************************************************* - * Copyright (c) 2009 EclipseSource and others. All rights reserved. + * Copyright (c) 2009, 2014 EclipseSource and others. All rights reserved. * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * EclipseSource - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 ******************************************************************************/ package org.eclipse.e4.ui.tests.css.core.parser; -import java.io.IOException; +import static org.junit.Assert.assertEquals; -import junit.framework.TestCase; +import java.io.IOException; import org.eclipse.e4.ui.css.core.impl.dom.DocumentCSSImpl; import org.eclipse.e4.ui.css.core.impl.dom.ViewCSSImpl; @@ -19,26 +20,30 @@ import org.eclipse.e4.ui.css.swt.engine.CSSSWTEngineImpl; import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil; import org.eclipse.e4.ui.tests.css.core.util.TestElement; import org.eclipse.swt.widgets.Display; +import org.junit.Before; +import org.junit.Test; import org.w3c.dom.css.CSSStyleDeclaration; import org.w3c.dom.css.CSSStyleSheet; import org.w3c.dom.css.ViewCSS; -public class CascadeTest extends TestCase { +public class CascadeTest { private Display display; private CSSSWTEngineImpl engine; - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { display = Display.getDefault(); engine = new CSSSWTEngineImpl(display); } + @Test public void testPosition() throws Exception { // Two rules with the same specificity, the second rule should take // precedence because of its position in the stylesheet String css = "Button { color: blue; font-weight: bold; }\n" - + "Button { color: black }\n"; + + "Button { color: black }\n"; ViewCSS viewCSS = createViewCss(css); TestElement button = new TestElement("Button", engine); @@ -48,6 +53,7 @@ public class CascadeTest extends TestCase { .getCssText()); } + @Test public void testSpecificity() throws Exception { // Two rules with different specificity, the first should take // precedence because of its higher specificity @@ -66,13 +72,14 @@ public class CascadeTest extends TestCase { .getCssText()); } + @Test public void testSpecificities() throws Exception { // Different specificities String css = "* { color: black; }\n" - + "Button { color: blue; }\n" - + "Button[BORDER] { color: gray; }\n" - + "Button.special { color: green; }\n" - + "Button#myid { color: red; }\n"; + + "Button { color: blue; }\n" + + "Button[BORDER] { color: gray; }\n" + + "Button.special { color: green; }\n" + + "Button#myid { color: red; }\n"; ViewCSS viewCSS = createViewCss(css); TestElement label = new TestElement("Label", engine); @@ -102,27 +109,28 @@ public class CascadeTest extends TestCase { docCss.addStyleSheet(styleSheet); return new ViewCSSImpl(docCss); } - -// public void testImportantRule() throws Exception { -// //Several rules for the same class, if one rule has ! important -// //it takes precedence over all other, if more than one -// //last one gets precedence -// -// String css = "Button{color:red ! important;}\n" -// +"Button{ color: blue ! important;}\n" -// + "Button { color: black }\n"; -// ViewCSS viewCSS = createViewCss(css); -// -// TestElement button = new TestElement("Button", engine); -// CSSStyleDeclaration style = viewCSS.getComputedStyle(button, null); -// assertEquals("blue", style.getPropertyCSSValue("color").getCssText()); -// } - + + // public void testImportantRule() throws Exception { + // //Several rules for the same class, if one rule has ! important + // //it takes precedence over all other, if more than one + // //last one gets precedence + // + // String css = "Button{color:red ! important;}\n" + // +"Button{ color: blue ! important;}\n" + // + "Button { color: black }\n"; + // ViewCSS viewCSS = createViewCss(css); + // + // TestElement button = new TestElement("Button", engine); + // CSSStyleDeclaration style = viewCSS.getComputedStyle(button, null); + // assertEquals("blue", style.getPropertyCSSValue("color").getCssText()); + // } + + @Test public void testBug261081() throws Exception{ // Two rules with the same specificity, the second rule should take // precedence because of its position in the stylesheet String css = "Button, Label { color: blue; font-weight: bold; }\n" - + "Button { color: black }\n"; + + "Button { color: black }\n"; ViewCSS viewCSS = createViewCss(css); TestElement button = new TestElement("Button", engine); diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/FontFaceRulesTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/FontFaceRulesTest.java index 36bbe0e13be..479465f0059 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/FontFaceRulesTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/FontFaceRulesTest.java @@ -1,37 +1,42 @@ /******************************************************************************* - * Copyright (c) 2009 EclipseSource and others. All rights reserved. + * Copyright (c) 2009, 2014 EclipseSource and others. All rights reserved. * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * EclipseSource - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 ******************************************************************************/ package org.eclipse.e4.ui.tests.css.core.parser; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil; +import org.junit.Test; import org.w3c.dom.css.CSSStyleSheet; /** * Assert that <code>@font-face</code> rules are ignored. */ -public class FontFaceRulesTest extends TestCase { +public class FontFaceRulesTest { + @Test public void testEmptyFontFaceRule() throws Exception { String css = "@font-face {}\n" - + "Label { background-color: #FF0000 }"; + + "Label { background-color: #FF0000 }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); assertNotNull(styleSheet); assertEquals(1, styleSheet.getCssRules().getLength()); } + @Test public void testFontFaceRuleWithProperties() throws Exception { String css = "@font-face {\n" - + " font-family: \"Robson Celtic\";\n" - + " src: url(\"http://site/fonts/rob-celt\")\n" + "}\n" - + "Label { background-color: #FF0000 }"; + + " font-family: \"Robson Celtic\";\n" + + " src: url(\"http://site/fonts/rob-celt\")\n" + "}\n" + + "Label { background-color: #FF0000 }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); assertNotNull(styleSheet); assertEquals(1, styleSheet.getCssRules().getLength()); diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ImportTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ImportTest.java index ffa30d65e91..89a08e3f480 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ImportTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ImportTest.java @@ -6,32 +6,35 @@ * * Contributors: * Stefan Winkler <stefan@winklerweb.net> - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 ******************************************************************************/ package org.eclipse.e4.ui.tests.css.core.parser; +import static org.junit.Assert.assertEquals; + import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.StringReader; -import junit.framework.TestCase; - import org.eclipse.e4.ui.css.core.engine.CSSEngine; import org.eclipse.e4.ui.css.core.impl.dom.DocumentCSSImpl; import org.eclipse.e4.ui.css.core.impl.dom.ViewCSSImpl; import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil; import org.eclipse.e4.ui.tests.css.core.util.TestElement; +import org.junit.Before; +import org.junit.Test; import org.w3c.css.sac.InputSource; import org.w3c.dom.css.CSSStyleDeclaration; import org.w3c.dom.css.ViewCSS; import org.w3c.dom.stylesheets.StyleSheet; -public class ImportTest extends TestCase { +public class ImportTest { private CSSEngine engine; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() { engine = ParserTestUtil.createEngine(); } @@ -40,6 +43,7 @@ public class ImportTest extends TestCase { * * @throws Exception */ + @Test public void testOverrideImportedRule() throws Exception { String importedCss = ".ClassAlpha {\n" // + " property: value;\n" // diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/MediaRulesTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/MediaRulesTest.java index 2ca3ebeb33f..1366ba0444c 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/MediaRulesTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/MediaRulesTest.java @@ -1,34 +1,40 @@ /******************************************************************************* - * Copyright (c) 2009 EclipseSource and others. All rights reserved. + * Copyright (c) 2009, 2014 EclipseSource and others. All rights reserved. * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * EclipseSource - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 ******************************************************************************/ package org.eclipse.e4.ui.tests.css.core.parser; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil; +import org.junit.Ignore; +import org.junit.Test; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleSheet; /** * Assert that <code>@media</code> rules are ignored. */ -public class MediaRulesTest extends TestCase { +public class MediaRulesTest { + @Test + @Ignore("//THIS TEST KNOWN TO FAIL Dec 16/08") public void testMediaRule() throws Exception { String css = "@media screen, print {\n" - + "BODY { line-height: 1.2 }\n" - + "}\n" + "Label { background-color: #FF0000 }"; + + "BODY { line-height: 1.2 }\n" + + "}\n" + "Label { background-color: #FF0000 }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); assertNotNull(styleSheet); CSSRuleList rules = styleSheet.getCssRules(); - - //THIS TEST KNOWN TO FAIL Dec 16/08 + + assertEquals(1, rules.getLength()); } } diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/RGBColorImplTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/RGBColorImplTest.java index e297588263f..59c0a2b6080 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/RGBColorImplTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/RGBColorImplTest.java @@ -1,24 +1,28 @@ /******************************************************************************* - * Copyright (c) 2009 EclipseSource and others. All rights reserved. + * Copyright (c) 2009, 2014 EclipseSource and others. All rights reserved. * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * EclipseSource - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 ******************************************************************************/ package org.eclipse.e4.ui.tests.css.core.parser; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.eclipse.e4.ui.css.core.engine.CSSEngine; import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil; +import org.junit.Test; import org.w3c.dom.css.CSSValue; import org.w3c.dom.css.RGBColor; -public class RGBColorImplTest extends TestCase { +public class RGBColorImplTest { + @Test public void testGetCssText() throws Exception { CSSEngine engine = ParserTestUtil.createEngine(); CSSValue value = engine.parsePropertyValue("#FF8000"); @@ -29,10 +33,10 @@ public class RGBColorImplTest extends TestCase { // http://www.w3.org/TR/CSS21/syndata.html#value-def-color value = engine.parsePropertyValue("rgb( 300, -10, 42 )"); assertTrue( value instanceof RGBColor ); -// assertEquals( "rgb(255, 0, 42)", value.getCssText() ); + // assertEquals( "rgb(255, 0, 42)", value.getCssText() ); -// value = engine.parsePropertyValue("rgb( 110%, 50%, -10% )"); -// assertTrue( value instanceof RGBColor ); -// assertEquals( "rgb(100%, 50%, 0%)", value.getCssText() ); + // value = engine.parsePropertyValue("rgb( 110%, 50%, -10% )"); + // assertTrue( value instanceof RGBColor ); + // assertEquals( "rgb(100%, 50%, 0%)", value.getCssText() ); } } diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/SelectorTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/SelectorTest.java index c6d9d60d37c..6a01a11bd3b 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/SelectorTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/SelectorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2013 IBM Corporation and others. + * Copyright (c) 2013, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,25 +7,32 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 *******************************************************************************/ package org.eclipse.e4.ui.tests.css.core.parser; -import java.io.IOException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; -import junit.framework.TestCase; +import java.io.IOException; import org.eclipse.e4.ui.css.core.engine.CSSEngine; import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil; +import org.junit.Before; +import org.junit.Test; import org.w3c.css.sac.CSSParseException; import org.w3c.css.sac.SelectorList; -public class SelectorTest extends TestCase { +public class SelectorTest { private CSSEngine engine; - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { engine = ParserTestUtil.createEngine(); } + @Test public void testSimpleSelector() throws Exception { SelectorList list = engine.parseSelectors("Type1"); assertNotNull(list); @@ -33,6 +40,7 @@ public class SelectorTest extends TestCase { assertEquals("Type1", list.item(0).toString()); } + @Test public void testMultipleSelectors() throws Exception { SelectorList list = engine.parseSelectors("Type1, Type2"); assertNotNull(list); @@ -41,6 +49,7 @@ public class SelectorTest extends TestCase { assertEquals("Type2", list.item(1).toString()); } + @Test public void testClassSelector() throws Exception { SelectorList list = engine.parseSelectors(".Class1"); assertNotNull(list); @@ -48,6 +57,7 @@ public class SelectorTest extends TestCase { assertEquals("*[class=\"Class1\"]", list.item(0).toString()); } + @Test public void testAttributeSelector() throws Exception { SelectorList list = engine.parseSelectors("*[class='Class1']"); assertNotNull(list); @@ -55,6 +65,7 @@ public class SelectorTest extends TestCase { assertEquals("*[class=\"Class1\"]", list.item(0).toString()); } + @Test public void testErrorAttributeSelector() throws IOException { try { engine.parseSelectors("*[class='Class1'"); // missing ']' diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/StyleRuleTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/StyleRuleTest.java index c722f2473cb..0791670f501 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/StyleRuleTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/StyleRuleTest.java @@ -1,17 +1,21 @@ /******************************************************************************* - * Copyright (c) 2009 EclipseSource and others. All rights reserved. + * Copyright (c) 2009, 2014 EclipseSource and others. All rights reserved. * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * EclipseSource - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 ******************************************************************************/ package org.eclipse.e4.ui.tests.css.core.parser; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil; +import org.junit.Test; import org.w3c.dom.css.CSSPrimitiveValue; import org.w3c.dom.css.CSSRule; import org.w3c.dom.css.CSSRuleList; @@ -22,8 +26,9 @@ import org.w3c.dom.css.CSSValue; import org.w3c.dom.css.RGBColor; -public class StyleRuleTest extends TestCase { +public class StyleRuleTest { + @Test public void testSimpleStyleRule() throws Exception { String css = "Label { color: #FF0000 }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); @@ -34,6 +39,7 @@ public class StyleRuleTest extends TestCase { assertEquals(CSSRule.STYLE_RULE, rule.getType()); } + @Test public void testHexColor() throws Exception { String css = "Label { color: #FF0220 }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); @@ -52,6 +58,7 @@ public class StyleRuleTest extends TestCase { CSSPrimitiveValue.CSS_NUMBER), 0f); } + @Test public void testNamedColor() throws Exception { String css = "Label { color: green }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); @@ -65,6 +72,7 @@ public class StyleRuleTest extends TestCase { assertEquals("green", colorString); } + @Test public void testFont() throws Exception { String css = "Label { font: Verdana }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); @@ -77,7 +85,8 @@ public class StyleRuleTest extends TestCase { String colorString = ((CSSPrimitiveValue) value).getStringValue(); assertEquals("Verdana", colorString); } - + + @Test public void testTestFontItalic() throws Exception { String css = "Label { font: Arial 12px; font-style: italic }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); @@ -90,7 +99,8 @@ public class StyleRuleTest extends TestCase { String colorString = ((CSSPrimitiveValue) value).getStringValue(); assertEquals("italic", colorString); } - + + @Test public void testTestFontBold() throws Exception{ String css = "Label { font: Arial 12px; font-style: bold }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); @@ -103,8 +113,8 @@ public class StyleRuleTest extends TestCase { String colorString = ((CSSPrimitiveValue) value).getStringValue(); assertEquals("bold", colorString); } - - + + @Test public void testBackgroundNameColor() throws Exception{ String css = "Label { background-color: green }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); @@ -117,7 +127,8 @@ public class StyleRuleTest extends TestCase { String colorString = ((CSSPrimitiveValue) value).getStringValue(); assertEquals("green", colorString); } - + + @Test public void testBackgroundHexColor() throws Exception { String css = "Label { background-color: #FF0220 }"; CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ValueTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ValueTest.java index 9f01eb312cb..9133e99109d 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ValueTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ValueTest.java @@ -1,38 +1,45 @@ /******************************************************************************* - * Copyright (c) 2009, 2011 IBM Corporation and others. All rights reserved. This + * Copyright (c) 2009, 2014 IBM Corporation and others. All rights reserved. This * program and the accompanying materials are made available under the terms of * the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 *******************************************************************************/ package org.eclipse.e4.ui.tests.css.core.parser; -import junit.framework.TestCase; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import org.eclipse.e4.ui.css.core.engine.CSSEngine; import org.eclipse.e4.ui.css.core.impl.dom.Measure; import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil; +import org.junit.Before; +import org.junit.Test; import org.w3c.dom.css.CSSPrimitiveValue; import org.w3c.dom.css.CSSValue; import org.w3c.dom.css.CSSValueList; -public class ValueTest extends TestCase { +public class ValueTest { private CSSEngine engine; - protected void setUp() throws Exception { + @Before + public void setUp() { engine = ParserTestUtil.createEngine(); } - + + @Test public void testFloat() throws Exception { CSSValue value = engine.parsePropertyValue("2.0"); assertTrue(value instanceof Measure); assertEquals( "2.0", value.getCssText() ); } + @Test public void testInt() throws Exception { CSSValue value = engine.parsePropertyValue("34"); assertTrue(value instanceof Measure); @@ -40,6 +47,7 @@ public class ValueTest extends TestCase { assertEquals( "34", value.getCssText() ); } + @Test public void testIdentifier() throws Exception { CSSValue value = engine.parsePropertyValue("SomeWord"); assertTrue(value instanceof Measure); @@ -47,41 +55,47 @@ public class ValueTest extends TestCase { assertEquals( "SomeWord", value.getCssText() ); } + @Test public void testPercent() throws Exception { CSSValue value = engine.parsePropertyValue("30%"); assertTrue(value instanceof Measure); assertEquals(((Measure) value).getPrimitiveType(), CSSPrimitiveValue.CSS_PERCENTAGE); assertEquals( "30.0%", value.getCssText() ); } - + + @Test public void testPixel() throws Exception { CSSValue value = engine.parsePropertyValue("26px"); assertTrue(value instanceof Measure); assertEquals(((Measure) value).getPrimitiveType(), CSSPrimitiveValue.CSS_PX); assertEquals( "26.0px", value.getCssText() ); } - + + @Test public void testInch() throws Exception { CSSValue value = engine.parsePropertyValue("88in"); assertTrue(value instanceof Measure); assertEquals(((Measure) value).getPrimitiveType(), CSSPrimitiveValue.CSS_IN); assertEquals( "88.0in", value.getCssText() ); } - + + @Test public void testEm() throws Exception { CSSValue value = engine.parsePropertyValue("75em"); assertTrue(value instanceof Measure); assertEquals(((Measure) value).getPrimitiveType(), CSSPrimitiveValue.CSS_EMS); assertEquals( "75.0em", value.getCssText() ); } - + + @Test public void testURI() throws Exception { CSSValue value = engine.parsePropertyValue("url(./somepath/picture.gif)"); assertTrue(value instanceof Measure); assertEquals(((Measure) value).getPrimitiveType(), CSSPrimitiveValue.CSS_URI); assertEquals("url(./somepath/picture.gif)", value.getCssText()); } - + + @Test public void testList() throws Exception { CSSValue value = engine.parsePropertyValue("34 34 34"); assertTrue(value instanceof CSSValueList); @@ -100,6 +114,7 @@ public class ValueTest extends TestCase { assertEquals("34 34 34", value.getCssText()); } + @Test public void testCommaSeparatedList() throws Exception { CSSValue value = engine.parsePropertyValue("34, 34, 34"); assertTrue(value instanceof CSSValueList); diff --git a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ViewCSSTest.java b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ViewCSSTest.java index e6cc6c40d7f..903b4e8e726 100644 --- a/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ViewCSSTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/ViewCSSTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 EclipseSource and others. All rights reserved. + * Copyright (c) 2009, 2014 EclipseSource and others. All rights reserved. * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html @@ -7,12 +7,15 @@ * Contributors: * EclipseSource - initial API and implementation * Stefan Winkler <stefan@winklerweb.net> - Bug 419482 + * Lars Vogel <Lars.Vogel@gmail.com> - Bug 430468 ******************************************************************************/ package org.eclipse.e4.ui.tests.css.core.parser; -import java.io.IOException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; -import junit.framework.TestCase; +import java.io.IOException; import org.eclipse.e4.ui.css.core.impl.dom.DocumentCSSImpl; import org.eclipse.e4.ui.css.core.impl.dom.ViewCSSImpl; @@ -20,90 +23,86 @@ import org.eclipse.e4.ui.css.swt.engine.CSSSWTEngineImpl; import org.eclipse.e4.ui.tests.css.core.util.ParserTestUtil; import org.eclipse.e4.ui.tests.css.core.util.TestElement; import org.eclipse.swt.widgets.Display; +import org.junit.Before; +import org.junit.Test; import org.w3c.dom.css.CSSStyleDeclaration; import org.w3c.dom.css.CSSStyleSheet; import org.w3c.dom.css.ViewCSS; -public class ViewCSSTest extends TestCase { +public class ViewCSSTest { private Display display; private CSSSWTEngineImpl engine; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() { display = Display.getDefault(); engine = new CSSSWTEngineImpl(display); } + @Test public void testGetComputedStyle() throws Exception { // Two rules with the same specificity, the second rule should take // precedence because of its position in the stylesheet - String css = "Label { color: black; }" - + "Button { color: blue; font-weight: bold; }\n" + String css = "Label { color: black; }" + "Button { color: blue; font-weight: bold; }\n" + "Button { color: green; }\n"; ViewCSS viewCSS = createViewCss(css); TestElement shell = new TestElement("Shell", engine); CSSStyleDeclaration shellStyle = viewCSS.getComputedStyle(shell, null); - assertNull( shellStyle ); + assertNull(shellStyle); TestElement label = new TestElement("Label", engine); CSSStyleDeclaration labelStyle = viewCSS.getComputedStyle(label, null); - assertNotNull( labelStyle ); - assertEquals( 1, labelStyle.getLength() ); + assertNotNull(labelStyle); + assertEquals(1, labelStyle.getLength()); TestElement button = new TestElement("Button", engine); CSSStyleDeclaration buttonStyle = viewCSS.getComputedStyle(button, null); - assertNotNull( buttonStyle ); - assertEquals( 2, buttonStyle.getLength() ); + assertNotNull(buttonStyle); + assertEquals(2, buttonStyle.getLength()); } - public void testBug419482_order1() throws Exception - { - String css = "Shell > * > * { color: red; }\n" - + "Button { color: blue; }\n"; + @Test + public void testBug419482_order1() throws Exception { + String css = "Shell > * > * { color: red; }\n" + "Button { color: blue; }\n"; ViewCSS viewCSS = createViewCss(css); final TestElement shell = new TestElement("Shell", engine); - final TestElement composite = new TestElement("Composite", shell, - engine); + final TestElement composite = new TestElement("Composite", shell, engine); final TestElement button = new TestElement("Button", composite, engine); CSSStyleDeclaration buttonStyle = viewCSS.getComputedStyle(button, null); - assertNotNull( buttonStyle ); - assertEquals( 1, buttonStyle.getLength() ); + assertNotNull(buttonStyle); + assertEquals(1, buttonStyle.getLength()); assertEquals("color: blue;", buttonStyle.getCssText()); } + @Test public void testBug419482_order2() throws Exception { - String css = "Button { color: blue; }\n" - + "Shell > * > * { color: red; }\n"; + String css = "Button { color: blue; }\n" + "Shell > * > * { color: red; }\n"; ViewCSS viewCSS = createViewCss(css); final TestElement shell = new TestElement("Shell", engine); - final TestElement composite = new TestElement("Composite", shell, - engine); + final TestElement composite = new TestElement("Composite", shell, engine); final TestElement button = new TestElement("Button", composite, engine); - CSSStyleDeclaration buttonStyle = viewCSS - .getComputedStyle(button, null); + CSSStyleDeclaration buttonStyle = viewCSS.getComputedStyle(button, null); assertNotNull(buttonStyle); assertEquals(1, buttonStyle.getLength()); assertEquals("color: red;", buttonStyle.getCssText()); } + @Test public void testBug419482_higherSpecificity() throws Exception { - String css = "Shell > * > Button { color: blue; }\n" - + "Shell > * > * { color: red; }\n"; + String css = "Shell > * > Button { color: blue; }\n" + "Shell > * > * { color: red; }\n"; ViewCSS viewCSS = createViewCss(css); final TestElement shell = new TestElement("Shell", engine); - final TestElement composite = new TestElement("Composite", shell, - engine); + final TestElement composite = new TestElement("Composite", shell, engine); final TestElement button = new TestElement("Button", composite, engine); - CSSStyleDeclaration buttonStyle = viewCSS - .getComputedStyle(button, null); + CSSStyleDeclaration buttonStyle = viewCSS.getComputedStyle(button, null); assertNotNull(buttonStyle); assertEquals(1, buttonStyle.getLength()); assertEquals("color: blue;", buttonStyle.getCssText()); |
