Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 125559 Details for
Bug 263081
[CSS] Need cascading order tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
updated CSS junits
tests_patch.txt (text/plain), 31.21 KB, created by
Aghiles Abdesselam
on 2009-02-12 14:07:05 EST
(
hide
)
Description:
updated CSS junits
Filename:
MIME Type:
Creator:
Aghiles Abdesselam
Created:
2009-02-12 14:07:05 EST
Size:
31.21 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.e4.ui.tests.css.core >Index: src/org/eclipse/e4/ui/tests/css/core/parser/CascadeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/CascadeTest.java,v >retrieving revision 1.1 >diff -u -r1.1 CascadeTest.java >--- src/org/eclipse/e4/ui/tests/css/core/parser/CascadeTest.java 31 Jan 2009 21:38:19 -0000 1.1 >+++ src/org/eclipse/e4/ui/tests/css/core/parser/CascadeTest.java 12 Feb 2009 19:06:33 -0000 >@@ -44,8 +44,7 @@ > 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()); > } > > public void testSpecificity() throws Exception { >@@ -95,6 +94,34 @@ > style = viewCSS.getComputedStyle(button, null); > assertEquals("red", 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()); >+ } >+ >+ 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"; >+ ViewCSS viewCSS = createViewCss(css); >+ >+ 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()); >+ } > > private static ViewCSS createViewCss(String css) throws IOException { > CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); >Index: src/org/eclipse/e4/ui/tests/css/core/parser/StyleRuleTest.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests.css.core/src/org/eclipse/e4/ui/tests/css/core/parser/StyleRuleTest.java,v >retrieving revision 1.2 >diff -u -r1.2 StyleRuleTest.java >--- src/org/eclipse/e4/ui/tests/css/core/parser/StyleRuleTest.java 31 Jan 2009 21:38:19 -0000 1.2 >+++ src/org/eclipse/e4/ui/tests/css/core/parser/StyleRuleTest.java 12 Feb 2009 19:06:33 -0000 >@@ -77,4 +77,62 @@ > String colorString = ((CSSPrimitiveValue) value).getStringValue(); > assertEquals("Verdana", colorString); > } >+ >+ public void testTestFontItalic() throws Exception { >+ String css = "Label { font: Arial 12px; font-style: italic }"; >+ CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); >+ CSSRuleList rules = styleSheet.getCssRules(); >+ CSSRule rule = rules.item(0); >+ assertEquals(CSSRule.STYLE_RULE, rule.getType()); >+ CSSStyleDeclaration style = ((CSSStyleRule) rule).getStyle(); >+ CSSValue value = style.getPropertyCSSValue("font-style"); >+ assertTrue(value instanceof CSSPrimitiveValue); >+ String colorString = ((CSSPrimitiveValue) value).getStringValue(); >+ assertEquals("italic", colorString); >+ } >+ >+ public void testTestFontBold() throws Exception{ >+ String css = "Label { font: Arial 12px; font-style: bold }"; >+ CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); >+ CSSRuleList rules = styleSheet.getCssRules(); >+ CSSRule rule = rules.item(0); >+ assertEquals(CSSRule.STYLE_RULE, rule.getType()); >+ CSSStyleDeclaration style = ((CSSStyleRule) rule).getStyle(); >+ CSSValue value = style.getPropertyCSSValue("font-style"); >+ assertTrue(value instanceof CSSPrimitiveValue); >+ String colorString = ((CSSPrimitiveValue) value).getStringValue(); >+ assertEquals("bold", colorString); >+ } >+ >+ >+ public void testBackgroundNameColor() throws Exception{ >+ String css = "Label { background-color: green }"; >+ CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); >+ CSSRuleList rules = styleSheet.getCssRules(); >+ CSSRule rule = rules.item(0); >+ assertEquals(CSSRule.STYLE_RULE, rule.getType()); >+ CSSStyleDeclaration style = ((CSSStyleRule) rule).getStyle(); >+ CSSValue value = style.getPropertyCSSValue("background-color"); >+ assertTrue(value instanceof CSSPrimitiveValue); >+ String colorString = ((CSSPrimitiveValue) value).getStringValue(); >+ assertEquals("green", colorString); >+ } >+ >+ public void testBackgroundHexColor() throws Exception { >+ String css = "Label { background-color: #FF0220 }"; >+ CSSStyleSheet styleSheet = ParserTestUtil.parseCss(css); >+ CSSRuleList rules = styleSheet.getCssRules(); >+ CSSRule rule = rules.item(0); >+ assertEquals(CSSRule.STYLE_RULE, rule.getType()); >+ CSSStyleDeclaration style = ((CSSStyleRule) rule).getStyle(); >+ CSSValue value = style.getPropertyCSSValue("background-color"); >+ assertTrue(value instanceof CSSPrimitiveValue); >+ RGBColor colorValue = ((CSSPrimitiveValue) value).getRGBColorValue(); >+ assertEquals(255.0f, colorValue.getRed().getFloatValue( >+ CSSPrimitiveValue.CSS_NUMBER), 0f); >+ assertEquals(2.0f, colorValue.getGreen().getFloatValue( >+ CSSPrimitiveValue.CSS_NUMBER), 0f); >+ assertEquals(32.0f, colorValue.getBlue().getFloatValue( >+ CSSPrimitiveValue.CSS_NUMBER), 0f); >+ } > } >#P org.eclipse.e4.ui.tests.css.swt >Index: src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java,v >retrieving revision 1.3 >diff -u -r1.3 CTabFolderTest.java >--- src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java 17 Dec 2008 06:31:08 -0000 1.3 >+++ src/org/eclipse/e4/ui/tests/css/swt/CTabFolderTest.java 12 Feb 2009 19:06:34 -0000 >@@ -4,6 +4,7 @@ > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.CTabFolder; > import org.eclipse.swt.custom.CTabItem; >+import org.eclipse.swt.graphics.FontData; > import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.layout.FillLayout; > import org.eclipse.swt.widgets.Composite; >@@ -30,13 +31,14 @@ > > CTabFolder folderToTest = new CTabFolder(panel, SWT.NONE); > CTabItem tab1 = new CTabItem(folderToTest, SWT.NONE); >- tab1.setText("A TAB ITEM"); > > engine.applyStyles(shell, true); > > shell.pack(); > shell.open(); > return folderToTest; >+ >+ > } > > public void testBackgroundColor() throws Exception { >@@ -50,6 +52,36 @@ > assertEquals(BLUE, folderToTest.getForeground().getRGB()); > folderToTest.getShell().close(); > } >+ >+ public void testFontRegular() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("Label { font: Verdana 16px }"); >+ assertEquals(1, folderToTest.getFont().getFontData().length); >+ FontData fontData = folderToTest.getFont().getFontData()[0]; >+ assertEquals("Verdana", fontData.getName()); >+ assertEquals(16, fontData.getHeight()); >+ assertEquals(SWT.NORMAL, fontData.getStyle()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testFontBold() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("Label { font: Arial 12px; font-weight: bold }"); >+ assertEquals(1, folderToTest.getFont().getFontData().length); >+ FontData fontData = folderToTest.getFont().getFontData()[0]; >+ assertEquals("Arial", fontData.getName()); >+ assertEquals(12, fontData.getHeight()); >+ assertEquals(SWT.BOLD, fontData.getStyle()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testFontItalic() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("Label { font: Arial 12px; font-style: italic }"); >+ assertEquals(1, folderToTest.getFont().getFontData().length); >+ FontData fontData = folderToTest.getFont().getFontData()[0]; >+ assertEquals("Arial", fontData.getName()); >+ assertEquals(12, fontData.getHeight()); >+ assertEquals(SWT.ITALIC, fontData.getStyle()); >+ folderToTest.getShell().close(); >+ } > > // public void testGradientColor() throws Exception { > // CTabFolder folderToTest = createTestCTabFolder("CTabFolder { background-color: #FF0000 #0000FF }"); >@@ -67,4 +99,94 @@ > assertEquals(GREEN, folderToTest.getSelectionBackground().getRGB()); > folderToTest.getShell().close(); > } >+ >+ public void testBorderVisible() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { borderVisible: true}"); >+ assertEquals(true, folderToTest.getBorderVisible()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { borderVisible: false}"); >+ assertEquals(false, folderToTest.getBorderVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testSimple() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { simple: true}"); >+ assertEquals(true, folderToTest.getSimple()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { simple: false}"); >+ assertEquals(false, folderToTest.getSimple()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMaximizeVisible() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { maximizeVisible: true}"); >+ assertEquals(true, folderToTest.getMaximizeVisible()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { maximizeVisible: false}"); >+ assertEquals(false, folderToTest.getMaximizeVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMinimizeVisible() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { minimizeVisible: true}"); >+ assertEquals(true, folderToTest.getMinimizeVisible()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { minimizeVisible: false}"); >+ assertEquals(false, folderToTest.getMinimizeVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMRUVisible() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { mruVisible: true}"); >+ assertEquals(true, folderToTest.getMRUVisible()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { mruVisible: false}"); >+ assertEquals(false, folderToTest.getMRUVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMaximized() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { maximized: true}"); >+ assertEquals(true, folderToTest.getMaximized()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { maximized: false}"); >+ assertEquals(false, folderToTest.getMaximized()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMinimized() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { minimized: true}"); >+ assertEquals(true, folderToTest.getMinimized()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { minimized: false}"); >+ assertEquals(false, folderToTest.getMinimized()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testSingle() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { single: true}"); >+ assertEquals(true, folderToTest.getSingle()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { single: false}"); >+ assertEquals(false, folderToTest.getSingle()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testUnselectedCloseVisible() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { unselectedCloseVisible: true}"); >+ assertEquals(true, folderToTest.getUnselectedCloseVisible()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { unselectedCloseVisible: false}"); >+ assertEquals(false, folderToTest.getUnselectedCloseVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testUnselectedImageVisible() throws Exception { >+ CTabFolder folderToTest = createTestCTabFolder("CTabFolder { unselectedImageVisible: true}"); >+ assertEquals(true, folderToTest.getUnselectedImageVisible()); >+ folderToTest.getShell().close(); >+ folderToTest = createTestCTabFolder("CTabFolder { unselectedImageVisible: false}"); >+ assertEquals(false, folderToTest.getUnselectedImageVisible()); >+ folderToTest.getShell().close(); >+ } > } >Index: src/org/eclipse/e4/ui/tests/css/swt/CssSwtTestSuite.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/CssSwtTestSuite.java,v >retrieving revision 1.5 >diff -u -r1.5 CssSwtTestSuite.java >--- src/org/eclipse/e4/ui/tests/css/swt/CssSwtTestSuite.java 14 Jan 2009 21:35:34 -0000 1.5 >+++ src/org/eclipse/e4/ui/tests/css/swt/CssSwtTestSuite.java 12 Feb 2009 19:06:34 -0000 >@@ -18,5 +18,8 @@ > addTestSuite(LabelTest.class); > addTestSuite(CTabFolderTest.class); > addTestSuite(IdClassLabelColorTest.class); >+ addTestSuite(ShellTest.class); >+ addTestSuite(ButtonTest.class); >+ addTestSuite(CssSelectorPrecedence.class); > } > } >Index: src/org/eclipse/e4/ui/tests/css/swt/CSSTestCase.java >=================================================================== >RCS file: /cvsroot/eclipse/e4/org.eclipse.e4.ui/tests/org.eclipse.e4.ui.tests.css.swt/src/org/eclipse/e4/ui/tests/css/swt/CSSTestCase.java,v >retrieving revision 1.1 >diff -u -r1.1 CSSTestCase.java >--- src/org/eclipse/e4/ui/tests/css/swt/CSSTestCase.java 17 Dec 2008 04:18:12 -0000 1.1 >+++ src/org/eclipse/e4/ui/tests/css/swt/CSSTestCase.java 12 Feb 2009 19:06:34 -0000 >@@ -1,6 +1,7 @@ > package org.eclipse.e4.ui.tests.css.swt; > > import java.io.IOException; >+import java.io.Reader; > import java.io.StringReader; > > import junit.framework.TestCase; >@@ -13,6 +14,10 @@ > public class CSSTestCase extends TestCase { > > public CSSEngine createEngine(String styleSheet, Display display) { >+ return createEngine(new StringReader(styleSheet), display); >+ } >+ >+ public CSSEngine createEngine(Reader reader, Display display) { > CSSEngine engine = new CSSSWTEngineImpl(display); > > engine.setErrorHandler(new CSSErrorHandler() { >@@ -22,7 +27,7 @@ > }); > > try { >- engine.parseStyleSheet(new StringReader(styleSheet)); >+ engine.parseStyleSheet(reader); > } catch (IOException e) { > fail(e.getMessage()); > } >Index: src/org/eclipse/e4/ui/tests/css/swt/CTabFolderAddedProperties.java >=================================================================== >RCS file: src/org/eclipse/e4/ui/tests/css/swt/CTabFolderAddedProperties.java >diff -N src/org/eclipse/e4/ui/tests/css/swt/CTabFolderAddedProperties.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/tests/css/swt/CTabFolderAddedProperties.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,112 @@ >+package org.eclipse.e4.ui.tests.css.swt; >+ >+import org.eclipse.e4.ui.css.core.engine.CSSEngine; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CTabFolder; >+import org.eclipse.swt.custom.CTabItem; >+import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+ >+ >+public class CTabFolderAddedProperties extends CSSTestCase { >+ >+ protected CTabFolder createFolder(String styleSheet) { >+ Display display = Display.getDefault(); >+ CSSEngine engine = createEngine(styleSheet, display); >+ >+ // Create widgets >+ Shell shell = new Shell(display, SWT.SHELL_TRIM); >+ FillLayout layout = new FillLayout(); >+ shell.setLayout(layout); >+ >+ CTabFolder folderToTest = new CTabFolder(shell, SWT.NONE); >+ CTabItem tab1 = new CTabItem(folderToTest, SWT.NONE); >+ >+ // Apply Styles >+ engine.applyStyles(shell, true); >+ >+ shell.pack(); >+ shell.open(); >+ return folderToTest; >+ } >+ >+// Display display = Display.getDefault(); >+// CSSEngine engine = new CSSSWTEngineImpl(display); >+// engine.parseStyleSheet(new StringReader("CTabFolder {showClose: true;}")); >+// >+// Shell shell = new Shell(display, SWT.SHELL_TRIM); >+// FillLayout layout = new FillLayout(); >+// shell.setLayout(layout); >+// >+// CTabFolder folderToTest = new CTabFolder(shell, SWT.NONE); >+// CTabItem tab1 = new CTabItem(folderToTest, SWT.NONE); >+// tab1.setText("A TAB ITEM"); >+// >+// // Apply Styles >+// engine.applyStyles(shell, true); >+// >+// shell.pack(); >+// shell.open(); >+ >+ public void testBorderVisible() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { borderVisible: true}"); >+ assertEquals(true, folderToTest.getBorderVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testSimple() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { simple: true}"); >+ assertEquals(true, folderToTest.getSimple()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMaximizeVisible() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { maximizeVisible: true}"); >+ assertEquals(true, folderToTest.getMaximizeVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMinimizeVisible() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { minimizeVisible: true}"); >+ assertEquals(true, folderToTest.getMinimizeVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMRUVisible() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { mruVisible: true}"); >+ assertEquals(true, folderToTest.getMRUVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMaximized() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { maximized: true}"); >+ assertEquals(true, folderToTest.getMaximized()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testMinimized() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { minimized: true}"); >+ assertEquals(true, folderToTest.getMinimized()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testSingle() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { single: true}"); >+ assertEquals(true, folderToTest.getSingle()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testUnselectedCloseVisible() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { unselectedCloseVisible: true}"); >+ assertEquals(true, folderToTest.getUnselectedCloseVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+ public void testUnselectedImageVisible() throws Exception { >+ CTabFolder folderToTest = createFolder("CTabFolder { unselectedImageVisible: true}"); >+ assertEquals(true, folderToTest.getUnselectedImageVisible()); >+ folderToTest.getShell().close(); >+ } >+ >+} >Index: src/org/eclipse/e4/ui/tests/css/swt/CssSelectorPrecedence.java >=================================================================== >RCS file: src/org/eclipse/e4/ui/tests/css/swt/CssSelectorPrecedence.java >diff -N src/org/eclipse/e4/ui/tests/css/swt/CssSelectorPrecedence.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/tests/css/swt/CssSelectorPrecedence.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,79 @@ >+package org.eclipse.e4.ui.tests.css.swt; >+ >+import org.eclipse.e4.ui.css.core.engine.CSSEngine; >+import org.eclipse.e4.ui.css.swt.CSSSWTConstants; >+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.Label; >+import org.eclipse.swt.widgets.Shell; >+ >+ >+public class CssSelectorPrecedence extends CSSTestCase{ >+ >+ static final RGB RED = new RGB(255, 0, 0); >+ static final RGB BLUE = new RGB(0, 0, 255); >+ public Label labelToTest; >+ >+ protected Label labelToTest(String styleSheet) { >+ Display display = Display.getDefault(); >+ CSSEngine engine = createEngine(styleSheet, display); >+ >+ // Create widgets >+ Shell shell = new Shell(display, SWT.SHELL_TRIM); >+ FillLayout layout = new FillLayout(); >+ shell.setLayout(layout); >+ >+ Composite panel = new Composite(shell, SWT.NONE); >+ panel.setLayout(new FillLayout()); >+ >+ Label label = new Label(panel, SWT.NONE); >+ label.setText("Some label text"); >+ label.setData(CSSSWTConstants.CSS_ID_KEY, "labelTest"); >+ label.setData(CSSSWTConstants.CSS_CLASS_NAME_KEY, "labelTest"); >+ >+ >+ // Apply styles >+ engine.applyStyles(shell,true); >+ >+ shell.pack(); >+ shell.open(); >+ engine.applyStyles(labelToTest, true); >+ return label; >+ } >+ >+ >+ public void testRedundancy(){ >+ labelToTest = labelToTest("Label { background-color: #FF0000;} " + >+ "Label {background-color: #0000FF;} "); >+ assertEquals(BLUE, labelToTest.getBackground().getRGB()); >+ } >+ >+ public void testBug261018(){ >+ labelToTest = labelToTest("Label {background-color: #FF0000;}" + >+ "Shell, Label {background-color: #0000FF;}"); >+ assertEquals(BLUE, labelToTest.getBackground().getRGB()); >+ } >+ >+ public void testWithClassNameAndID() { >+ labelToTest = labelToTest("Label { background-color: #FF0000; color: #0000FF} " + >+ "#labelTest {background-color: #0000FF;} "); >+ assertEquals(BLUE, labelToTest.getBackground().getRGB()); >+ } >+ >+ public void testWithClassNameAndPseudoClass() { >+ labelToTest = labelToTest("Label { background-color: #FF0000; color: #0000FF} " + >+ ".labelTest {background-color: #0000FF;} "); >+ assertEquals(BLUE, labelToTest.getBackground().getRGB()); >+ } >+ >+ public void testImportant(){ >+ labelToTest = labelToTest("Label {background-color: rgb(255,0,0);}" + >+ "Label { background-color: rgb(0,0,255) ! important;}" + >+ "Label {background-color: rgb(255,0,0);}"); >+ assertEquals(BLUE, labelToTest.getBackground().getRGB()); >+ } >+ >+} >Index: src/org/eclipse/e4/ui/tests/css/swt/WidgetBehaviour.java >=================================================================== >RCS file: src/org/eclipse/e4/ui/tests/css/swt/WidgetBehaviour.java >diff -N src/org/eclipse/e4/ui/tests/css/swt/WidgetBehaviour.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/tests/css/swt/WidgetBehaviour.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,65 @@ >+package org.eclipse.e4.ui.tests.css.swt; >+ >+import org.eclipse.e4.ui.css.core.engine.CSSEngine; >+import org.eclipse.e4.ui.css.swt.CSSSWTConstants; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.CTabFolder; >+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.Label; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Text; >+ >+ >+public class WidgetBehaviour extends CSSTestCase { >+ >+ public static Button button; >+ public static Text text; >+ public static Label label; >+ public static CTabFolder tabFolder; >+ public static Shell shell; >+ public static Composite panel; >+ public static FillLayout layout; >+ static final RGB RED = new RGB(255, 0, 0); >+ >+ public void createTest(String styleSheet) { >+ Display display = Display.getDefault(); >+ CSSEngine engine = createEngine(styleSheet, display); >+ >+ // Create widgets >+ shell = new Shell(display, SWT.SHELL_TRIM); >+ layout = new FillLayout(); >+ shell.setLayout(layout); >+ >+ panel = new Composite(shell, SWT.NONE); >+ panel.setLayout(new FillLayout()); >+ >+ label = new Label(panel, SWT.NONE); >+ label.setText("Some label text"); >+ >+ button = new Button(panel, SWT.NONE); >+ button.setText("Some button text"); >+ >+ text = new Text(panel, SWT.NONE); >+ text.setText("Some text"); >+ >+ tabFolder = new CTabFolder(panel, SWT.NONE); >+ // Apply styles >+ engine.applyStyles(shell,true); >+ >+ shell.pack(); >+ shell.open(); >+ engine.applyStyles(shell, true); >+ } >+ >+ public void testBackgroudColor(){ >+ createTest("Label, Button, Shell { background-color: #FF0000;}"); >+ assertEquals(RED, button.getBackground().getRGB()); >+ assertEquals(RED, label.getBackground().getRGB()); >+ >+ } >+ >+} >Index: src/org/eclipse/e4/ui/tests/css/swt/ShellTest.java >=================================================================== >RCS file: src/org/eclipse/e4/ui/tests/css/swt/ShellTest.java >diff -N src/org/eclipse/e4/ui/tests/css/swt/ShellTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/tests/css/swt/ShellTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,74 @@ >+package org.eclipse.e4.ui.tests.css.swt; >+ >+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.Composite; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+ >+public class ShellTest extends CSSTestCase { >+ >+ 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 Shell createTestShell(String styleSheet) { >+ Display display = Display.getDefault(); >+ CSSEngine engine = createEngine(styleSheet, display); >+ >+ // Create widgets >+ Shell shell = new Shell(display, SWT.SHELL_TRIM); >+ FillLayout layout = new FillLayout(); >+ shell.setLayout(layout); >+ >+ Composite panel = new Composite(shell, SWT.NONE); >+ panel.setLayout(new FillLayout()); >+ >+ // Apply styles >+ engine.applyStyles(shell, true); >+ >+ shell.pack(); >+ shell.open(); >+ return shell; >+ } >+ >+ >+ public void testColor() throws Exception { >+ Shell shellToTest = createTestShell("Shell { background-color: #FF0000; color: #0000FF }"); >+ assertEquals(RED, shellToTest.getBackground().getRGB()); >+ assertEquals(BLUE, shellToTest.getForeground().getRGB()); >+ shellToTest.getShell().close(); >+ } >+ >+ public void testFontRegular() throws Exception { >+ Shell shellToTest = createTestShell("Shell { font: Verdana 16px }"); >+ assertEquals(1, shellToTest.getFont().getFontData().length); >+ FontData fontData = shellToTest.getFont().getFontData()[0]; >+ assertEquals("Verdana", fontData.getName()); >+ assertEquals(16, fontData.getHeight()); >+ assertEquals(SWT.NORMAL, fontData.getStyle()); >+ shellToTest.getShell().close(); >+ } >+ >+ public void testFontBold() throws Exception { >+ Shell shellToTest = createTestShell("Shell { font: Arial 12px; font-weight: bold }"); >+ assertEquals(1, shellToTest.getFont().getFontData().length); >+ FontData fontData = shellToTest.getFont().getFontData()[0]; >+ assertEquals("Arial", fontData.getName()); >+ assertEquals(12, fontData.getHeight()); >+ assertEquals(SWT.BOLD, fontData.getStyle()); >+ shellToTest.getShell().close(); >+ } >+ >+ public void testFontItalic() throws Exception { >+ Shell shellToTest = createTestShell("Shell { font-style: italic }"); >+ assertEquals(1, shellToTest.getFont().getFontData().length); >+ FontData fontData = shellToTest.getFont().getFontData()[0]; >+ assertEquals(SWT.ITALIC, fontData.getStyle()); >+ shellToTest.getShell().close(); >+ } >+ >+} >Index: src/org/eclipse/e4/ui/tests/css/swt/ButtonTest.java >=================================================================== >RCS file: src/org/eclipse/e4/ui/tests/css/swt/ButtonTest.java >diff -N src/org/eclipse/e4/ui/tests/css/swt/ButtonTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/e4/ui/tests/css/swt/ButtonTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,84 @@ >+package org.eclipse.e4.ui.tests.css.swt; >+ >+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.Composite; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Shell; >+ >+public class ButtonTest extends CSSTestCase { >+ >+ 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 Button createTestButton(String styleSheet) { >+ Display display = Display.getDefault(); >+ CSSEngine engine = createEngine(styleSheet, display); >+ >+ // Create widgets >+ Shell shell = new Shell(display, SWT.SHELL_TRIM); >+ FillLayout layout = new FillLayout(); >+ shell.setLayout(layout); >+ >+ Composite panel = new Composite(shell, SWT.NONE); >+ panel.setLayout(new FillLayout()); >+ >+ Button buttonToTest = new Button(panel, SWT.NONE); >+ buttonToTest.setText("Some button text"); >+ >+ // Apply styles >+ engine.applyStyles(shell, true); >+ >+ shell.pack(); >+ shell.open(); >+ return buttonToTest; >+ } >+ >+ >+ public void testColor() throws Exception { >+ Button buttonToTest = createTestButton("Button { background-color: #FF0000; color: #0000FF }"); >+ assertEquals(RED, buttonToTest.getBackground().getRGB()); >+ assertEquals(BLUE, buttonToTest.getForeground().getRGB()); >+ buttonToTest.getShell().close(); >+ } >+ >+ public void testFontRegular() throws Exception { >+ Button buttonToTest = createTestButton("Button { font: Verdana 16px }"); >+ assertEquals(1, buttonToTest.getFont().getFontData().length); >+ FontData fontData = buttonToTest.getFont().getFontData()[0]; >+ assertEquals("Verdana", fontData.getName()); >+ assertEquals(16, fontData.getHeight()); >+ assertEquals(SWT.NORMAL, fontData.getStyle()); >+ buttonToTest.getShell().close(); >+ } >+ >+ public void testFontBold() throws Exception { >+ Button buttonToTest = createTestButton("Button { font: Arial 12px; font-weight: bold }"); >+ assertEquals(1, buttonToTest.getFont().getFontData().length); >+ FontData fontData = buttonToTest.getFont().getFontData()[0]; >+ assertEquals("Arial", fontData.getName()); >+ assertEquals(12, fontData.getHeight()); >+ assertEquals(SWT.BOLD, fontData.getStyle()); >+ buttonToTest.getShell().close(); >+ } >+ >+ public void testFontItalic() throws Exception { >+ Button buttonToTest = createTestButton("Button { font-style: italic }"); >+ assertEquals(1, buttonToTest.getFont().getFontData().length); >+ FontData fontData = buttonToTest.getFont().getFontData()[0]; >+ assertEquals(SWT.ITALIC, fontData.getStyle()); >+ buttonToTest.getShell().close(); >+ } >+ >+ public void testBorder() throws Exception { >+ Button buttonToTest = createTestButton("Button { border-width: 2;}"); >+ assertEquals(buttonToTest.getBorderWidth(), 2); >+ buttonToTest.getShell().close(); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 263081
:
124314
|
124581
|
125559