-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
ph-css/src/test/java/com/helger/css/supplementary/issues/Issue107Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (C) 2014-2025 Philip Helger (www.helger.com) | ||
* philip[at]helger[dot]com | ||
* | ||
* 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.helger.css.supplementary.issues; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import org.junit.Test; | ||
|
||
import com.helger.css.decl.CSSStyleRule; | ||
import com.helger.css.decl.CascadingStyleSheet; | ||
import com.helger.css.reader.CSSReader; | ||
import com.helger.css.reader.CSSReaderSettings; | ||
import com.helger.css.writer.CSSWriterSettings; | ||
|
||
/** | ||
* Test for issue: https://github.com/phax/ph-css/issues/107 | ||
* | ||
* @author Philip Helger | ||
*/ | ||
public final class Issue107Test | ||
{ | ||
@Test | ||
public void testIssue () | ||
{ | ||
final String sCSS = "a:focus {\r\n" + | ||
" background-color: red;\r\n" + | ||
"}\r\n" + | ||
".box {\r\n" + | ||
" *zoom: 1; /* Applied only in IE7 and below */\r\n" + | ||
" background-image: url(\"https://www.example.com/image3.png\");\r\n" + | ||
"}"; | ||
final CascadingStyleSheet aCSS = CSSReader.readFromStringReader (sCSS, | ||
new CSSReaderSettings ().setBrowserCompliantMode (true) | ||
.setUseSourceLocation (true)); | ||
assertNotNull (aCSS); | ||
|
||
assertEquals (2, aCSS.getAllStyleRules ().size ()); | ||
|
||
final CSSStyleRule aRule2 = aCSS.getAllStyleRules ().get (1); | ||
assertNotNull (aRule2); | ||
|
||
// Check selector | ||
assertEquals (".box", aRule2.getSelectorsAsCSSString (new CSSWriterSettings (), 0)); | ||
|
||
// Check declarations | ||
// *zoom is a deprecated property | ||
assertEquals (1, aRule2.getDeclarationCount ()); | ||
assertEquals ("background-image", aRule2.getDeclarationAtIndex (0).getProperty ()); | ||
} | ||
} |