modules/graphics/src/test/java/javafx/scene/layout/TilePaneTest.java

Print this page
rev 9240 : 8076423: JEP 253: Prepare JavaFX UI Controls & CSS APIs for Modularization


  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.scene.layout;
  27 
  28 import javafx.css.ParsedValue;
  29 import javafx.css.CssMetaData;
  30 import com.sun.javafx.css.parser.CSSParser;
  31 import javafx.css.StyleableProperty;
  32 import static org.junit.Assert.assertEquals;
  33 import static org.junit.Assert.assertNull;
  34 import javafx.geometry.Insets;
  35 import javafx.geometry.Orientation;
  36 import javafx.geometry.Pos;
  37 import javafx.scene.Node;
  38 import javafx.scene.Scene;
  39 import javafx.scene.shape.Rectangle;
  40 import javafx.stage.Stage;
  41 import org.junit.Assert;
  42 
  43 import org.junit.Before;
  44 import org.junit.Test;
  45 
  46 
  47 public class TilePaneTest {
  48 
  49     TilePane tilepane;
  50     TilePane htilepane;


1009             tilepane.getChildren().add(child);
1010         }
1011 
1012         tilepane.autosize();
1013         tilepane.layout();
1014 
1015         Node first = tilepane.getChildren().get(0);
1016 
1017         assertEquals(0, first.getLayoutX(), 1e-100);
1018         assertEquals(0, first.getLayoutY(), 1e-100);
1019         assertEquals(100, tilepane.getLayoutBounds().getWidth(), 1e-100);
1020         assertEquals(160, tilepane.getLayoutBounds().getHeight(), 1e-100);
1021     }
1022 
1023     @Test public void testCSSsetPrefTileWidthAndHeight_RT20388() {
1024         Scene scene = new Scene(tilepane);
1025         Stage stage = new Stage();
1026         stage.setScene(scene);
1027         stage.show();
1028 
1029         ParsedValue pv = CSSParser.getInstance().parseExpr("-fx-perf-tile-width","67.0");
1030         Object val = pv.convert(null);
1031         try {
1032             ((StyleableProperty)tilepane.prefTileWidthProperty()).applyStyle(null, val);
1033             assertEquals(67.0, tilepane.getPrefTileWidth(), 0.00001);
1034         } catch (Exception e) {
1035             Assert.fail(e.toString());
1036         }
1037     }
1038 
1039     @Test public void testCSSsetPrefRow_RT20437() {
1040         Scene scene = new Scene(tilepane);
1041         Stage stage = new Stage();
1042         stage.setScene(scene);
1043         stage.show();
1044 
1045         ParsedValue pv = CSSParser.getInstance().parseExpr("-fx-perf-rows","2");
1046         Object val = pv.convert(null);
1047         try {
1048             ((StyleableProperty)tilepane.prefRowsProperty()).applyStyle(null, val);
1049             assertEquals(2, tilepane.getPrefRows(), 0.00001);
1050         } catch (Exception e) {
1051             Assert.fail(e.toString());
1052         }
1053     }
1054 
1055 
1056     @Test public void testCSSsetPrefColumns_RT22929() {
1057         Scene scene = new Scene(tilepane);
1058         Stage stage = new Stage();
1059         stage.setScene(scene);
1060         stage.show();
1061 
1062         ParsedValue pv = CSSParser.getInstance().parseExpr("-fx-pref-columns","2");
1063         Object val = pv.convert(null);
1064         CssMetaData prop = ((StyleableProperty)tilepane.prefColumnsProperty()).getCssMetaData();
1065         try {
1066             ((StyleableProperty)tilepane.prefColumnsProperty()).applyStyle(null,val);
1067             assertEquals(2, tilepane.getPrefColumns(), 0.00001);
1068         } catch (Exception e) {
1069             Assert.fail(e.toString());
1070         }
1071     }
1072 }


  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.scene.layout;
  27 
  28 import javafx.css.ParsedValue;
  29 import javafx.css.CssMetaData;
  30 import javafx.css.CssParser;
  31 import javafx.css.StyleableProperty;
  32 import static org.junit.Assert.assertEquals;
  33 import static org.junit.Assert.assertNull;
  34 import javafx.geometry.Insets;
  35 import javafx.geometry.Orientation;
  36 import javafx.geometry.Pos;
  37 import javafx.scene.Node;
  38 import javafx.scene.Scene;
  39 import javafx.scene.shape.Rectangle;
  40 import javafx.stage.Stage;
  41 import org.junit.Assert;
  42 
  43 import org.junit.Before;
  44 import org.junit.Test;
  45 
  46 
  47 public class TilePaneTest {
  48 
  49     TilePane tilepane;
  50     TilePane htilepane;


1009             tilepane.getChildren().add(child);
1010         }
1011 
1012         tilepane.autosize();
1013         tilepane.layout();
1014 
1015         Node first = tilepane.getChildren().get(0);
1016 
1017         assertEquals(0, first.getLayoutX(), 1e-100);
1018         assertEquals(0, first.getLayoutY(), 1e-100);
1019         assertEquals(100, tilepane.getLayoutBounds().getWidth(), 1e-100);
1020         assertEquals(160, tilepane.getLayoutBounds().getHeight(), 1e-100);
1021     }
1022 
1023     @Test public void testCSSsetPrefTileWidthAndHeight_RT20388() {
1024         Scene scene = new Scene(tilepane);
1025         Stage stage = new Stage();
1026         stage.setScene(scene);
1027         stage.show();
1028 
1029         ParsedValue pv = new CssParser().parseExpr("-fx-perf-tile-width","67.0");
1030         Object val = pv.convert(null);
1031         try {
1032             ((StyleableProperty)tilepane.prefTileWidthProperty()).applyStyle(null, val);
1033             assertEquals(67.0, tilepane.getPrefTileWidth(), 0.00001);
1034         } catch (Exception e) {
1035             Assert.fail(e.toString());
1036         }
1037     }
1038 
1039     @Test public void testCSSsetPrefRow_RT20437() {
1040         Scene scene = new Scene(tilepane);
1041         Stage stage = new Stage();
1042         stage.setScene(scene);
1043         stage.show();
1044 
1045         ParsedValue pv = new CssParser().parseExpr("-fx-perf-rows","2");
1046         Object val = pv.convert(null);
1047         try {
1048             ((StyleableProperty)tilepane.prefRowsProperty()).applyStyle(null, val);
1049             assertEquals(2, tilepane.getPrefRows(), 0.00001);
1050         } catch (Exception e) {
1051             Assert.fail(e.toString());
1052         }
1053     }
1054 
1055 
1056     @Test public void testCSSsetPrefColumns_RT22929() {
1057         Scene scene = new Scene(tilepane);
1058         Stage stage = new Stage();
1059         stage.setScene(scene);
1060         stage.show();
1061 
1062         ParsedValue pv = new CssParser().parseExpr("-fx-pref-columns","2");
1063         Object val = pv.convert(null);
1064         CssMetaData prop = ((StyleableProperty)tilepane.prefColumnsProperty()).getCssMetaData();
1065         try {
1066             ((StyleableProperty)tilepane.prefColumnsProperty()).applyStyle(null,val);
1067             assertEquals(2, tilepane.getPrefColumns(), 0.00001);
1068         } catch (Exception e) {
1069             Assert.fail(e.toString());
1070         }
1071     }
1072 }