modules/graphics/src/test/java/javafx/scene/FocusTest.java

Print this page
rev 6167 : RT-35330 [Monocle] Remove StubToolkit and replace it with headless glass implementation


   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.scene;
  27 
  28 

  29 import com.sun.javafx.pgstub.StubScene;
  30 import com.sun.javafx.pgstub.StubToolkit;
  31 import com.sun.javafx.tk.Toolkit;
  32 import static org.junit.Assert.assertEquals;
  33 import static org.junit.Assert.assertFalse;
  34 import static org.junit.Assert.assertNull;
  35 import static org.junit.Assert.assertSame;
  36 import static org.junit.Assert.assertTrue;
  37 import static org.junit.Assert.fail;
  38 
  39 import java.util.ArrayList;
  40 import java.util.List;
  41 import javafx.beans.InvalidationListener;
  42 import javafx.beans.Observable;
  43 import javafx.beans.value.ChangeListener;
  44 import javafx.beans.value.ObservableValue;
  45 
  46 import javafx.scene.shape.Rectangle;
  47 import javafx.stage.Stage;
  48 
  49 import org.junit.After;
  50 import org.junit.Before;

  51 import org.junit.Test;
  52 
  53 public class FocusTest {
  54 



  55     private Stage stage;
  56     private Scene scene;
  57     private List<Node> nodes;
  58     private int nodeIndex;
  59     private StubToolkit toolkit;
  60     private boolean actionTaken;
  61 
  62     @Before
  63     public void setUp() {
  64         stage = new Stage();
  65         scene = new Scene(new Group(), 500, 500);
  66         stage.setScene(scene);
  67         stage.show();
  68         stage.requestFocus();
  69         nodes = new ArrayList();
  70         nodeIndex = 0;
  71 
  72         toolkit = (StubToolkit) Toolkit.getToolkit();
  73     }
  74 




   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.scene;
  27 
  28 
  29 import com.sun.javafx.FXUnit;
  30 import com.sun.javafx.pgstub.StubScene;
  31 import com.sun.javafx.pgstub.StubToolkit;
  32 import com.sun.javafx.tk.Toolkit;
  33 import static org.junit.Assert.assertEquals;
  34 import static org.junit.Assert.assertFalse;
  35 import static org.junit.Assert.assertNull;
  36 import static org.junit.Assert.assertSame;
  37 import static org.junit.Assert.assertTrue;
  38 import static org.junit.Assert.fail;
  39 
  40 import java.util.ArrayList;
  41 import java.util.List;
  42 import javafx.beans.InvalidationListener;
  43 import javafx.beans.Observable;
  44 import javafx.beans.value.ChangeListener;
  45 import javafx.beans.value.ObservableValue;
  46 
  47 import javafx.scene.shape.Rectangle;
  48 import javafx.stage.Stage;
  49 
  50 import org.junit.After;
  51 import org.junit.Before;
  52 import org.junit.Rule;
  53 import org.junit.Test;
  54 
  55 public class FocusTest {
  56 
  57     @Rule
  58     public FXUnit fx = new FXUnit();
  59 
  60     private Stage stage;
  61     private Scene scene;
  62     private List<Node> nodes;
  63     private int nodeIndex;
  64     private StubToolkit toolkit;
  65     private boolean actionTaken;
  66 
  67     @Before
  68     public void setUp() {
  69         stage = new Stage();
  70         scene = new Scene(new Group(), 500, 500);
  71         stage.setScene(scene);
  72         stage.show();
  73         stage.requestFocus();
  74         nodes = new ArrayList();
  75         nodeIndex = 0;
  76 
  77         toolkit = (StubToolkit) Toolkit.getToolkit();
  78     }
  79