diff options
author | John Ahlroos <john@vaadin.com> | 2013-03-01 15:00:47 +0200 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2013-03-01 15:03:05 +0200 |
commit | c965ff2475f4047ae5efa2b2917089f8b97e95d9 (patch) | |
tree | 76e29313c468e791dba2dbae30aefca105b48d81 /theme-compiler/tests | |
parent | eb65236d0eee3cbeebe5a2d5fa5a2f3744ebaeff (diff) | |
parent | 7f9e51e0e31c5c0a699c7ca486aaf993d5aec347 (diff) | |
download | vaadin-framework-c965ff2475f4047ae5efa2b2917089f8b97e95d9.tar.gz vaadin-framework-c965ff2475f4047ae5efa2b2917089f8b97e95d9.zip |
Merge remote-tracking branch 'origin/7.0'
Change-Id: Ifdc095169c31731cb013727f14d92839ecc775db
Diffstat (limited to 'theme-compiler/tests')
17 files changed, 198 insertions, 7 deletions
diff --git a/theme-compiler/tests/resources/automatic/css/extend-in-nested-block.css b/theme-compiler/tests/resources/automatic/css/extend-in-nested-block.css new file mode 100644 index 0000000000..29f1550dd7 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/extend-in-nested-block.css @@ -0,0 +1,7 @@ +.test .error, .test .seriousError { + border: 1px #f00; + background-color: #fdd; +} +.test .seriousError { + border-width: 3px; +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/css/extend-selector-in-different-levels.css b/theme-compiler/tests/resources/automatic/css/extend-selector-in-different-levels.css new file mode 100644 index 0000000000..4de05d8d82 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/extend-selector-in-different-levels.css @@ -0,0 +1,15 @@ +.test .middle .error, .test .middle .seriousError { + border: 1px #f00; + background-color: #fdd; +} +.test .seriousError { + border-width: 3px; +} + +.test1 .error1, .test1 .middle1 .seriousError1 { + border: 1px #f00; + background-color: #fdd; +} +.test1 .middle1 .seriousError1 { + border-width: 3px; +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/css/extending-non-exist-selector-with-same-beginning.css b/theme-compiler/tests/resources/automatic/css/extending-non-exist-selector-with-same-beginning.css new file mode 100644 index 0000000000..d138a79e4a --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/extending-non-exist-selector-with-same-beginning.css @@ -0,0 +1,7 @@ +.test1 { + color: blue; +} + +.test2 { + background: red; +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/css/extending-same-selector.css b/theme-compiler/tests/resources/automatic/css/extending-same-selector.css new file mode 100644 index 0000000000..1a85c0c23e --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/extending-same-selector.css @@ -0,0 +1,7 @@ +.test { + color: blue; +} + +.test { + background: red; +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/css/extending-selector-with-same-beginning.css b/theme-compiler/tests/resources/automatic/css/extending-selector-with-same-beginning.css new file mode 100644 index 0000000000..097d7a8655 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/extending-selector-with-same-beginning.css @@ -0,0 +1,7 @@ +.test1, .test2 { + color: blue; +} + +.test2 { + background: red; +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/scss/extend-in-nested-block.scss b/theme-compiler/tests/resources/automatic/scss/extend-in-nested-block.scss new file mode 100644 index 0000000000..d62ead937e --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/extend-in-nested-block.scss @@ -0,0 +1,11 @@ +.test{ + .error { + border: 1px #f00; + background-color: #fdd; + } + + .seriousError { + @extend .error; + border-width: 3px; + } +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/scss/extend-selector-in-different-levels.scss b/theme-compiler/tests/resources/automatic/scss/extend-selector-in-different-levels.scss new file mode 100644 index 0000000000..977ead8d62 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/extend-selector-in-different-levels.scss @@ -0,0 +1,26 @@ +.test{ + .middle{ + .error { + border: 1px #f00; + background-color: #fdd; + } + } + + .seriousError { + @extend .error; + border-width: 3px; + } +} + +.test1{ + .error1 { + border: 1px #f00; + background-color: #fdd; + } + .middle1{ + .seriousError1 { + @extend .error1; + border-width: 3px; + } + } +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/scss/extending-non-exist-selector-with-same-beginning.scss b/theme-compiler/tests/resources/automatic/scss/extending-non-exist-selector-with-same-beginning.scss new file mode 100644 index 0000000000..538f17da1d --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/extending-non-exist-selector-with-same-beginning.scss @@ -0,0 +1,8 @@ +.test1 { + color: blue; +} + +.test2 { + @extend .test; + background: red; +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/scss/extending-same-selector.scss b/theme-compiler/tests/resources/automatic/scss/extending-same-selector.scss new file mode 100644 index 0000000000..fbfaed9b20 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/extending-same-selector.scss @@ -0,0 +1,8 @@ +.test { + color: blue; +} + +.test { + @extend .test; + background: red; +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/automatic/scss/extending-selector-with-same-beginning.scss b/theme-compiler/tests/resources/automatic/scss/extending-selector-with-same-beginning.scss new file mode 100644 index 0000000000..c7a9e5e921 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/extending-selector-with-same-beginning.scss @@ -0,0 +1,8 @@ +.test1 { + color: blue; +} + +.test2 { + @extend .test1; + background: red; +}
\ No newline at end of file diff --git a/theme-compiler/tests/resources/sasslangbroken/css/19-test_control_flow_if.css b/theme-compiler/tests/resources/sasslang/css/19-test_control_flow_if.css index 14a1c6ef3c..14a1c6ef3c 100644 --- a/theme-compiler/tests/resources/sasslangbroken/css/19-test_control_flow_if.css +++ b/theme-compiler/tests/resources/sasslang/css/19-test_control_flow_if.css diff --git a/theme-compiler/tests/resources/sasslangbroken/scss/19-test_control_flow_if.scss b/theme-compiler/tests/resources/sasslang/scss/19-test_control_flow_if.scss index be53e52341..be53e52341 100644 --- a/theme-compiler/tests/resources/sasslangbroken/scss/19-test_control_flow_if.scss +++ b/theme-compiler/tests/resources/sasslang/scss/19-test_control_flow_if.scss diff --git a/theme-compiler/tests/src/com/vaadin/sass/internal/util/StringUtilTest.java b/theme-compiler/tests/src/com/vaadin/sass/internal/util/StringUtilTest.java index b05b0e9dcf..84d189d8ba 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/internal/util/StringUtilTest.java +++ b/theme-compiler/tests/src/com/vaadin/sass/internal/util/StringUtilTest.java @@ -50,4 +50,62 @@ public class StringUtilTest { Assert.assertEquals(sentence, StringUtil.replaceVariable(sentence, word, value)); } + + @Test + public void testContainsSubString() { + String sentence = "var1 var2"; + String word = "var"; + Assert.assertFalse(StringUtil.containsSubString(sentence, word)); + + word = "var1"; + Assert.assertTrue(StringUtil.containsSubString(sentence, word)); + + String var2 = "var2"; + Assert.assertTrue(StringUtil.containsSubString(sentence, var2)); + + Assert.assertTrue(StringUtil.containsSubString(".error.intrusion", + ".error")); + + Assert.assertFalse(StringUtil.containsSubString(".foo", "oo")); + } + + @Test + public void testContainsSubStringWithDash() { + String sentence = "var- var2"; + String word = "var"; + Assert.assertFalse(StringUtil.containsSubString(sentence, word)); + } + + @Test + public void testReplaceSubString() { + String sentence = "var1 var2"; + String word = "var"; + String value = "abc"; + + word = "var1"; + Assert.assertEquals("abc var2", + StringUtil.replaceSubString(sentence, word, value)); + + String var2 = "var1 abc"; + Assert.assertEquals(sentence, + StringUtil.replaceSubString(sentence, var2, value)); + + Assert.assertEquals(".foo", + StringUtil.replaceSubString(".foo", "oo", "aa")); + } + + @Test + public void testReplaceSubStringWithDash() { + String sentence = "var- var2"; + String word = "var"; + String value = "abc"; + Assert.assertEquals(sentence, + StringUtil.replaceSubString(sentence, word, value)); + } + + @Test + public void testRemoveDuplicatedClassSelector() { + Assert.assertEquals(".seriousError", StringUtil + .removeDuplicatedSubString(".seriousError.seriousError", ".")); + } } diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/AbstractDirectoryScanningSassTests.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/AbstractDirectoryScanningSassTests.java index f990647978..47657f805c 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/AbstractDirectoryScanningSassTests.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/AbstractDirectoryScanningSassTests.java @@ -27,15 +27,13 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import junit.framework.TestCase; - import org.apache.commons.io.IOUtils; import org.junit.Assert; import com.vaadin.sass.internal.ScssStylesheet; import com.vaadin.sass.testcases.scss.SassTestRunner.FactoryTest; -public abstract class AbstractDirectoryScanningSassTests extends TestCase { +public abstract class AbstractDirectoryScanningSassTests { public static Collection<String> getScssResourceNames(URL directoryUrl) throws URISyntaxException { @@ -51,7 +49,7 @@ public abstract class AbstractDirectoryScanningSassTests extends TestCase { URL sasslangUrl = directoryUrl; File sasslangDir = new File(sasslangUrl.toURI()); File scssDir = new File(sasslangDir, "scss"); - assertTrue(scssDir.exists()); + Assert.assertTrue(scssDir.exists()); return scssDir.listFiles(new FilenameFilter() { diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassLangTests.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassLangTests.java index 7f42898fe5..4b8aada524 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassLangTests.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassLangTests.java @@ -32,7 +32,12 @@ public class SassLangTests extends AbstractDirectoryScanningSassTests { } private static URL getResourceURLInternal(String path) { - return SassLangTests.class.getResource("/sasslang" + path); + URL url = SassLangTests.class.getResource("/sasslang" + path); + if (url == null) { + throw new RuntimeException( + "Could not locate /sasslang using classloader"); + } + return url; } @TestFactory diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassLangTestsBroken.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassLangTestsBroken.java index 897e8dc543..6b812a6940 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassLangTestsBroken.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassLangTestsBroken.java @@ -19,7 +19,9 @@ import java.net.URISyntaxException; import java.net.URL; import java.util.Collection; +import org.junit.Assert; import org.junit.runner.RunWith; +import org.w3c.css.sac.CSSException; import com.vaadin.sass.testcases.scss.SassTestRunner.TestFactory; @@ -32,7 +34,13 @@ public class SassLangTestsBroken extends AbstractDirectoryScanningSassTests { } private static URL getResourceURLInternal(String path) { - return SassLangTestsBroken.class.getResource("/sasslangbroken" + path); + URL url = SassLangTestsBroken.class.getResource("/sasslangbroken" + + path); + if (url == null) { + throw new RuntimeException( + "Could not locate /sasslangbroken using classloader"); + } + return url; } @TestFactory @@ -41,4 +49,22 @@ public class SassLangTestsBroken extends AbstractDirectoryScanningSassTests { return getScssResourceNames(getResourceURLInternal("")); } + @Override + public void compareScssWithCss(String scssResourceName) throws Exception { + boolean success = false; + try { + super.compareScssWithCss(scssResourceName); + success = true; + } catch (CSSException e) { + // this is an expected outcome + } catch (AssertionError e) { + // this is an expected outcome + } + if (success) { + Assert.fail("Test " + + scssResourceName + + " from sasslangbroken that was expected to fail has been fixed. Please move the corresponding CSS and SCSS files to sasslang."); + } + } + } diff --git a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassTestRunner.java b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassTestRunner.java index da5210b2da..147362e4c7 100644 --- a/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassTestRunner.java +++ b/theme-compiler/tests/src/com/vaadin/sass/testcases/scss/SassTestRunner.java @@ -80,7 +80,7 @@ public class SassTestRunner extends BlockJUnit4ClassRunner { getTestClass().getJavaClass()); } catch (Throwable t) { throw new RuntimeException("Could not run test factory method " - + method.getName()); + + method.getName(), t); } // Did the factory return an array? If so, make it a list. |