1 /*
   2  * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.css;
  27 
  28 import java.io.File;
  29 import java.lang.reflect.InvocationTargetException;
  30 import java.lang.reflect.Method;
  31 import java.lang.reflect.Modifier;
  32 import java.net.URL;
  33 import java.util.ArrayList;
  34 import java.util.Arrays;
  35 import java.util.Collections;
  36 import java.util.List;
  37 import java.util.Set;
  38 
  39 import com.sun.javafx.css.ParsedValueImpl;
  40 import com.sun.javafx.css.PseudoClassState;
  41 import com.sun.javafx.css.StyleManager;
  42 import com.sun.javafx.css.TestNode;
  43 import com.sun.javafx.css.TestNodeBase;
  44 import com.sun.javafx.sg.prism.NGNode;
  45 import javafx.beans.value.WritableValue;
  46 import javafx.scene.Group;
  47 import javafx.scene.Node;
  48 import javafx.scene.Scene;
  49 import javafx.scene.paint.Color;
  50 import javafx.scene.shape.Rectangle;
  51 import javafx.scene.text.Font;
  52 import javafx.scene.text.Text;
  53 import javafx.stage.Stage;
  54 import javafx.css.converter.BooleanConverter;
  55 import com.sun.javafx.geom.BaseBounds;
  56 import com.sun.javafx.geom.transform.BaseTransform;
  57 import com.sun.javafx.jmx.MXNodeAlgorithm;
  58 import com.sun.javafx.jmx.MXNodeAlgorithmContext;
  59 import org.junit.Test;
  60 
  61 import static org.junit.Assert.*;
  62 
  63 
  64 public class CssMetaDataTest {
  65 
  66     public CssMetaDataTest() {
  67     }
  68 
  69     private static CssMetaData get(List<CssMetaData<? extends Styleable, ?>> list, String prop) {
  70         for (CssMetaData styleable : list) {
  71             if (prop.equals(styleable.getProperty())) return styleable;
  72         }
  73         return null;
  74     }
  75 
  76     /**
  77      * Test of getCssMetaData method of class Styleable.
  78      */
  79     @Test
  80     public void testGetCssMetaData_Styleable() {
  81         Styleable styleable = new TestNode();
  82         List<CssMetaData<? extends Styleable, ?>> expResult = TestNode.getClassCssMetaData();
  83         List result = styleable.getCssMetaData();
  84         assertEquals(expResult, result);
  85     }
  86 
  87     @Test
  88     public void testGetJavafxBeansProperty() {
  89         TestNode testNode = new TestNode();
  90         WritableValue prop = TestNodeBase.StyleableProperties.TEST.getStyleableProperty(testNode);
  91         assert(prop != null);
  92         CssMetaData result = ((StyleableProperty)prop).getCssMetaData();
  93         assert(result == TestNodeBase.StyleableProperties.TEST);
  94     }
  95 
  96     /**
  97      * Test of getProperty method, of class CssMetaData.
  98      */
  99     @Test
 100     public void testGetProperty() {
 101 
 102         String expResult = "-fx-test";
 103         String result = TestNodeBase.StyleableProperties.TEST.getProperty();
 104         assertEquals(expResult, result);
 105     }
 106 
 107     /**
 108      * Test of getConverter method, of class CssMetaData.
 109      */
 110     @Test
 111     public void testGetConverter() {
 112 
 113         StyleConverter expResult = BooleanConverter.getInstance();
 114         StyleConverter result = TestNodeBase.StyleableProperties.TEST.getConverter();
 115         assertEquals(expResult, result);
 116     }
 117 
 118     /**
 119      * Test of getInitialValue method, of class CssMetaData.
 120      */
 121     @Test
 122     public void testGetInitialValue() {
 123 
 124         TestNode testNode = new TestNode();
 125         Double expResult = testNode.getXyzzy();
 126         Double result = (Double)TestNode.StyleableProperties.XYZZY.getInitialValue(testNode);
 127         assertEquals(expResult, result);
 128 
 129     }
 130 
 131     /**
 132      * Test of getSubProperties method, of class CssMetaData.
 133      */
 134     @Test
 135     public void testGetSubProperties() {
 136 
 137         CssMetaData<TestNode,Font> fontProp =
 138                 new FontCssMetaData<TestNode>("-fx-font", Font.getDefault()) {
 139 
 140                     @Override
 141                     public boolean isSettable(TestNode n) {
 142                         return true;
 143                     }
 144 
 145                     @Override
 146                     public StyleableProperty<Font> getStyleableProperty(TestNode n) {
 147                         return null;
 148                     }
 149                 };
 150 
 151         List<CssMetaData<? extends Styleable, ?>> list = fontProp.getSubProperties();
 152         assertNotNull(list);
 153 
 154     }
 155 
 156     /**
 157      * Test of isInherits method, of class CssMetaData.
 158      */
 159     @Test
 160     public void testIsInherits() {
 161 
 162         boolean expResult = false;
 163         boolean result = TestNode.StyleableProperties.XYZZY.isInherits();
 164         assertEquals(expResult, result);
 165 
 166     }
 167 
 168     /**
 169      * Test of toString method, of class CssMetaData.
 170      */
 171     @Test
 172     public void testToString() {
 173 
 174         CssMetaData<TestNode,Font> fontProp =
 175                 new FontCssMetaData<TestNode>("-fx-font", Font.getDefault()) {
 176 
 177                     @Override
 178                     public boolean isSettable(TestNode n) {
 179                         return true;
 180                     }
 181 
 182                     @Override
 183                     public StyleableProperty<Font> getStyleableProperty(TestNode n) {
 184                         return null;
 185                     }
 186                 };
 187 
 188         String string = fontProp.toString();
 189         assertNotNull(string);
 190 
 191     }
 192 
 193     /**
 194      * Test of equals method, of class CssMetaData.
 195      */
 196     @Test
 197     public void testEquals() {
 198         TestNode testNode = new TestNode();
 199         Node node = new Node() {
 200 
 201             @Override
 202             protected NGNode impl_createPeer() {
 203                 throw new UnsupportedOperationException("Not supported yet.");
 204             }
 205 
 206             @Override
 207             public BaseBounds impl_computeGeomBounds(BaseBounds bb, BaseTransform bt) {
 208                 throw new UnsupportedOperationException("Not supported yet.");
 209             }
 210 
 211             @Override
 212             protected boolean impl_computeContains(double d, double d1) {
 213                 throw new UnsupportedOperationException("Not supported yet.");
 214             }
 215 
 216             @Override
 217             public Object impl_processMXNode(MXNodeAlgorithm mxna, MXNodeAlgorithmContext mxnac) {
 218                 throw new UnsupportedOperationException("Not supported yet.");
 219             }
 220         };
 221 
 222         CssMetaData testNodeOpacity = get(TestNode.getClassCssMetaData(), "-fx-opacity");
 223         CssMetaData nodeOpacity = get(Node.getClassCssMetaData(), "-fx-opacity");
 224 
 225         assertTrue(testNodeOpacity.equals(nodeOpacity));
 226     }
 227 
 228     static int ord = 0;
 229     static CascadingStyle createCascadingStyle(Selector selector, Declaration declaration) {
 230 
 231         Set<PseudoClass> pseudoClasses = null;
 232         if (selector instanceof SimpleSelector) {
 233 
 234             pseudoClasses = ((SimpleSelector)selector).getPseudoClassStates();
 235         } else {
 236 
 237             pseudoClasses = new PseudoClassState();
 238             for (SimpleSelector sel : ((CompoundSelector)selector).getSelectors()) {
 239 
 240                 Set<PseudoClass> selectorPseudoClasses = sel.getPseudoClassStates();
 241                 pseudoClasses.addAll(selectorPseudoClasses);
 242             }
 243         }
 244 
 245         return new CascadingStyle(
 246                 new Style(selector, declaration),
 247                 pseudoClasses,
 248                 0,
 249                 ord++
 250         );
 251     }
 252 
 253     @Test @org.junit.Ignore
 254     public void testGetMatchingStyles() {
 255 
 256 
 257         final Stylesheet stylesheet = new Stylesheet();
 258         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
 259         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 260 
 261         final List<Rule> rules = stylesheet.getRules();
 262 
 263         //
 264         // .root { -fx-base: red; -fx-color: -fx-base; }
 265         //
 266         List<String> rootStyleClass = new ArrayList<String>();
 267         rootStyleClass.add("root");
 268 
 269         Selector root = new SimpleSelector("*", rootStyleClass, null, null);
 270 
 271         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
 272         Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
 273 
 274         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
 275         Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
 276 
 277         List<Selector> selectors = new ArrayList<Selector>();
 278         Collections.addAll(selectors, root);
 279 
 280         List<Declaration> declarations = new ArrayList<Declaration>();
 281         Collections.addAll(declarations, fxBase, fxColor);
 282 
 283         Rule baseRule = new Rule(selectors, declarations);
 284         rules.add(baseRule);
 285 
 286         //
 287         // .rect { -fx-fill: -fx-color; }
 288         //
 289         List<String> rectStyleClass = new ArrayList<String>();
 290         rectStyleClass.add("rect");
 291 
 292         Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
 293 
 294         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
 295         Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
 296 
 297         selectors = new ArrayList<Selector>();
 298         Collections.addAll(selectors, rect);
 299 
 300         declarations = new ArrayList<Declaration>();
 301         Collections.addAll(declarations, fxFill);
 302 
 303         Rule rectRule = new Rule(selectors, declarations);
 304         rules.add(rectRule);
 305 
 306         // .rect:hover { -fx-fill: yellow; }
 307         List<String> pseudoclasses = new ArrayList<String>();
 308         pseudoclasses.add("hover");
 309 
 310         Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
 311 
 312         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
 313         Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
 314 
 315         selectors = new ArrayList<Selector>();
 316         Collections.addAll(selectors, rectHover);
 317 
 318         declarations = new ArrayList<Declaration>();
 319         Collections.addAll(declarations, fxFillHover);
 320 
 321         Rule rectHoverRule = new Rule(selectors, declarations);
 322         rules.add(rectHoverRule);
 323 
 324         List<Style> expecteds = new ArrayList<Style>();
 325         Collections.addAll(expecteds,
 326                            new Style(root, fxBase),
 327                            new Style(root, fxColor),
 328                            new Style(rect, fxFill),
 329                            new Style(rectHover, fxFillHover)
 330         );
 331 
 332         final Rectangle rectangle = new Rectangle();
 333         rectangle.getStyleClass().add("rect");
 334 
 335         final Group group = new Group();
 336         group.getChildren().add(rectangle);
 337 
 338         Scene scene = new Scene(group);
 339         Stage stage = new Stage();
 340         stage.setScene(scene);
 341         stage.show();
 342 
 343         final CssMetaData FILL = get(rectangle.getCssMetaData(), "-fx-fill");
 344         final List<Style> actuals = Node.impl_getMatchingStyles(FILL, rectangle);
 345 
 346         //        System.err.println("matchingStyles: " + matchingStyles);
 347         //        System.err.println("expecteds: " + expecteds);
 348         //        System.err.println("actuals: " + actuals);
 349 
 350         assertEquals(expecteds.size(), actuals.size(), 0);
 351 
 352         for (Style style : expecteds) {
 353             if (!actuals.remove(style)) fail();
 354         }
 355         assertTrue(actuals.isEmpty());
 356     }
 357 
 358     @Test @org.junit.Ignore
 359     public void testGetMatchingStylesWithInlineStyleOnParent() {
 360 
 361 
 362         final Stylesheet stylesheet = new Stylesheet();
 363         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
 364         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 365 
 366         final List<Rule> rules = stylesheet.getRules();
 367 
 368         //
 369         // .root { -fx-base: red; -fx-color: -fx-base; }
 370         //
 371         List<String> rootStyleClass = new ArrayList<String>();
 372         rootStyleClass.add("root");
 373 
 374         Selector root = new SimpleSelector("*", rootStyleClass, null, null);
 375 
 376         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
 377         Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
 378 
 379         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
 380         Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
 381 
 382         List<Selector> selectors = new ArrayList<Selector>();
 383         Collections.addAll(selectors, root);
 384 
 385         List<Declaration> declarations = new ArrayList<Declaration>();
 386         Collections.addAll(declarations, fxBase, fxColor);
 387 
 388         Rule baseRule = new Rule(selectors, declarations);
 389         rules.add(baseRule);
 390 
 391         //
 392         // .rect { -fx-fill: -fx-color; }
 393         //
 394         List<String> rectStyleClass = new ArrayList<String>();
 395         rectStyleClass.add("rect");
 396 
 397         Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
 398 
 399         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
 400         Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
 401 
 402         selectors = new ArrayList<Selector>();
 403         Collections.addAll(selectors, rect);
 404 
 405         declarations = new ArrayList<Declaration>();
 406         Collections.addAll(declarations, fxFill);
 407 
 408         Rule rectRule = new Rule(selectors, declarations);
 409         rules.add(rectRule);
 410 
 411         // .rect:hover { -fx-fill: yellow; }
 412         List<String> pseudoclasses = new ArrayList<String>();
 413         pseudoclasses.add("hover");
 414 
 415         Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
 416 
 417         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
 418         Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
 419 
 420         selectors = new ArrayList<Selector>();
 421         Collections.addAll(selectors, rectHover);
 422 
 423         declarations = new ArrayList<Declaration>();
 424         Collections.addAll(declarations, fxFillHover);
 425 
 426         Rule rectHoverRule = new Rule(selectors, declarations);
 427         rules.add(rectHoverRule);
 428 
 429         // Declaration now checks origin, so we need to make this expected
 430         // value look like it came from an inline
 431         final Declaration decl = new Declaration("-fx-base", new ParsedValueImpl<Color,Color>(Color.GREEN, null), false);
 432 
 433         Stylesheet ss = new Stylesheet() {
 434             {
 435                 setOrigin(StyleOrigin.INLINE);
 436                 getRules().add(
 437                         new Rule(Arrays.asList(SimpleSelector.getUniversalSelector()), Arrays.asList(decl))
 438                 );
 439             }
 440         };
 441 
 442         List<Style> expecteds = new ArrayList<Style>();
 443         Collections.addAll(expecteds,
 444                            new Style(SimpleSelector.getUniversalSelector(), decl),
 445                            new Style(root, fxBase),
 446                            new Style(root, fxColor),
 447                            new Style(rect, fxFill),
 448                            new Style(rectHover, fxFillHover)
 449         );
 450 
 451         final Rectangle rectangle = new Rectangle();
 452         rectangle.getStyleClass().add("rect");
 453 
 454         final Group group = new Group();
 455         group.setStyle("-fx-base: green;");
 456         group.getChildren().add(rectangle);
 457 
 458         Scene scene = new Scene(group);
 459         Stage stage = new Stage();
 460         stage.setScene(scene);
 461         stage.show();
 462 
 463         final CssMetaData FILL = get(rectangle.getCssMetaData(), "-fx-fill");
 464         final List<Style> actuals = Node.impl_getMatchingStyles(FILL, rectangle);
 465 
 466         //        System.err.println("matchingStyles: " + matchingStyles);
 467         //        System.err.println("expecteds: " + expecteds);
 468         //        System.err.println("actuals: " + actuals);
 469 
 470         assertEquals(expecteds.size(), actuals.size(), 0);
 471 
 472         // inline style should be first
 473         assertEquals(expecteds.get(0), actuals.get(0));
 474 
 475         for (Style style : expecteds) {
 476             if (!actuals.remove(style)) fail();
 477         }
 478         assertTrue(actuals.isEmpty());
 479     }
 480 
 481     @Test @org.junit.Ignore
 482     public void testGetMatchingStylesWithInlineStyleOnLeaf() {
 483 
 484 
 485         final Stylesheet stylesheet = new Stylesheet();
 486         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
 487         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 488 
 489         final List<Rule> rules = stylesheet.getRules();
 490 
 491         //
 492         // .root { -fx-base: red; -fx-color: -fx-base; }
 493         //
 494         List<String> rootStyleClass = new ArrayList<String>();
 495         rootStyleClass.add("root");
 496 
 497         Selector root = new SimpleSelector("*", rootStyleClass, null, null);
 498 
 499         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
 500         Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
 501 
 502         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
 503         Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
 504 
 505         List<Selector> selectors = new ArrayList<Selector>();
 506         Collections.addAll(selectors, root);
 507 
 508         List<Declaration> declarations = new ArrayList<Declaration>();
 509         Collections.addAll(declarations, fxBase, fxColor);
 510 
 511         Rule baseRule = new Rule(selectors, declarations);
 512         rules.add(baseRule);
 513 
 514         //
 515         // .rect { -fx-fill: -fx-color; }
 516         //
 517         List<String> rectStyleClass = new ArrayList<String>();
 518         rectStyleClass.add("rect");
 519 
 520         Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
 521 
 522         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
 523         Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
 524 
 525         selectors = new ArrayList<Selector>();
 526         Collections.addAll(selectors, rect);
 527 
 528         declarations = new ArrayList<Declaration>();
 529         Collections.addAll(declarations, fxFill);
 530 
 531         Rule rectRule = new Rule(selectors, declarations);
 532         rules.add(rectRule);
 533 
 534         // .rect:hover { -fx-fill: yellow; }
 535         List<String> pseudoclasses = new ArrayList<String>();
 536         pseudoclasses.add("hover");
 537 
 538         Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
 539 
 540         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
 541         Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
 542 
 543         selectors = new ArrayList<Selector>();
 544         Collections.addAll(selectors, rectHover);
 545 
 546         declarations = new ArrayList<Declaration>();
 547         Collections.addAll(declarations, fxFillHover);
 548 
 549         Rule rectHoverRule = new Rule(selectors, declarations);
 550         rules.add(rectHoverRule);
 551 
 552         // Declaration now checks origin, so we need to make this expected
 553         // value look like it came from an inline
 554         final Declaration decl = new Declaration("-fx-base", new ParsedValueImpl<Color,Color>(Color.GREEN, null), false);
 555 
 556         Stylesheet ss = new Stylesheet() {
 557             {
 558                 setOrigin(StyleOrigin.INLINE);
 559                 getRules().add(
 560                         new Rule(Arrays.asList(SimpleSelector.getUniversalSelector()), Arrays.asList(decl))
 561                 );
 562             }
 563         };
 564 
 565         List<Style> expecteds = new ArrayList<Style>();
 566         Collections.addAll(expecteds,
 567                            new Style(SimpleSelector.getUniversalSelector(), decl),
 568                            new Style(root, fxBase),
 569                            new Style(root, fxColor),
 570                            new Style(rect, fxFill),
 571                            new Style(rectHover, fxFillHover)
 572         );
 573 
 574         final Rectangle rectangle = new Rectangle();
 575         rectangle.getStyleClass().add("rect");
 576         rectangle.setStyle("-fx-base: green;");
 577 
 578         final Group group = new Group();
 579         group.getChildren().add(rectangle);
 580 
 581         Scene scene = new Scene(group);
 582         Stage stage = new Stage();
 583         stage.setScene(scene);
 584         stage.show();
 585 
 586         final CssMetaData FILL = get(rectangle.getCssMetaData(), "-fx-fill");
 587         final List<Style> actuals = Node.impl_getMatchingStyles(FILL, rectangle);
 588 
 589         //        System.err.println("matchingStyles: " + matchingStyles);
 590         //        System.err.println("expecteds: " + expecteds);
 591         //        System.err.println("actuals: " + actuals);
 592 
 593         assertEquals(expecteds.size(), actuals.size(), 0);
 594 
 595         // inline style should be first
 596         assertEquals(expecteds.get(0), actuals.get(0));
 597 
 598         for (Style style : expecteds) {
 599             if (!actuals.remove(style)) fail();
 600         }
 601         assertTrue(actuals.isEmpty());
 602     }
 603 
 604     @Test @org.junit.Ignore
 605     public void testGetMatchingStylesWithInlineStyleOnRootAndLeaf() {
 606 
 607 
 608         final Stylesheet stylesheet = new Stylesheet();
 609         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
 610         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 611 
 612         final List<Rule> rules = stylesheet.getRules();
 613 
 614         //
 615         // .root { -fx-base: red; -fx-color: -fx-base; }
 616         //
 617         List<String> rootStyleClass = new ArrayList<String>();
 618         rootStyleClass.add("root");
 619 
 620         Selector root = new SimpleSelector("*", rootStyleClass, null, null);
 621 
 622         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
 623         Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
 624 
 625         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
 626         Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
 627 
 628         List<Selector> selectors = new ArrayList<Selector>();
 629         Collections.addAll(selectors, root);
 630 
 631         List<Declaration> declarations = new ArrayList<Declaration>();
 632         Collections.addAll(declarations, fxBase, fxColor);
 633 
 634         Rule baseRule = new Rule(selectors, declarations);
 635         rules.add(baseRule);
 636 
 637         //
 638         // .rect { -fx-fill: -fx-color; }
 639         //
 640         List<String> rectStyleClass = new ArrayList<String>();
 641         rectStyleClass.add("rect");
 642 
 643         Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
 644 
 645         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
 646         Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
 647 
 648         selectors = new ArrayList<Selector>();
 649         Collections.addAll(selectors, rect);
 650 
 651         declarations = new ArrayList<Declaration>();
 652         Collections.addAll(declarations, fxFill);
 653 
 654         Rule rectRule = new Rule(selectors, declarations);
 655         rules.add(rectRule);
 656 
 657         // .rect:hover { -fx-fill: yellow; }
 658         List<String> pseudoclasses = new ArrayList<String>();
 659         pseudoclasses.add("hover");
 660 
 661         Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
 662 
 663         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
 664         Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
 665 
 666         selectors = new ArrayList<Selector>();
 667         Collections.addAll(selectors, rectHover);
 668 
 669         declarations = new ArrayList<Declaration>();
 670         Collections.addAll(declarations, fxFillHover);
 671 
 672         Rule rectHoverRule = new Rule(selectors, declarations);
 673         rules.add(rectHoverRule);
 674 
 675         // Declaration now checks origin, so we need to make this expected
 676         // value look like it came from an inline
 677         final Declaration gdecl = new Declaration("-fx-base", new ParsedValueImpl<Color,Color>(Color.GREEN, null), false);
 678         final Declaration ydecl = new Declaration("-fx-color", new ParsedValueImpl<Color,Color>(Color.YELLOW, null), false);
 679 
 680         Stylesheet ss = new Stylesheet() {
 681             {
 682                 setOrigin(StyleOrigin.INLINE);
 683                 Collections.addAll(getRules(),
 684                                    new Rule(Arrays.asList(SimpleSelector.getUniversalSelector()), Arrays.asList(gdecl)),
 685                                    new Rule(Arrays.asList(SimpleSelector.getUniversalSelector()), Arrays.asList(ydecl))
 686                 );
 687             }
 688         };
 689 
 690         List<Style> expecteds = new ArrayList<Style>();
 691         Collections.addAll(expecteds,
 692                            new Style(SimpleSelector.getUniversalSelector(), ydecl),
 693                            new Style(SimpleSelector.getUniversalSelector(), gdecl),
 694                            new Style(root, fxBase),
 695                            new Style(root, fxColor),
 696                            new Style(rect, fxFill),
 697                            new Style(rectHover, fxFillHover)
 698         );
 699 
 700         final Rectangle rectangle = new Rectangle();
 701         rectangle.getStyleClass().add("rect");
 702         rectangle.setStyle("-fx-base: green;");
 703 
 704         final Group group = new Group();
 705         group.setStyle("-fx-color: yellow;");
 706         group.getChildren().add(rectangle);
 707 
 708         Scene scene = new Scene(group);
 709         Stage stage = new Stage();
 710         stage.setScene(scene);
 711         stage.show();
 712 
 713         final CssMetaData FILL = get(rectangle.getCssMetaData(), "-fx-fill");
 714         final List<Style> actuals = Node.impl_getMatchingStyles(FILL, rectangle);
 715 
 716         //        System.err.println("matchingStyles: " + matchingStyles);
 717         //        System.err.println("expecteds: " + expecteds);
 718         //        System.err.println("actuals: " + actuals);
 719 
 720         assertEquals(expecteds.size(), actuals.size(), 0);
 721 
 722         // inline style should be first
 723         assertEquals(expecteds.get(0), actuals.get(0));
 724 
 725         for (Style style : expecteds) {
 726             if (!actuals.remove(style)) fail(style.toString());
 727         }
 728         assertTrue(actuals.isEmpty());
 729     }
 730 
 731     @Test @org.junit.Ignore
 732     public void testGetMatchingStylesShouldNotReturnAncestorPropertyIfNotInherited() {
 733 
 734 
 735         final Stylesheet stylesheet = new Stylesheet();
 736         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
 737         StyleManager.getInstance().getInstance().setDefaultUserAgentStylesheet(stylesheet);
 738 
 739         final List<Rule> rules = stylesheet.getRules();
 740 
 741         //
 742         // .root { -fx-base: red; -fx-color: -fx-base; }
 743         //
 744         List<String> rootStyleClass = new ArrayList<String>();
 745         rootStyleClass.add("root");
 746 
 747         Selector root = new SimpleSelector("*", rootStyleClass, null, null);
 748 
 749         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
 750         Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
 751 
 752         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
 753         Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
 754 
 755         ParsedValueImpl<Color,Color> fxFillShouldNotMatchValue = new ParsedValueImpl<Color,Color>(Color.RED, null);
 756         Declaration fxFillShouldNotMatch = new Declaration("-fx-fill", fxFillShouldNotMatchValue, false);
 757 
 758         List<Selector> selectors = new ArrayList<Selector>();
 759         Collections.addAll(selectors, root);
 760 
 761         List<Declaration> declarations = new ArrayList<Declaration>();
 762         Collections.addAll(declarations, fxBase, fxColor, fxFillShouldNotMatch);
 763 
 764         Rule baseRule = new Rule(selectors, declarations);
 765         rules.add(baseRule);
 766 
 767         //
 768         // .rect { -fx-fill: -fx-color; }
 769         //
 770         List<String> rectStyleClass = new ArrayList<String>();
 771         rectStyleClass.add("rect");
 772 
 773         Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
 774 
 775         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
 776         Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
 777 
 778         selectors = new ArrayList<Selector>();
 779         Collections.addAll(selectors, rect);
 780 
 781         declarations = new ArrayList<Declaration>();
 782         Collections.addAll(declarations, fxFill);
 783 
 784         Rule rectRule = new Rule(selectors, declarations);
 785         rules.add(rectRule);
 786 
 787         // .rect:hover { -fx-fill: yellow; }
 788         List<String> pseudoclasses = new ArrayList<String>();
 789         pseudoclasses.add("hover");
 790 
 791         Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
 792 
 793         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
 794         Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
 795 
 796         selectors = new ArrayList<Selector>();
 797         Collections.addAll(selectors, rectHover);
 798 
 799         declarations = new ArrayList<Declaration>();
 800         Collections.addAll(declarations, fxFillHover);
 801 
 802         Rule rectHoverRule = new Rule(selectors, declarations);
 803         rules.add(rectHoverRule);
 804 
 805         List<Style> expecteds = new ArrayList<Style>();
 806         Collections.addAll(expecteds,
 807                            new Style(root, fxBase),
 808                            new Style(root, fxColor),
 809                            new Style(rect, fxFill),
 810                            new Style(rectHover, fxFillHover)
 811         );
 812 
 813         final Rectangle rectangle = new Rectangle();
 814         rectangle.getStyleClass().add("rect");
 815 
 816         final Group group = new Group();
 817         group.getChildren().add(rectangle);
 818 
 819         Scene scene = new Scene(group);
 820         Stage stage = new Stage();
 821         stage.setScene(scene);
 822         stage.show();
 823 
 824         final CssMetaData FILL = get(rectangle.getCssMetaData(), "-fx-fill");
 825         final List<Style> actuals = Node.impl_getMatchingStyles(FILL, rectangle);
 826 
 827         //        System.err.println("matchingStyles: " + matchingStyles);
 828         //        System.err.println("expecteds: " + expecteds);
 829         //        System.err.println("actuals: " + actuals);
 830 
 831         assertEquals(expecteds.size(), actuals.size(), 0);
 832 
 833         for (Style style : expecteds) {
 834             if (!actuals.remove(style)) fail();
 835         }
 836         assertTrue(actuals.isEmpty());
 837     }
 838 
 839 
 840     @Test @org.junit.Ignore
 841     public void testGetMatchingStylesShouldNotReturnInlineAncestorPropertyIfNotInherited() {
 842 
 843         final Stylesheet stylesheet = new Stylesheet();
 844         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
 845         StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
 846 
 847         final List<Rule> rules = stylesheet.getRules();
 848 
 849         List<String> rootStyleClass = new ArrayList<String>();
 850         rootStyleClass.add("root");
 851 
 852         List<String> rectStyleClass = new ArrayList<String>();
 853         rectStyleClass.add("rect");
 854 
 855         //
 856         // .root { -fx-base: red; -fx-color: -fx-base; }
 857         //
 858         Selector root = new SimpleSelector("*", rootStyleClass, null, null);
 859 
 860         ParsedValue fxBaseValue = new CssParser().parseExpr("-fx-base", "red");
 861         Declaration fxBase = new Declaration("-fx-base", fxBaseValue, false);
 862 
 863         ParsedValueImpl<String,String> fxColorValue = new ParsedValueImpl<String,String>(fxBase.getProperty(), null, true);
 864         Declaration fxColor = new Declaration("-fx-color", fxColorValue, false);
 865 
 866         ParsedValueImpl<Color,Color> fxFillShouldNotMatchValue = new ParsedValueImpl<Color,Color>(Color.RED, null);
 867         Declaration fxFillShouldNotMatch = new Declaration("-fx-fill", fxFillShouldNotMatchValue, false);
 868 
 869         List<Selector> selectors = new ArrayList<Selector>();
 870         Collections.addAll(selectors, root);
 871 
 872         List<Declaration> declarations = new ArrayList<Declaration>();
 873         Collections.addAll(declarations, fxBase, fxColor, fxFillShouldNotMatch);
 874 
 875         Rule baseRule = new Rule(selectors, declarations);
 876         rules.add(baseRule);
 877 
 878         //
 879         // .rect { -fx-fill: -fx-color; }
 880         //
 881         Selector rect = new SimpleSelector("*", rectStyleClass, null, null);
 882 
 883         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "-fx-color");
 884         Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
 885 
 886         selectors = new ArrayList<Selector>();
 887         Collections.addAll(selectors, rect);
 888 
 889         declarations = new ArrayList<Declaration>();
 890         Collections.addAll(declarations, fxFill);
 891 
 892         Rule rectRule = new Rule(selectors, declarations);
 893         rules.add(rectRule);
 894 
 895         // .rect:hover { -fx-fill: yellow; }
 896         List<String> pseudoclasses = new ArrayList<String>();
 897         pseudoclasses.add("hover");
 898 
 899         Selector rectHover = new SimpleSelector("*", rectStyleClass, pseudoclasses, null);
 900 
 901         ParsedValueImpl<Color,Color> fxFillHoverValue = new ParsedValueImpl<Color,Color>(Color.YELLOW, null);
 902         Declaration fxFillHover = new Declaration("-fx-fill", fxFillHoverValue, false);
 903 
 904         selectors = new ArrayList<Selector>();
 905         Collections.addAll(selectors, rectHover);
 906 
 907         declarations = new ArrayList<Declaration>();
 908         Collections.addAll(declarations, fxFillHover);
 909 
 910         Rule rectHoverRule = new Rule(selectors, declarations);
 911         rules.add(rectHoverRule);
 912 
 913         List<Style> expecteds = new ArrayList<Style>();
 914         Collections.addAll(expecteds,
 915                            new Style(root, fxBase),
 916                            new Style(root, fxColor),
 917                            new Style(rect, fxFill),
 918                            new Style(rectHover, fxFillHover)
 919         );
 920 
 921         final Rectangle rectangle = new Rectangle();
 922         rectangle.getStyleClass().add("rect");
 923 
 924         final Group group = new Group();
 925         group.getChildren().add(rectangle);
 926 
 927         Scene scene = new Scene(group);
 928         Stage stage = new Stage();
 929         stage.setScene(scene);
 930         stage.show();
 931 
 932         final CssMetaData FILL = get(rectangle.getCssMetaData(), "-fx-fill");
 933         final List<Style> actuals = Node.impl_getMatchingStyles(FILL, rectangle);
 934 
 935         //        System.err.println("matchingStyles: " + matchingStyles);
 936         //        System.err.println("expecteds: " + expecteds);
 937         //        System.err.println("actuals: " + actuals);
 938 
 939         for (Style style : expecteds) {
 940             actuals.remove(style);
 941         }
 942         assertTrue(actuals.toString(), actuals.isEmpty());
 943     }
 944 
 945     @Test @org.junit.Ignore
 946     public void testGetMatchingStylesReturnsInheritedProperty() {
 947 
 948 
 949         final Stylesheet stylesheet = new Stylesheet();
 950         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
 951         StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
 952 
 953         final List<Rule> rules = stylesheet.getRules();
 954 
 955         //
 956         // .root { -fx-base: red; -fx-color: -fx-base; }
 957         //
 958         List<String> rootStyleClass = new ArrayList<String>();
 959         rootStyleClass.add("root");
 960 
 961         Selector root = new SimpleSelector("*", rootStyleClass, null, null);
 962 
 963         ParsedValue<Color,Color> fxFontShouldInheritValue = new CssParser().parseExpr("-fx-font", "12px system");
 964         Declaration fxFontShouldInherit = new Declaration("-fx-font", fxFontShouldInheritValue, false);
 965 
 966         List<Selector> selectors = new ArrayList<Selector>();
 967         Collections.addAll(selectors, root);
 968 
 969         List<Declaration> declarations = new ArrayList<Declaration>();
 970         Collections.addAll(declarations, fxFontShouldInherit);
 971 
 972         Rule baseRule = new Rule(selectors, declarations);
 973         rules.add(baseRule);
 974 
 975         //
 976         // .text { -fx-fill: -fx-color; }
 977         //
 978         List<String> textStyleClass = new ArrayList<String>();
 979         textStyleClass.add("text");
 980 
 981         Selector textSelector = new SimpleSelector("*", textStyleClass, null, null);
 982 
 983         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "red");
 984         Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
 985 
 986         selectors = new ArrayList<Selector>();
 987         Collections.addAll(selectors, textSelector);
 988 
 989         declarations = new ArrayList<Declaration>();
 990         Collections.addAll(declarations, fxFill);
 991 
 992         Rule rectRule = new Rule(selectors, declarations);
 993         rules.add(rectRule);
 994 
 995         List<Style> expecteds = new ArrayList<Style>();
 996         Collections.addAll(expecteds,
 997                            new Style(root, fxFontShouldInherit)
 998         );
 999 
