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 test.javafx.scene.layout;
27
28 import test.javafx.scene.layout.MockBiased;
29 import javafx.css.ParsedValue;
30 import javafx.css.CssMetaData;
31 import javafx.css.CssParser;
32 import javafx.css.StyleableProperty;
33 import static org.junit.Assert.assertEquals;
34 import static org.junit.Assert.assertNull;
35 import javafx.geometry.Insets;
36 import javafx.geometry.Orientation;
37 import javafx.geometry.Pos;
38 import javafx.scene.Node;
39 import javafx.scene.ParentShim;
40 import javafx.scene.Scene;
41 import javafx.scene.layout.Region;
42 import javafx.scene.layout.TilePane;
43 import javafx.scene.shape.Rectangle;
44 import javafx.stage.Stage;
45 import org.junit.Assert;
46
47 import org.junit.Before;
48 import org.junit.Test;
49
50
51 public class TilePaneTest {
1013 ParentShim.getChildren(tilepane).add(child);
1014 }
1015
1016 tilepane.autosize();
1017 tilepane.layout();
1018
1019 Node first = ParentShim.getChildren(tilepane).get(0);
1020
1021 assertEquals(0, first.getLayoutX(), 1e-100);
1022 assertEquals(0, first.getLayoutY(), 1e-100);
1023 assertEquals(100, tilepane.getLayoutBounds().getWidth(), 1e-100);
1024 assertEquals(160, tilepane.getLayoutBounds().getHeight(), 1e-100);
1025 }
1026
1027 @Test public void testCSSsetPrefTileWidthAndHeight_RT20388() {
1028 Scene scene = new Scene(tilepane);
1029 Stage stage = new Stage();
1030 stage.setScene(scene);
1031 stage.show();
1032
1033 ParsedValue pv = new CssParser().parseExpr("-fx-perf-tile-width","67.0");
1034 Object val = pv.convert(null);
1035 try {
1036 ((StyleableProperty)tilepane.prefTileWidthProperty()).applyStyle(null, val);
1037 assertEquals(67.0, tilepane.getPrefTileWidth(), 0.00001);
1038 } catch (Exception e) {
1039 Assert.fail(e.toString());
1040 }
1041 }
1042
1043 @Test public void testCSSsetPrefRow_RT20437() {
1044 Scene scene = new Scene(tilepane);
1045 Stage stage = new Stage();
1046 stage.setScene(scene);
1047 stage.show();
1048
1049 ParsedValue pv = new CssParser().parseExpr("-fx-perf-rows","2");
1050 Object val = pv.convert(null);
1051 try {
1052 ((StyleableProperty)tilepane.prefRowsProperty()).applyStyle(null, val);
1053 assertEquals(2, tilepane.getPrefRows(), 0.00001);
1054 } catch (Exception e) {
1055 Assert.fail(e.toString());
1056 }
1057 }
1058
1059
1060 @Test public void testCSSsetPrefColumns_RT22929() {
1061 Scene scene = new Scene(tilepane);
1062 Stage stage = new Stage();
1063 stage.setScene(scene);
1064 stage.show();
1065
1066 ParsedValue pv = new CssParser().parseExpr("-fx-pref-columns","2");
1067 Object val = pv.convert(null);
1068 CssMetaData prop = ((StyleableProperty)tilepane.prefColumnsProperty()).getCssMetaData();
1069 try {
1070 ((StyleableProperty)tilepane.prefColumnsProperty()).applyStyle(null,val);
1071 assertEquals(2, tilepane.getPrefColumns(), 0.00001);
1072 } catch (Exception e) {
1073 Assert.fail(e.toString());
1074 }
1075 }
1076 }
|
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 test.javafx.scene.layout;
27
28 import test.javafx.scene.layout.MockBiased;
29 import javafx.css.ParsedValue;
30 import javafx.css.CssMetaData;
31 import javafx.css.CssParserShim;
32 import javafx.css.StyleableProperty;
33 import static org.junit.Assert.assertEquals;
34 import static org.junit.Assert.assertNull;
35 import javafx.geometry.Insets;
36 import javafx.geometry.Orientation;
37 import javafx.geometry.Pos;
38 import javafx.scene.Node;
39 import javafx.scene.ParentShim;
40 import javafx.scene.Scene;
41 import javafx.scene.layout.Region;
42 import javafx.scene.layout.TilePane;
43 import javafx.scene.shape.Rectangle;
44 import javafx.stage.Stage;
45 import org.junit.Assert;
46
47 import org.junit.Before;
48 import org.junit.Test;
49
50
51 public class TilePaneTest {
1013 ParentShim.getChildren(tilepane).add(child);
1014 }
1015
1016 tilepane.autosize();
1017 tilepane.layout();
1018
1019 Node first = ParentShim.getChildren(tilepane).get(0);
1020
1021 assertEquals(0, first.getLayoutX(), 1e-100);
1022 assertEquals(0, first.getLayoutY(), 1e-100);
1023 assertEquals(100, tilepane.getLayoutBounds().getWidth(), 1e-100);
1024 assertEquals(160, tilepane.getLayoutBounds().getHeight(), 1e-100);
1025 }
1026
1027 @Test public void testCSSsetPrefTileWidthAndHeight_RT20388() {
1028 Scene scene = new Scene(tilepane);
1029 Stage stage = new Stage();
1030 stage.setScene(scene);
1031 stage.show();
1032
1033 ParsedValue pv = new CssParserShim().parseExpr("-fx-perf-tile-width","67.0");
1034 Object val = pv.convert(null);
1035 try {
1036 ((StyleableProperty)tilepane.prefTileWidthProperty()).applyStyle(null, val);
1037 assertEquals(67.0, tilepane.getPrefTileWidth(), 0.00001);
1038 } catch (Exception e) {
1039 Assert.fail(e.toString());
1040 }
1041 }
1042
1043 @Test public void testCSSsetPrefRow_RT20437() {
1044 Scene scene = new Scene(tilepane);
1045 Stage stage = new Stage();
1046 stage.setScene(scene);
1047 stage.show();
1048
1049 ParsedValue pv = new CssParserShim().parseExpr("-fx-perf-rows","2");
1050 Object val = pv.convert(null);
1051 try {
1052 ((StyleableProperty)tilepane.prefRowsProperty()).applyStyle(null, val);
1053 assertEquals(2, tilepane.getPrefRows(), 0.00001);
1054 } catch (Exception e) {
1055 Assert.fail(e.toString());
1056 }
1057 }
1058
1059
1060 @Test public void testCSSsetPrefColumns_RT22929() {
1061 Scene scene = new Scene(tilepane);
1062 Stage stage = new Stage();
1063 stage.setScene(scene);
1064 stage.show();
1065
1066 ParsedValue pv = new CssParserShim().parseExpr("-fx-pref-columns","2");
1067 Object val = pv.convert(null);
1068 CssMetaData prop = ((StyleableProperty)tilepane.prefColumnsProperty()).getCssMetaData();
1069 try {
1070 ((StyleableProperty)tilepane.prefColumnsProperty()).applyStyle(null,val);
1071 assertEquals(2, tilepane.getPrefColumns(), 0.00001);
1072 } catch (Exception e) {
1073 Assert.fail(e.toString());
1074 }
1075 }
1076 }
|