modules/graphics/src/test/java/test/javafx/css/Node_cssStyleMap_Test.java
Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:
*** 21,31 ****
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
! package javafx.css;
import com.sun.javafx.css.CascadingStyle;
import com.sun.javafx.css.ParsedValueImpl;
import com.sun.javafx.css.StyleManager;
import javafx.css.converter.FontConverter;
--- 21,31 ----
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
! package test.javafx.css;
import com.sun.javafx.css.CascadingStyle;
import com.sun.javafx.css.ParsedValueImpl;
import com.sun.javafx.css.StyleManager;
import javafx.css.converter.FontConverter;
*** 35,44 ****
--- 35,58 ----
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javafx.beans.property.Property;
+ import javafx.css.CssMetaData;
+ import javafx.css.Declaration;
+ import javafx.css.DeclarationShim;
+ import javafx.css.ParsedValue;
+ import javafx.css.Rule;
+ import javafx.css.RuleShim;
+ import javafx.css.Selector;
+ import javafx.css.Size;
+ import javafx.css.SizeUnits;
+ import javafx.css.Style;
+ import javafx.css.StyleOrigin;
+ import javafx.css.StyleableProperty;
+ import javafx.css.Stylesheet;
+ import javafx.css.StylesheetShim;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
*** 89,129 ****
@Test
public void testStyleMap() {
final List<Declaration> declsNoState = new ArrayList<Declaration>();
Collections.addAll(declsNoState,
! new Declaration("-fx-fill", new ParsedValueImpl<Color,Color>(Color.RED, null), false),
! new Declaration("-fx-stroke", new ParsedValueImpl<Color,Color>(Color.YELLOW, null), false),
! new Declaration("-fx-stroke-width", new ParsedValueImpl<ParsedValue<?,Size>,Number>(
new ParsedValueImpl<Size,Size>(new Size(3d, SizeUnits.PX), null),
SizeConverter.getInstance()), false)
);
final List<Selector> selsNoState = new ArrayList<Selector>();
Collections.addAll(selsNoState,
Selector.createSelector(".rect")
);
! Rule rule = new Rule(selsNoState, declsNoState);
! Stylesheet stylesheet = new Stylesheet("testStyleMap");
stylesheet.setOrigin(StyleOrigin.USER_AGENT);
stylesheet.getRules().add(rule);
final List<Declaration> declsDisabledState = new ArrayList<Declaration>();
Collections.addAll(declsDisabledState,
! new Declaration("-fx-fill", new ParsedValueImpl<Color,Color>(Color.GRAY, null), false),
! new Declaration("-fx-stroke", new ParsedValueImpl<Color,Color>(Color.DARKGRAY, null), false)
);
final List<Selector> selsDisabledState = new ArrayList<Selector>();
Collections.addAll(selsDisabledState,
Selector.createSelector(".rect:disabled")
);
! rule = new Rule(selsDisabledState, declsDisabledState);
stylesheet.getRules().add(rule);
Rectangle rect = new Rectangle(50,50);
rect.getStyleClass().add("rect");
--- 103,143 ----
@Test
public void testStyleMap() {
final List<Declaration> declsNoState = new ArrayList<Declaration>();
Collections.addAll(declsNoState,
! DeclarationShim.getDeclaration("-fx-fill", new ParsedValueImpl<Color,Color>(Color.RED, null), false),
! DeclarationShim.getDeclaration("-fx-stroke", new ParsedValueImpl<Color,Color>(Color.YELLOW, null), false),
! DeclarationShim.getDeclaration("-fx-stroke-width", new ParsedValueImpl<ParsedValue<?,Size>,Number>(
new ParsedValueImpl<Size,Size>(new Size(3d, SizeUnits.PX), null),
SizeConverter.getInstance()), false)
);
final List<Selector> selsNoState = new ArrayList<Selector>();
Collections.addAll(selsNoState,
Selector.createSelector(".rect")
);
! Rule rule = RuleShim.getRule(selsNoState, declsNoState);
! Stylesheet stylesheet = new StylesheetShim("testStyleMap");
stylesheet.setOrigin(StyleOrigin.USER_AGENT);
stylesheet.getRules().add(rule);
final List<Declaration> declsDisabledState = new ArrayList<Declaration>();
Collections.addAll(declsDisabledState,
! DeclarationShim.getDeclaration("-fx-fill", new ParsedValueImpl<Color,Color>(Color.GRAY, null), false),
! DeclarationShim.getDeclaration("-fx-stroke", new ParsedValueImpl<Color,Color>(Color.DARKGRAY, null), false)
);
final List<Selector> selsDisabledState = new ArrayList<Selector>();
Collections.addAll(selsDisabledState,
Selector.createSelector(".rect:disabled")
);
! rule = RuleShim.getRule(selsDisabledState, declsDisabledState);
stylesheet.getRules().add(rule);
Rectangle rect = new Rectangle(50,50);
rect.getStyleClass().add("rect");
*** 156,176 ****
@Test
public void testStyleMapChildren() {
final List<Declaration> declsNoState = new ArrayList<Declaration>();
Collections.addAll(declsNoState,
! new Declaration("-fx-fill", new ParsedValueImpl<Color,Color>(Color.RED, null), false)
);
final List<Selector> selsNoState = new ArrayList<Selector>();
Collections.addAll(selsNoState,
Selector.createSelector(".rect")
);
! Rule rule = new Rule(selsNoState, declsNoState);
! Stylesheet stylesheet = new Stylesheet("testStyleMapChildren");
stylesheet.setOrigin(StyleOrigin.USER_AGENT);
stylesheet.getRules().add(rule);
Rectangle rect = new Rectangle(50,50);
rect.getStyleClass().add("rect");
--- 170,190 ----
@Test
public void testStyleMapChildren() {
final List<Declaration> declsNoState = new ArrayList<Declaration>();
Collections.addAll(declsNoState,
! DeclarationShim.getDeclaration("-fx-fill", new ParsedValueImpl<Color,Color>(Color.RED, null), false)
);
final List<Selector> selsNoState = new ArrayList<Selector>();
Collections.addAll(selsNoState,
Selector.createSelector(".rect")
);
! Rule rule = RuleShim.getRule(selsNoState, declsNoState);
! Stylesheet stylesheet = new StylesheetShim("testStyleMapChildren");
stylesheet.setOrigin(StyleOrigin.USER_AGENT);
stylesheet.getRules().add(rule);
Rectangle rect = new Rectangle(50,50);
rect.getStyleClass().add("rect");
*** 195,217 ****
@Test
public void testRT_21212() {
final List<Declaration> rootDecls = new ArrayList<Declaration>();
Collections.addAll(rootDecls,
! new Declaration("-fx-font-size", new ParsedValueImpl<ParsedValue<?,Size>,Number>(
new ParsedValueImpl<Size,Size>(new Size(12, SizeUnits.PX), null),
SizeConverter.getInstance()), false)
);
final List<Selector> rootSels = new ArrayList<Selector>();
Collections.addAll(rootSels,
Selector.createSelector(".root")
);
! Rule rootRule = new Rule(rootSels, rootDecls);
! Stylesheet stylesheet = new Stylesheet("testRT_21212");
stylesheet.setOrigin(StyleOrigin.USER_AGENT);
stylesheet.getRules().add(rootRule);
Group group = new Group();
group.getStyleClass().add("root");
--- 209,231 ----
@Test
public void testRT_21212() {
final List<Declaration> rootDecls = new ArrayList<Declaration>();
Collections.addAll(rootDecls,
! DeclarationShim.getDeclaration("-fx-font-size", new ParsedValueImpl<ParsedValue<?,Size>,Number>(
new ParsedValueImpl<Size,Size>(new Size(12, SizeUnits.PX), null),
SizeConverter.getInstance()), false)
);
final List<Selector> rootSels = new ArrayList<Selector>();
Collections.addAll(rootSels,
Selector.createSelector(".root")
);
! Rule rootRule = RuleShim.getRule(rootSels, rootDecls);
! Stylesheet stylesheet = new StylesheetShim("testRT_21212");
stylesheet.setOrigin(StyleOrigin.USER_AGENT);
stylesheet.getRules().add(rootRule);
Group group = new Group();
group.getStyleClass().add("root");
*** 226,245 ****
null,
null
};
final List<Declaration> textDecls = new ArrayList<Declaration>();
Collections.addAll(textDecls,
! new Declaration("-fx-font", new ParsedValueImpl<ParsedValue[], Font>(
fontValues, FontConverter.getInstance()), false)
);
final List<Selector> textSels = new ArrayList<Selector>();
Collections.addAll(textSels,
Selector.createSelector(".text")
);
! Rule textRule = new Rule(textSels, textDecls);
stylesheet.getRules().add(textRule);
Text text = new Text("HelloWorld");
text.getStyleClass().add("text");
group.getChildren().add(text);
--- 240,259 ----
null,
null
};
final List<Declaration> textDecls = new ArrayList<Declaration>();
Collections.addAll(textDecls,
! DeclarationShim.getDeclaration("-fx-font", new ParsedValueImpl<ParsedValue[], Font>(
fontValues, FontConverter.getInstance()), false)
);
final List<Selector> textSels = new ArrayList<Selector>();
Collections.addAll(textSels,
Selector.createSelector(".text")
);
! Rule textRule = RuleShim.getRule(textSels, textDecls);
stylesheet.getRules().add(textRule);
Text text = new Text("HelloWorld");
text.getStyleClass().add("text");
group.getChildren().add(text);
*** 269,298 ****
}
@Test
public void testRT_34799() {
! Stylesheet stylesheet = new Stylesheet("testRT_34799");
stylesheet.setOrigin(StyleOrigin.USER_AGENT);
final List<Declaration> txtDecls = new ArrayList<Declaration>();
Collections.addAll(txtDecls,
! new Declaration("-fx-fill", new ParsedValueImpl<Color,Color>(Color.RED, null), false)
);
final List<Selector> textSels = new ArrayList<Selector>();
Collections.addAll(textSels,
Selector.createSelector(".rt-34799")
);
! Rule txtRules = new Rule(textSels, txtDecls);
stylesheet.getRules().add(txtRules);
final List<Style> expectedStyles = new ArrayList<>();
for (Rule rule : stylesheet.getRules()) {
for (Selector selector : rule.getSelectors()) {
! for (Declaration declaration : rule.getUnobservedDeclarationList()) {
expectedStyles.add(
new Style(selector, declaration)
);
}
}
--- 283,312 ----
}
@Test
public void testRT_34799() {
! Stylesheet stylesheet = new StylesheetShim("testRT_34799");
stylesheet.setOrigin(StyleOrigin.USER_AGENT);
final List<Declaration> txtDecls = new ArrayList<Declaration>();
Collections.addAll(txtDecls,
! DeclarationShim.getDeclaration("-fx-fill", new ParsedValueImpl<Color,Color>(Color.RED, null), false)
);
final List<Selector> textSels = new ArrayList<Selector>();
Collections.addAll(textSels,
Selector.createSelector(".rt-34799")
);
! Rule txtRules = RuleShim.getRule(textSels, txtDecls);
stylesheet.getRules().add(txtRules);
final List<Style> expectedStyles = new ArrayList<>();
for (Rule rule : stylesheet.getRules()) {
for (Selector selector : rule.getSelectors()) {
! for (Declaration declaration : RuleShim.getUnobservedDeclarationList(rule)) {
expectedStyles.add(
new Style(selector, declaration)
);
}
}