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