1000         final Text text = new Text("text");
1001         text.getStyleClass().add("text");
1002 
1003         final Group group = new Group();
1004         group.getChildren().add(text);
1005 
1006         Scene scene = new Scene(group);
1007         Stage stage = new Stage();
1008         stage.setScene(scene);
1009         stage.show();
1010 
1011         final CssMetaData FONT = get(text.getCssMetaData(), "-fx-font");
1012         final List<Style> actuals = Node.impl_getMatchingStyles(FONT, text);
1013 
1014         //        System.err.println("matchingStyles: " + matchingStyles);
1015         //        System.err.println("expecteds: " + expecteds);
1016         //        System.err.println("actuals: " + actuals);
1017 
1018         assertEquals(expecteds.size(), actuals.size(), 0);
1019 
1020         for (Style style : expecteds) {
1021             if (!actuals.remove(style)) fail();
1022         }
1023         assertTrue(actuals.isEmpty());
1024     }
1025 
1026     @Test @org.junit.Ignore
1027     public void testGetMatchingStylesReturnsSubProperty() {
1028 
1029         final Stylesheet stylesheet = new Stylesheet();
1030         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
1031         StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
1032 
1033         final List<Rule> rules = stylesheet.getRules();
1034 
1035         //
1036         // .root { -fx-base: red; -fx-color: -fx-base; }
1037         //
1038         List<String> rootStyleClass = new ArrayList<String>();
1039         rootStyleClass.add("root");
1040 
1041         Selector root = new SimpleSelector("*", rootStyleClass, null, null);
1042 
1043         ParsedValue<Color,Color> fxFontShouldInheritValue = new CssParser().parseExpr("-fx-font", "12px system");
1044         Declaration fxFontShouldInherit = new Declaration("-fx-font", fxFontShouldInheritValue, false);
1045 
1046         List<Selector> selectors = new ArrayList<Selector>();
1047         Collections.addAll(selectors, root);
1048 
1049         List<Declaration> declarations = new ArrayList<Declaration>();
1050         Collections.addAll(declarations, fxFontShouldInherit);
1051 
1052         Rule baseRule = new Rule(selectors, declarations);
1053         rules.add(baseRule);
1054 
1055         //
1056         // .text { -fx-fill: -fx-color; }
1057         //
1058         List<String> rectStyleClass = new ArrayList<String>();
1059         rectStyleClass.add("text");
1060 
1061         Selector textSelector = new SimpleSelector("*", rectStyleClass, null, null);
1062 
1063         ParsedValue fxFillValue = new CssParser().parseExpr("-fx-fill", "red");
1064         Declaration fxFill = new Declaration("-fx-fill", fxFillValue, false);
1065 
1066         ParsedValue fxFontFamilyValue = new CssParser().parseExpr("-fx-font-family", "arial");
1067         Declaration fxFontFamily = new Declaration("-fx-font-family", fxFontFamilyValue, false);
1068 
1069         selectors = new ArrayList<Selector>();
1070         Collections.addAll(selectors, textSelector);
1071 
1072         declarations = new ArrayList<Declaration>();
1073         Collections.addAll(declarations, fxFill, fxFontFamily);
1074 
1075         Rule rectRule = new Rule(selectors, declarations);
1076         rules.add(rectRule);
1077 
1078         List<Style> expecteds = new ArrayList<Style>();
1079         Collections.addAll(expecteds,
1080                            new Style(textSelector, fxFontFamily),
1081                            new Style(root, fxFontShouldInherit)
1082         );
1083 
1084         final Text text  = new Text();
1085         text.getStyleClass().add("text");
1086 
1087         final Group group = new Group();
1088         group.getChildren().add(text);
1089 
1090         Scene scene = new Scene(group);
1091         Stage stage = new Stage();
1092         stage.setScene(scene);
1093         stage.show();
1094 
1095         final CssMetaData FONT = get(text.getCssMetaData(), "-fx-font");
1096         final List<Style> actuals = Node.impl_getMatchingStyles(FONT, text);
1097 
1098         //        System.err.println("matchingStyles: " + matchingStyles);
1099         //        System.err.println("expecteds: " + expecteds);
1100         //        System.err.println("actuals: " + actuals);
1101 
1102         assertEquals(expecteds.size(), actuals.size(), 0);
1103 
1104         for (Style style : expecteds) {
1105             if (!actuals.remove(style)) fail();
1106         }
1107         assertTrue(actuals.isEmpty());
1108     }
1109 
1110     @Test
1111     public void testRT18097() {
1112         try {
1113             File f = System.getProperties().containsKey("CSS_META_DATA_TEST_DIR") ?
1114                     new File(System.getProperties().get("CSS_META_DATA_TEST_DIR").toString()) :
1115                     null;
1116             if (f == null) {
1117                 ClassLoader cl = Thread.currentThread().getContextClassLoader();
1118                 URL base = cl.getResource("javafx/../javafx");
1119                 f = new File(base.toURI());
1120             }
1121             //System.err.println(f.getPath());
1122             recursiveCheck(f, f.getPath().length() - 7);
1123         } catch (Exception ex) {
1124             ex.printStackTrace(System.err);
1125             fail(ex.getMessage());
1126         }
1127     }
1128 
1129     private static void checkClass(Class someClass) {
1130 
1131         if (javafx.scene.Node.class.isAssignableFrom(someClass) &&
1132                 Modifier.isAbstract(someClass.getModifiers()) == false) {
1133 
1134             String what = someClass.getName();
1135             try {
1136                 // should get NoSuchMethodException if ctor is not public
1137                 //                Constructor ctor = someClass.getConstructor((Class[])null);
1138                 Method m = someClass.getMethod("getClassCssMetaData", (Class[]) null);
1139                 //                Node node = (Node)ctor.newInstance((Object[])null);
1140                 Node node = (Node)someClass.newInstance();
1141                 List<CssMetaData<? extends Styleable, ?>> list = (List<CssMetaData<? extends Styleable, ?>>)m.invoke(null);
1142                 if(list == null || list.isEmpty()) return;
1143 
1144                 for (CssMetaData styleable : list) {
1145 
1146                     what = someClass.getName() + " " + styleable.getProperty();
1147                     WritableValue writable = styleable.getStyleableProperty(node);
1148                     assertNotNull(what, writable);
1149 
1150                     Object defaultValue = writable.getValue();
1151                     Object initialValue = styleable.getInitialValue((Node) someClass.newInstance());
1152 
1153                     if (defaultValue instanceof Number) {
1154                         // 5 and 5.0 are not the same according to equals,
1155                         // but they should be...
1156                         assert(initialValue instanceof Number);
1157                         double d1 = ((Number)defaultValue).doubleValue();
1158                         double d2 = ((Number)initialValue).doubleValue();
1159                         assertEquals(what, d1, d2, .001);
1160 
1161                     } else if (defaultValue != null && defaultValue.getClass().isArray()) {
1162                         assertTrue(what, Arrays.equals((Object[])defaultValue, (Object[])initialValue));
1163                     } else {
1164                         assertEquals(what, defaultValue, initialValue);
1165                     }
1166 
1167                 }
1168 
1169             } catch (NoSuchMethodException ex) {
1170                 System.err.println("NoSuchMethodException: " + what);
1171             } catch (IllegalAccessException ex) {
1172                 System.err.println("IllegalAccessException: " + what);
1173             } catch (IllegalArgumentException ex) {
1174                 System.err.println("IllegalArgumentException: " + what);
1175             } catch (InvocationTargetException ex) {
1176                 System.err.println("InvocationTargetException: " + what);
1177             } catch (InstantiationException ex) {
1178                 System.err.println("InstantiationException: " + what);
1179             }
1180         }
1181     }
1182 
1183     private static void checkDirectory(File directory, final int pathLength) {
1184         if (directory.isDirectory()) {
1185 
1186             for (File file : directory.listFiles()) {
1187                 if (file.isFile() && file.getName().endsWith(".class")) {
1188                     final int len = file.getPath().length() - ".class".length();
1189                     final String clName =
1190                             file.getPath().substring(pathLength+1, len).replace(File.separatorChar,'.');
1191                     try {
1192                         final Class cl = Class.forName(clName);
1193                         if (cl != null) checkClass(cl);
1194                     } catch(ClassNotFoundException ex) {
1195                         System.err.println(ex.toString() + " " + clName);
1196                     }
1197                 }
1198             }
1199         }
1200     }
1201 
1202     private static void recursiveCheck(File directory, int pathLength) {
1203         if (directory.isDirectory()) {
1204             //            System.err.println(directory.getPath());
1205             checkDirectory(directory, pathLength);
1206 
1207             for (File subFile : directory.listFiles()) {
1208                 recursiveCheck(subFile, pathLength);
1209             }
1210         }
1211     }
1212 
1213     @Test @org.junit.Ignore("tested CssMetaData#set method, which is deprecated")
1214     public void testRT_21185() {
1215 
1216         Color c1 = new Color(.1,.2,.3,1.0);
1217         Color c2 = new Color(.1,.2,.3,1.0);
1218 
1219         Rectangle rect = new Rectangle();
1220         rect.setFill(c1);
1221 
1222         StyleableProperty fill = (StyleableProperty)rect.fillProperty();
1223         StyleOrigin origin = ((StyleableProperty)rect.fillProperty()).getStyleOrigin();
1224 
1225         // set should not change the value if the values are equal and origin is same
1226         assertEquals(c1, c2);        
1227         fill.applyStyle(origin, c2);
1228 
1229         assertSame(c1,rect.getFill()); // instance should not change.
1230 
1231         // set should change the value if the values are not equal.
1232         c2 = new Color(.3,.2,.1,1.0);
1233         fill.applyStyle(origin, c2);
1234         assertSame(c2,rect.getFill());
1235 
1236         // set should change the value if the origin is not the same
1237         fill.applyStyle(StyleOrigin.INLINE, c2);
1238         origin = ((StyleableProperty)rect.fillProperty()).getStyleOrigin();
1239         assertSame(StyleOrigin.INLINE, origin);
1240 
1241         // set should change the value if one is null and the other is not.
1242         rect.setFill(null);
1243         fill.applyStyle(origin, c2);
1244         assertSame(c2, rect.getFill());
1245 
1246         // set should change the value if one is null and the other is not
1247         fill.applyStyle(origin, null);
1248         assertNull(rect.getFill());
1249 
1250     }
1251 
1252 
1253     @Test  @org.junit.Ignore
1254     public void testRT_24606() {
1255 
1256         final Stylesheet stylesheet = new CssParser().parse(
1257                 ".root { -fx-base: red; }" +
1258                         ".group { -fx-color: -fx-base; }" +
1259                         ".text { -fx-fill: -fx-color; }"
1260         );
1261         stylesheet.setOrigin(StyleOrigin.USER_AGENT);
1262         StyleManager.getInstance().setDefaultUserAgentStylesheet(stylesheet);
1263 
1264         final Text text = new Text("HelloWorld");
1265         text.getStyleClass().add("text");
1266         text.setFill(Color.BLUE);
1267 
1268         final Group group = new Group();
1269         group.getStyleClass().add("group");
1270         group.getChildren().add(text);
1271 
1272         final Group root = new Group();
1273         root.getChildren().add(group);
1274 
1275         Scene scene = new Scene(root);
1276         Stage stage = new Stage();
1277         stage.setScene(scene);
1278         stage.show();
1279 
1280         CssMetaData prop = ((StyleableProperty)text.fillProperty()).getCssMetaData();
1281         List list = Node.impl_getMatchingStyles(prop, text);
1282 
1283         assertEquals(3, list.size(), 0);
1284 
1285     }
1286 
1287 }