Fix style nit in Css2Gss converter.
Change-Id: I520a50c288e29e030c444b6856ea5330349bb8b5
diff --git a/user/src/com/google/gwt/resources/converter/GssGenerationVisitor.java b/user/src/com/google/gwt/resources/converter/GssGenerationVisitor.java
index f266d18..f901ca0 100644
--- a/user/src/com/google/gwt/resources/converter/GssGenerationVisitor.java
+++ b/user/src/com/google/gwt/resources/converter/GssGenerationVisitor.java
@@ -593,7 +593,7 @@
@Override
public boolean visit(CssSelector x, Context ctx) {
if (needsComma) {
- comma();
+ comma(false);
}
maybePrintNewLine();
@@ -663,8 +663,15 @@
}
private void comma() {
+ comma(true);
+ }
+
+ private void comma(boolean addSpace) {
out.print(',');
- spaceOpt();
+
+ if (addSpace) {
+ spaceOpt();
+ }
}
private void openBrace() {
diff --git a/user/test/com/google/gwt/resources/converter/Css2GssTest.java b/user/test/com/google/gwt/resources/converter/Css2GssTest.java
index 579ede9..7be7a39 100644
--- a/user/test/com/google/gwt/resources/converter/Css2GssTest.java
+++ b/user/test/com/google/gwt/resources/converter/Css2GssTest.java
@@ -15,6 +15,9 @@
*/
package com.google.gwt.resources.converter;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.thirdparty.common.css.SourceCode;
import com.google.gwt.thirdparty.common.css.compiler.ast.GssParser;
@@ -24,9 +27,6 @@
import junit.framework.TestCase;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
import org.apache.commons.io.IOUtils;
import java.io.IOException;
@@ -50,7 +50,7 @@
}
public void testCssConditional() throws Exception {
- Predicate<String> mockPropertyConfigurationMatcher = mock(Predicate.class);
+ Predicate<String> mockPropertyConfigurationMatcher = mock(Predicate.class);
when(mockPropertyConfigurationMatcher.apply("!WILL_MATCH_A_CONFIGURATION_PROPERTY"))
.thenReturn(true);
when(mockPropertyConfigurationMatcher.apply("WILL_MATCH_A_CONFIGURATION_PROPERTY2"))
@@ -124,14 +124,22 @@
public void testConvertingWithVariablesDefinedInAnotherFile()
throws UnableToCompleteException, IOException {
URL resource = Css2GssTest.class.getResource("variable_defined_in_another_file.css");
- InputStream stream = Css2GssTest.class.getResourceAsStream("variable_defined_in_another_file.gss");
+ InputStream stream =
+ Css2GssTest.class.getResourceAsStream("variable_defined_in_another_file.gss");
Set<URL> set = new HashSet<>();
set.add(Css2GssTest.class.getResource("variable_defined_in_file.css"));
- String convertedGss = new Css2Gss(resource, false, Predicates.<String>alwaysFalse(), set).toGss();
+ String convertedGss =
+ new Css2Gss(resource, false, Predicates.<String>alwaysFalse(), set).toGss();
String gss = IOUtils.toString(stream, "UTF-8");
assertEquals(gss, convertedGss);
}
+ public void testNoTrailingWhiteSpacesWithMultiSelectors() throws IOException,
+ UnableToCompleteException {
+ assertFileContentEqualsAfterConversionAndIsGssCompatible(
+ "multi_selector_trailing_whitespace.css", "multi_selector_trailing_whitespace.gss", false);
+ }
+
private void assertFileContentEqualsAfterConversion(String inputCssFile, String expectedGssFile)
throws IOException, UnableToCompleteException {
assertFileContentEqualsAfterConversionAndIsGssCompatible(inputCssFile, expectedGssFile, false);
diff --git a/user/test/com/google/gwt/resources/converter/multi_selector_trailing_whitespace.css b/user/test/com/google/gwt/resources/converter/multi_selector_trailing_whitespace.css
new file mode 100644
index 0000000..8f0a83c
--- /dev/null
+++ b/user/test/com/google/gwt/resources/converter/multi_selector_trailing_whitespace.css
@@ -0,0 +1,3 @@
+.foo, .bar {
+ width: 100px;
+}
diff --git a/user/test/com/google/gwt/resources/converter/multi_selector_trailing_whitespace.gss b/user/test/com/google/gwt/resources/converter/multi_selector_trailing_whitespace.gss
new file mode 100644
index 0000000..904d13c
--- /dev/null
+++ b/user/test/com/google/gwt/resources/converter/multi_selector_trailing_whitespace.gss
@@ -0,0 +1,4 @@
+.foo,
+.bar {
+ width: 100px;
+}