1 /*
   2  * Copyright (c) 2018, 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.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package org.netbeans.jemmy.operators;
  25 
  26 import java.awt.Dimension;
  27 import java.awt.Point;
  28 
  29 import javax.swing.JDesktopPane;
  30 import javax.swing.JFrame;
  31 import javax.swing.JInternalFrame;
  32 
  33 import org.testng.annotations.AfterClass;
  34 import org.testng.annotations.BeforeClass;
  35 import org.testng.annotations.Test;
  36 
  37 public class JInternalFrameOperatorTest {
  38 
  39     private JFrameOperator frameOper;
  40 
  41     private JInternalFrameOperator internalFrameOper;
  42 
  43     @BeforeClass
  44     protected void setUp() throws Exception {
  45         JFrame frame = new JFrame();
  46         JDesktopPane desktop = new JDesktopPane();
  47         frame.setContentPane(desktop);
  48         JInternalFrame internalFrame = new JInternalFrame(
  49                 "JInternalFrameOperatorTest", true, true, true, true);
  50         internalFrame.setName("JInternalFrameOperatorTest");
  51         internalFrame.setSize(200, 200);
  52         internalFrame.setVisible(true);
  53         desktop.add(internalFrame);
  54         frame.setSize(400,400);
  55         frame.setLocationRelativeTo(null);
  56         frame.setVisible(true);
  57         frameOper = new JFrameOperator();
  58         internalFrameOper = new JInternalFrameOperator(frameOper);
  59         internalFrameOper.setVerification(true);
  60     }
  61 
  62     @AfterClass
  63     protected void tearDown() throws Exception {
  64         frameOper.setVisible(false);
  65         frameOper.dispose();
  66     }
  67 
  68     @Test
  69     public void testIconify() {
  70         internalFrameOper.iconify();
  71         internalFrameOper.deiconify();
  72     }
  73 
  74     @Test
  75     public void testMaximize() {
  76         internalFrameOper.maximize();
  77         internalFrameOper.demaximize();
  78     }
  79 
  80     @Test
  81     public void testMove() {
  82         Point originalLocation = internalFrameOper.getLocation();
  83         internalFrameOper.move(150, 150);
  84         internalFrameOper.move(originalLocation.x, originalLocation.y);
  85     }
  86 
  87     @Test
  88     public void testResize() {
  89         Dimension originaSize = internalFrameOper.getSize();
  90         internalFrameOper.resize(250, 250);
  91         internalFrameOper.resize(originaSize.width, originaSize.height);
  92     }
  93 
  94     @Test
  95     public void testActivate() {
  96         internalFrameOper.activate();
  97     }
  98 
  99 }