View Javadoc
1   /*
2    * #%L
3    * IsisFish
4    * 
5    * $Id: IntervalPanelTest.java 4156 2014-12-09 11:27:18Z echatellier $
6    * $HeadURL: https://svn.codelutin.com/isis-fish/tags/isis-fish-4.4.0.2/src/test/java/fr/ifremer/isisfish/ui/widget/IntervalPanelTest.java $
7    * %%
8    * Copyright (C) 2002 - 2012 Ifremer, CodeLutin, Chatellier Eric
9    * %%
10   * This program is free software: you can redistribute it and/or modify
11   * it under the terms of the GNU General Public License as
12   * published by the Free Software Foundation, either version 3 of the 
13   * License, or (at your option) any later version.
14   * 
15   * This program is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18   * GNU General Public License for more details.
19   * 
20   * You should have received a copy of the GNU General Public 
21   * License along with this program.  If not, see
22   * <http://www.gnu.org/licenses/gpl-3.0.html>.
23   * #L%
24   */
25  
26  package fr.ifremer.isisfish.ui.widget;
27  
28  import javax.swing.SwingUtilities;
29  
30  import org.junit.Assume;
31  import org.junit.BeforeClass;
32  import org.junit.Test;
33  
34  /**
35   * Test class for {@link IntervalPanel}.
36   * 
37   * @author chatellier
38   * @version $Revision: 4156 $
39   * 
40   * Last update : $Date: 2014-12-09 12:27:18 +0100 (Tue, 09 Dec 2014) $
41   * By : $Author: echatellier $
42   */
43  public class IntervalPanelTest {
44  
45      @BeforeClass
46      public static void disableTests() {
47          Assume.assumeTrue(!java.awt.GraphicsEnvironment.isHeadless());
48      }
49  
50      /**
51       * Test to display a frame with interval panel.
52       * 
53       * @throws InterruptedException 
54       */
55      @Test
56      public void testIntervalPanelDisplay() throws InterruptedException {
57          Interval i = new Interval(0, 11);
58          final FormInterval f = new FormInterval(i);
59          SwingUtilities.invokeLater(new Runnable() {
60              @Override
61              public void run() {
62                  f.setVisible(true);
63              }
64          });
65  
66          Thread t = new Thread(new Runnable() {
67              public void run() {
68                  try {
69                      Thread.sleep(1000);
70                  } catch (InterruptedException e) {
71                      // do nothing
72                  }
73                  f.dispose();
74              }
75          });
76          t.start();
77  
78          // it would really be nice to wait the thread, otherwise the test
79          // means nothing!!!
80          t.join();
81      }
82  }