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