]> source.dussan.org Git - vaadin-framework.git/commitdiff
Compass test cases (#11776)
authorArtur Signell <artur@vaadin.com>
Mon, 2 Sep 2013 19:10:39 +0000 (22:10 +0300)
committerVaadin Code Review <review@vaadin.com>
Thu, 26 Sep 2013 06:21:18 +0000 (06:21 +0000)
Change-Id: Icf460eec606196bcff9b329fe7055bce6ed82c5f

18 files changed:
theme-compiler/tests/resources/css/compass-import.css [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test/compass-import.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/_compass.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass-import2.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/_css3.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/_typography.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/_utilities.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/css3/_border-radius.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/css3/_inline-block.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/css3/_opacity.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/typography/_links.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/typography/_lists.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/typography/_text.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/utilities/_color.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/utilities/_general.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/compass/utilities/_sprites.scss [new file with mode: 0644]
theme-compiler/tests/resources/scss/compass-test2/license-readme.txt [new file with mode: 0644]
theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java [new file with mode: 0644]

diff --git a/theme-compiler/tests/resources/css/compass-import.css b/theme-compiler/tests/resources/css/compass-import.css
new file mode 100644 (file)
index 0000000..e3d4b5f
--- /dev/null
@@ -0,0 +1,49 @@
+.content-navigation {
+       border-color: #3bbfce;
+       color: #0000ff;
+}
+
+.border {
+       padding: 8px;
+       margin: 8px;
+       border-color: #3bbfce;
+}
+
+.body {
+       background-image: url(compass/folder-test2/bg.png);
+       background: transparent url(compass/folder-test2/img/loading-indicator.gif);
+       background-image: url(http://abc/bg.png);
+       background-image: url(/abc/bg.png);
+}
+
+.base {
+       color: red;
+}
+
+.text {
+       font-weight: bold;
+}
+
+.footer {
+       border: 2px solid black;
+       -webkit-border-radius: 10px;
+       -moz-border-radius: 10px;
+       border-radius: 10px;
+}
+
+.banner {
+       border: 1px solid black;
+       font-color: red;
+}
+
+.interpolation-test {
+       font-size: 14px;
+}
+
+.header {
+       width: 100%;
+}
+
+.badError {
+       border-width: 3px;
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test/compass-import.scss b/theme-compiler/tests/resources/scss/compass-test/compass-import.scss
new file mode 100644 (file)
index 0000000..36d041b
--- /dev/null
@@ -0,0 +1,4 @@
+@import "compass";
+.badError {
+       border-width: 3px;
+}
diff --git a/theme-compiler/tests/resources/scss/compass-test2/_compass.scss b/theme-compiler/tests/resources/scss/compass-test2/_compass.scss
new file mode 100644 (file)
index 0000000..9b741c0
--- /dev/null
@@ -0,0 +1,3 @@
+@import "compass/utilities";
+@import "compass/typography";
+@import "compass/css3";
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass-import2.scss b/theme-compiler/tests/resources/scss/compass-test2/compass-import2.scss
new file mode 100644 (file)
index 0000000..36d041b
--- /dev/null
@@ -0,0 +1,4 @@
+@import "compass";
+.badError {
+       border-width: 3px;
+}
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/_css3.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/_css3.scss
new file mode 100644 (file)
index 0000000..42163ba
--- /dev/null
@@ -0,0 +1,3 @@
+@import "css3/border-radius";
+@import "css3/inline-block";
+@import "css3/opacity";
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/_typography.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/_typography.scss
new file mode 100644 (file)
index 0000000..a65c1ff
--- /dev/null
@@ -0,0 +1,3 @@
+@import "typography/links";
+@import "typography/lists";
+@import "typography/text";
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/_utilities.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/_utilities.scss
new file mode 100644 (file)
index 0000000..644ad33
--- /dev/null
@@ -0,0 +1,3 @@
+@import "utilities/color";
+@import "utilities/general";
+@import "utilities/sprites";
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/css3/_border-radius.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/css3/_border-radius.scss
new file mode 100644 (file)
index 0000000..7520031
--- /dev/null
@@ -0,0 +1,4 @@
+.banner {
+       border: 1px solid black;
+       font-color: red;
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/css3/_inline-block.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/css3/_inline-block.scss
new file mode 100644 (file)
index 0000000..3fefab8
--- /dev/null
@@ -0,0 +1,3 @@
+.interpolation-test {
+       font-size: 14px;
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/css3/_opacity.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/css3/_opacity.scss
new file mode 100644 (file)
index 0000000..f6bf34f
--- /dev/null
@@ -0,0 +1,3 @@
+.header {
+       width: 100%;
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/typography/_links.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/typography/_links.scss
new file mode 100644 (file)
index 0000000..bc73185
--- /dev/null
@@ -0,0 +1,3 @@
+.base {
+       color: red;
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/typography/_lists.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/typography/_lists.scss
new file mode 100644 (file)
index 0000000..af174b7
--- /dev/null
@@ -0,0 +1,3 @@
+.text {
+       font-weight: bold;
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/typography/_text.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/typography/_text.scss
new file mode 100644 (file)
index 0000000..8239527
--- /dev/null
@@ -0,0 +1,6 @@
+.footer {
+       border: 2px solid black;
+       -webkit-border-radius: 10px;
+       -moz-border-radius: 10px;
+       border-radius: 10px;
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/utilities/_color.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/utilities/_color.scss
new file mode 100644 (file)
index 0000000..ea1b7a5
--- /dev/null
@@ -0,0 +1,4 @@
+.content-navigation {
+       border-color: #3bbfce;
+       color: #0000ff;
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/utilities/_general.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/utilities/_general.scss
new file mode 100644 (file)
index 0000000..0c58c64
--- /dev/null
@@ -0,0 +1,5 @@
+.border {
+       padding: 8px;
+       margin: 8px;
+       border-color: #3bbfce;
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test2/compass/utilities/_sprites.scss b/theme-compiler/tests/resources/scss/compass-test2/compass/utilities/_sprites.scss
new file mode 100644 (file)
index 0000000..28960f8
--- /dev/null
@@ -0,0 +1,6 @@
+.body {
+       background-image: url(../folder-test2/bg.png);
+       background: transparent url(../folder-test2/img/loading-indicator.gif);
+       background-image: url(http://abc/bg.png);
+       background-image: url(/abc/bg.png);
+}
\ No newline at end of file
diff --git a/theme-compiler/tests/resources/scss/compass-test2/license-readme.txt b/theme-compiler/tests/resources/scss/compass-test2/license-readme.txt
new file mode 100644 (file)
index 0000000..90ba808
--- /dev/null
@@ -0,0 +1,26 @@
+The design here is to use the stylesheets located at: 
+https://github com/chriseppstein/compass/tree/stable/frameworks/compass/stylesheets 
+
+and update the VAADIN code to be able to read them in such that an existing JRuby implementation can be replaced with VAADIN without any changes to one's *.scss and *.css files.
+
+The current short snippets of SCSS that are included here only for testing Compass compatibility might not qualify as significant or substantial parts, but in any case Compass is being mentioned for related tests pointing to the original implementation. These small portions of Compass are copied and modified for the testing of compatibility only.
+
+The license for Compass mentioned here:
+https://github.com/chriseppstein/compass/blob/stable/LICENSE.markdown
+
+is as follows:
+
+
+
+
+Copyright (c) 2009 Christopher M. Eppstein
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. No attribution is required by products that make use of this software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name(s) of the above copyright holders shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization.
+
+Contributors to this project agree to grant all rights to the copyright holder of the primary product. Attribution is maintained in the source control history of the product.
diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/CompassImports.java
new file mode 100644 (file)
index 0000000..1e3eb09
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.vaadin.sass.testcases.scss;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.w3c.css.sac.CSSException;
+
+import com.vaadin.sass.AbstractTestBase;
+import com.vaadin.sass.internal.ScssStylesheet;
+import com.vaadin.sass.internal.handler.SCSSDocumentHandler;
+import com.vaadin.sass.internal.handler.SCSSDocumentHandlerImpl;
+import com.vaadin.sass.internal.parser.Parser;
+import com.vaadin.sass.internal.resolver.FilesystemResolver;
+import com.vaadin.sass.internal.tree.ImportNode;
+
+public class CompassImports extends AbstractTestBase {
+
+    String scssOtherDirectory = "/scss/compass-test/compass-import.scss";
+    String scssSameDirectory = "/scss/compass-test2/compass-import2.scss";
+    String css = "/css/compass-import.css";
+
+    String compassPath = "/scss/compass-test2";
+
+    @Test
+    public void testParser() throws CSSException, IOException {
+        Parser parser = new Parser();
+        SCSSDocumentHandler handler = new SCSSDocumentHandlerImpl();
+        parser.setDocumentHandler(handler);
+        parser.parseStyleSheet(getClass().getResource(scssOtherDirectory)
+                .getPath());
+        ScssStylesheet root = handler.getStyleSheet();
+        ImportNode importVariableNode = (ImportNode) root.getChildren().get(0);
+        Assert.assertEquals("compass", importVariableNode.getUri());
+        Assert.assertFalse(importVariableNode.isPureCssImport());
+    }
+
+    @Test
+    public void testCompiler() throws Exception {
+        testCompiler(scssSameDirectory, css, null);
+    }
+
+    @Test
+    public void testCompilerWithCustomPath() throws Exception {
+        File rootPath = new File(getClass().getResource(compassPath).toURI());
+
+        testCompiler(scssOtherDirectory, css, rootPath.getPath());
+    }
+
+    public void testCompiler(String scss, String css, String additionalPath)
+            throws Exception {
+        comparisonCss = getFileContent(css);
+        ScssStylesheet sheet = getStyleSheet(scss);
+        Assert.assertNotNull(sheet);
+        sheet.addResolver(new FilesystemResolver(additionalPath));
+
+        sheet.compile();
+        parsedScss = sheet.toString();
+        Assert.assertEquals("Original CSS and parsed CSS do not match",
+                comparisonCss, parsedScss);
+    }
+}