1 /*
   2  * Copyright (c) 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 package test.css.controls.api.styles;
  26 
  27 import javafx.css.CssMetaData;
  28 import java.util.Map;
  29 import java.util.Set;
  30 import javafx.scene.Node;
  31 import javafx.scene.control.*;
  32 import javafx.scene.layout.*;
  33 import javafx.scene.chart.*;
  34 import javafx.scene.shape.*;
  35 import javafx.scene.web.*;
  36 import javafx.scene.image.*;
  37 import javafx.scene.text.*;
  38 import javafx.scene.*;
  39 import org.junit.Assert;
  40 import org.junit.BeforeClass;
  41 import org.junit.Test;
  42 import org.jemmy.fx.Root;
  43 import org.jemmy.action.GetAction;
  44 import client.test.Keywords;
  45 import javafx.scene.control.skin.*;
  46 import javafx.scene.paint.Paint;
  47 import javafx.geometry.Insets;
  48 import com.sun.javafx.scene.layout.region.RepeatStruct;
  49 import com.sun.javafx.scene.layout.region.BorderImageSlices;
  50 
  51 
  52 /**
  53  * Generation test
  54  * @author sergey.lugovoy@oracle.com
  55  */
  56 public class StylesToggleButtonTest extends BaseStyleNodeTest {
  57 
  58     @Override
  59     Node getControl() {
  60         return new GetAction<Node>() {
  61             @Override
  62             public void run(Object... os) throws Exception {
  63                 ToggleButton control = new ToggleButton();
  64                 control.setSkin(new ToggleButtonSkin(control));
  65                 setResult(control);
  66             }
  67         }.dispatch(Root.ROOT.getEnvironment());
  68     }
  69 
  70     @Test
  71     public void testfxalignment () {
  72         Set<String> styleNames = getStyleNames();
  73         Assert.assertNotNull(styleNames);
  74         Assert.assertTrue(styleNames.contains("-fx-alignment"));
  75         Map<String, CssMetaData> styles = getStyles();
  76         CssMetaData data = styles.get("-fx-alignment");
  77         Assert.assertEquals(data.getInitialValue(getControl()), javafx.geometry.Pos.CENTER);
  78     }
  79 
  80     @Test
  81     public void testfxblendmode () {
  82         Set<String> styleNames = getStyleNames();
  83         Assert.assertNotNull(styleNames);
  84         Assert.assertTrue(styleNames.contains("-fx-blend-mode"));
  85         Map<String, CssMetaData> styles = getStyles();
  86         CssMetaData data = styles.get("-fx-blend-mode");
  87         Assert.assertEquals(data.getInitialValue(getControl()), null);
  88     }
  89 
  90     @Test
  91     public void testfxcontentdisplay () {
  92         Set<String> styleNames = getStyleNames();
  93         Assert.assertNotNull(styleNames);
  94         Assert.assertTrue(styleNames.contains("-fx-content-display"));
  95         Map<String, CssMetaData> styles = getStyles();
  96         CssMetaData data = styles.get("-fx-content-display");
  97         Assert.assertEquals(data.getInitialValue(getControl()), javafx.scene.control.ContentDisplay.LEFT);
  98     }
  99 
 100     @Test
 101     public void testfxcursor () {
 102         Set<String> styleNames = getStyleNames();
 103         Assert.assertNotNull(styleNames);
 104         Assert.assertTrue(styleNames.contains("-fx-cursor"));
 105         Map<String, CssMetaData> styles = getStyles();
 106         CssMetaData data = styles.get("-fx-cursor");
 107         Assert.assertEquals(data.getInitialValue(getControl()), null);
 108     }
 109 
 110     @Test
 111     public void testfxeffect () {
 112         Set<String> styleNames = getStyleNames();
 113         Assert.assertNotNull(styleNames);
 114         Assert.assertTrue(styleNames.contains("-fx-effect"));
 115         Map<String, CssMetaData> styles = getStyles();
 116         CssMetaData data = styles.get("-fx-effect");
 117         Assert.assertEquals(data.getInitialValue(getControl()), null);
 118     }
 119 
 120     @Test
 121     public void testfxellipsisstring () {
 122         Set<String> styleNames = getStyleNames();
 123         Assert.assertNotNull(styleNames);
 124         Assert.assertTrue(styleNames.contains("-fx-ellipsis-string"));
 125         Map<String, CssMetaData> styles = getStyles();
 126         CssMetaData data = styles.get("-fx-ellipsis-string");
 127         Assert.assertEquals(data.getInitialValue(getControl()), "...");
 128     }
 129 
 130     @Test
 131     public void testfxfont () {
 132         Set<String> styleNames = getStyleNames();
 133         Assert.assertNotNull(styleNames);
 134         Assert.assertTrue(styleNames.contains("-fx-font"));
 135         Map<String, CssMetaData> styles = getStyles();
 136         CssMetaData data = styles.get("-fx-font");
 137         Assert.assertEquals(data.getInitialValue(getControl()), javafx.scene.text.Font.getDefault());
 138     }
 139 
 140     @Test
 141     public void testfxgraphic () {
 142         Set<String> styleNames = getStyleNames();
 143         Assert.assertNotNull(styleNames);
 144         Assert.assertTrue(styleNames.contains("-fx-graphic"));
 145         Map<String, CssMetaData> styles = getStyles();
 146         CssMetaData data = styles.get("-fx-graphic");
 147         Assert.assertEquals(data.getInitialValue(getControl()), null);
 148     }
 149 
 150     @Test
 151     public void testfxgraphictextgap () {
 152         Set<String> styleNames = getStyleNames();
 153         Assert.assertNotNull(styleNames);
 154         Assert.assertTrue(styleNames.contains("-fx-graphic-text-gap"));
 155         Map<String, CssMetaData> styles = getStyles();
 156         CssMetaData data = styles.get("-fx-graphic-text-gap");
 157         Assert.assertEquals(data.getInitialValue(getControl()), 4.0);
 158     }
 159 
 160     @Test
 161     public void testfxlabelpadding () {
 162         Set<String> styleNames = getStyleNames();
 163         Assert.assertNotNull(styleNames);
 164         Assert.assertTrue(styleNames.contains("-fx-label-padding"));
 165         Map<String, CssMetaData> styles = getStyles();
 166         CssMetaData data = styles.get("-fx-label-padding");
 167         Assert.assertEquals(data.getInitialValue(getControl()), new javafx.geometry.Insets(0.0,0.0,0.0,0.0));
 168     }
 169 
 170     @Test
 171     public void testfxopacity () {
 172         Set<String> styleNames = getStyleNames();
 173         Assert.assertNotNull(styleNames);
 174         Assert.assertTrue(styleNames.contains("-fx-opacity"));
 175         Map<String, CssMetaData> styles = getStyles();
 176         CssMetaData data = styles.get("-fx-opacity");
 177         Assert.assertEquals(data.getInitialValue(getControl()), 1.0);
 178     }
 179 
 180     @Test
 181     public void testfxrotate () {
 182         Set<String> styleNames = getStyleNames();
 183         Assert.assertNotNull(styleNames);
 184         Assert.assertTrue(styleNames.contains("-fx-rotate"));
 185         Map<String, CssMetaData> styles = getStyles();
 186         CssMetaData data = styles.get("-fx-rotate");
 187         Assert.assertEquals(data.getInitialValue(getControl()), 0.0);
 188     }
 189 
 190     @Test
 191     public void testfxscalex () {
 192         Set<String> styleNames = getStyleNames();
 193         Assert.assertNotNull(styleNames);
 194         Assert.assertTrue(styleNames.contains("-fx-scale-x"));
 195         Map<String, CssMetaData> styles = getStyles();
 196         CssMetaData data = styles.get("-fx-scale-x");
 197         Assert.assertEquals(data.getInitialValue(getControl()), 1.0);
 198     }
 199 
 200     @Test
 201     public void testfxscaley () {
 202         Set<String> styleNames = getStyleNames();
 203         Assert.assertNotNull(styleNames);
 204         Assert.assertTrue(styleNames.contains("-fx-scale-y"));
 205         Map<String, CssMetaData> styles = getStyles();
 206         CssMetaData data = styles.get("-fx-scale-y");
 207         Assert.assertEquals(data.getInitialValue(getControl()), 1.0);
 208     }
 209 
 210     @Test
 211     public void testfxscalez () {
 212         Set<String> styleNames = getStyleNames();
 213         Assert.assertNotNull(styleNames);
 214         Assert.assertTrue(styleNames.contains("-fx-scale-z"));
 215         Map<String, CssMetaData> styles = getStyles();
 216         CssMetaData data = styles.get("-fx-scale-z");
 217         Assert.assertEquals(data.getInitialValue(getControl()), 1.0);
 218     }
 219 
 220     @Test
 221     public void testfxskin () {
 222         Set<String> styleNames = getStyleNames();
 223         Assert.assertNotNull(styleNames);
 224         Assert.assertTrue(styleNames.contains("-fx-skin"));
 225         Map<String, CssMetaData> styles = getStyles();
 226         CssMetaData data = styles.get("-fx-skin");
 227         Assert.assertEquals(data.getInitialValue(getControl()), null);
 228     }
 229 
 230     @Test
 231     public void testfxtextalignment () {
 232         Set<String> styleNames = getStyleNames();
 233         Assert.assertNotNull(styleNames);
 234         Assert.assertTrue(styleNames.contains("-fx-text-alignment"));
 235         Map<String, CssMetaData> styles = getStyles();
 236         CssMetaData data = styles.get("-fx-text-alignment");
 237         Assert.assertEquals(data.getInitialValue(getControl()), javafx.scene.text.TextAlignment.LEFT);
 238     }
 239 
 240     @Test
 241     public void testfxtextfill () {
 242         Set<String> styleNames = getStyleNames();
 243         Assert.assertNotNull(styleNames);
 244         Assert.assertTrue(styleNames.contains("-fx-text-fill"));
 245         Map<String, CssMetaData> styles = getStyles();
 246         CssMetaData data = styles.get("-fx-text-fill");
 247         Assert.assertEquals(data.getInitialValue(getControl()), javafx.scene.paint.Color.valueOf("0x000000ff"));
 248     }
 249 
 250     @Test
 251     public void testfxtextoverrun () {
 252         Set<String> styleNames = getStyleNames();
 253         Assert.assertNotNull(styleNames);
 254         Assert.assertTrue(styleNames.contains("-fx-text-overrun"));
 255         Map<String, CssMetaData> styles = getStyles();
 256         CssMetaData data = styles.get("-fx-text-overrun");
 257         Assert.assertEquals(data.getInitialValue(getControl()), javafx.scene.control.OverrunStyle.ELLIPSIS);
 258     }
 259 
 260     @Test
 261     public void testfxtranslatex () {
 262         Set<String> styleNames = getStyleNames();
 263         Assert.assertNotNull(styleNames);
 264         Assert.assertTrue(styleNames.contains("-fx-translate-x"));
 265         Map<String, CssMetaData> styles = getStyles();
 266         CssMetaData data = styles.get("-fx-translate-x");
 267         Assert.assertEquals(data.getInitialValue(getControl()), 0.0);
 268     }
 269 
 270     @Test
 271     public void testfxtranslatey () {
 272         Set<String> styleNames = getStyleNames();
 273         Assert.assertNotNull(styleNames);
 274         Assert.assertTrue(styleNames.contains("-fx-translate-y"));
 275         Map<String, CssMetaData> styles = getStyles();
 276         CssMetaData data = styles.get("-fx-translate-y");
 277         Assert.assertEquals(data.getInitialValue(getControl()), 0.0);
 278     }
 279 
 280     @Test
 281     public void testfxtranslatez () {
 282         Set<String> styleNames = getStyleNames();
 283         Assert.assertNotNull(styleNames);
 284         Assert.assertTrue(styleNames.contains("-fx-translate-z"));
 285         Map<String, CssMetaData> styles = getStyles();
 286         CssMetaData data = styles.get("-fx-translate-z");
 287         Assert.assertEquals(data.getInitialValue(getControl()), 0.0);
 288     }
 289 
 290     @Test
 291     public void testfxunderline () {
 292         Set<String> styleNames = getStyleNames();
 293         Assert.assertNotNull(styleNames);
 294         Assert.assertTrue(styleNames.contains("-fx-underline"));
 295         Map<String, CssMetaData> styles = getStyles();
 296         CssMetaData data = styles.get("-fx-underline");
 297         Assert.assertEquals(data.getInitialValue(getControl()), false);
 298     }
 299 
 300     @Test
 301     public void testfxwraptext () {
 302         Set<String> styleNames = getStyleNames();
 303         Assert.assertNotNull(styleNames);
 304         Assert.assertTrue(styleNames.contains("-fx-wrap-text"));
 305         Map<String, CssMetaData> styles = getStyles();
 306         CssMetaData data = styles.get("-fx-wrap-text");
 307         Assert.assertEquals(data.getInitialValue(getControl()), false);
 308     }
 309 
 310     @Test
 311     public void testvisibility () {
 312         Set<String> styleNames = getStyleNames();
 313         Assert.assertNotNull(styleNames);
 314         Assert.assertTrue(styleNames.contains("visibility"));
 315         Map<String, CssMetaData> styles = getStyles();
 316         CssMetaData data = styles.get("visibility");
 317         Assert.assertEquals(data.getInitialValue(getControl()), true);
 318     }
 319 
 320 
 321 }
--- EOF ---