1 /*
   2  * Copyright (c) 2011, 2017, 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 test.javafx.scene.control;
  27 
  28 import static org.junit.Assert.assertEquals;
  29 import static org.junit.Assert.assertTrue;
  30 
  31 
  32 import javafx.scene.control.ProgressIndicator;
  33 import javafx.scene.Scene;
  34 import javafx.stage.Stage;
  35 import javafx.scene.layout.HBox;
  36 import javafx.scene.layout.VBox;
  37 import javafx.geometry.Pos;
  38 import com.sun.javafx.tk.Toolkit;
  39 
  40 import org.junit.Before;
  41 import org.junit.Test;
  42 
  43 /**
  44  */
  45 public class ProgressIndicatorTest {
  46     Toolkit tk;
  47 
  48     @Before public void setup() {
  49         tk = Toolkit.getToolkit();
  50     }
  51 
  52     @Test public void progressIndicatorHeightTest() {
  53         ProgressIndicator pi = new ProgressIndicator(0.5);
  54         
  55         HBox hb = new HBox();
  56         hb.setAlignment(Pos.CENTER);
  57         hb.getChildren().addAll(pi);
  58 
  59         Scene scene = new Scene(hb, 400, 400);
  60         Stage stage = new Stage();
  61         stage.setScene(scene);
  62         stage.show();
  63         tk.firePulse();
  64         
  65         // Test the ProgressIndicator height is non zero and 
  66         // does not occupy entire height of the scene.
  67         int x = Double.compare(0.0, pi.getHeight());
  68         assertTrue(x != 0);
  69 
  70         x = Double.compare(400.0, pi.getHeight());
  71         assertTrue(x != 0);
  72     }
  73     
  74     @Test public void progressIndicatorWidthTest() {
  75         ProgressIndicator pi = new ProgressIndicator(0.5);
  76         
  77         VBox vb = new VBox();
  78         vb.setAlignment(Pos.CENTER);
  79         vb.getChildren().addAll(pi);
  80 
  81         Scene scene = new Scene(vb, 400, 400);
  82         Stage stage = new Stage();
  83         stage.setScene(scene);
  84         stage.show();
  85         
  86         tk.firePulse();
  87         
  88         // Test the ProgressIndicator width is non zero and 
  89         // does not occupy entire width of the scene.
  90         int x = Double.compare(0.0, pi.getWidth());
  91         assertTrue(x != 0);
  92 
  93         x = Double.compare(400.0, pi.getWidth());
  94         assertTrue(x != 0);         
  95     }
  96 }
  97