diff options
Diffstat (limited to 'tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/DescendentTest.java')
-rw-r--r-- | tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/DescendentTest.java | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/DescendentTest.java b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/DescendentTest.java index 2fd7a334cad..5835d8528c0 100644 --- a/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/DescendentTest.java +++ b/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/DescendentTest.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,31 +7,31 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Thibault Le Ouay <thibaultleouay@gmail.com> - Bug 443094 *******************************************************************************/ package org.eclipse.e4.ui.tests.css.swt; -import org.eclipse.e4.ui.css.core.engine.CSSEngine; +import static org.junit.Assert.assertEquals; + import org.eclipse.e4.ui.css.swt.dom.WidgetElement; import org.eclipse.swt.SWT; 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.Test; public class DescendentTest extends CSSSWTTestCase { - + 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); static final RGB WHITE = new RGB(255, 255, 255); static final RGB BLACK = new RGB(0, 0, 0); - static public CSSEngine engine; - + protected Button[] createTestWidgets(String styleSheet) { - Display display = Display.getDefault(); engine = createEngine(styleSheet, display); // Create widgets @@ -50,29 +50,30 @@ public class DescendentTest extends CSSSWTTestCase { engine.applyStyles(shell, true); return new Button[] {buttonA, buttonB, buttonC}; } - - public void testDescendentSpecificity() throws Exception { + + @Test + public void testDescendentSpecificity() { Button[] buttons = createTestWidgets( "Composite.special Button { background: #FF0000}\n" + //specificity a=1 b=0 c=1 = 101 - "Composite Button { background: #00FF00}\n" + //specificity a=0 b=0 c=2 = 002 - "Composite.extraordinary Button { background: #FFFFFF}\n" + //specificity a=0 b=0 c=2 = 002 - "#parent Button { background: #000000}\n" + //specificity a=0 b=0 c=2 = 002 + "Composite Button { background: #00FF00}\n" + //specificity a=0 b=0 c=2 = 002 + "Composite.extraordinary Button { background: #FFFFFF}\n" + //specificity a=0 b=0 c=2 = 002 + "#parent Button { background: #000000}\n" + //specificity a=0 b=0 c=2 = 002 "Button { background: #0000FF}"); //specificity a=0 b=0 c=1 = 001 - + Button buttonA = buttons[0]; Button buttonB = buttons[1]; Button buttonC = buttons[2]; - + WidgetElement.setCSSClass(buttonA.getParent(), "special"); engine.applyStyles(buttonA.getShell(), true); - + assertEquals(RED, buttonA.getBackground().getRGB()); assertEquals(GREEN, buttonB.getBackground().getRGB()); assertEquals(BLUE, buttonC.getBackground().getRGB()); - + WidgetElement.setCSSClass(buttonA.getParent(), "extraordinary"); WidgetElement.setID(buttonB.getParent(), "parent"); - + engine.applyStyles(buttonA.getShell(), true); assertEquals(WHITE, buttonA.getBackground().getRGB()); assertEquals(BLACK, buttonB.getBackground().getRGB()); |