View Javadoc

1   /**
2    * Copyright 2008 WebPhotos
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.webphotos.gui.component;
17  
18  import org.junit.AfterClass;
19  import static org.junit.Assert.assertTrue;
20  import org.junit.Before;
21  import org.junit.BeforeClass;
22  import org.junit.Test;
23  import org.uispec4j.Trigger;
24  import org.uispec4j.UISpec4J;
25  import org.uispec4j.Window;
26  import org.uispec4j.interception.WindowHandler;
27  import org.uispec4j.interception.WindowInterceptor;
28  
29  /**
30   *
31   * @author Guilherme
32   */
33  public class PainelPesquisaFrameTest extends javax.swing.JFrame {
34      /**
35       *
36       */
37      public static PainelPesquisaFrameTest PAINEL_PESQUISA_FRAME_TEST;
38  
39      static {
40          UISpec4J.init();
41          UISpec4J.setWindowInterceptionTimeLimit(30000);
42      }
43  
44      /**
45       *
46       * @throws Exception
47       */
48      @BeforeClass
49      public static void setUpClass() throws Exception {
50      }
51  
52      /**
53       *
54       * @throws Exception
55       */
56      @AfterClass
57      public static void tearDownClass() throws Exception {
58          PAINEL_PESQUISA_FRAME_TEST.dispose();
59      }
60  
61      /**
62       *
63       */
64      @Before
65      public void setUp() {
66      }
67  
68      /**
69       * Creates new form PainelPesquisaFrameTest
70       */
71      public PainelPesquisaFrameTest() {
72          super("PainelPesquisaFrameTest");
73          initComponents();
74      }
75  
76      /**
77       * This method is called from within the constructor to initialize the form.
78       * WARNING: Do NOT modify this code. The content of this method is always
79       * regenerated by the Form Editor.
80       */
81      @SuppressWarnings("unchecked")
82      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
83      private void initComponents() {
84  
85          painelPesquisaTest = new net.sf.webphotos.gui.component.PainelPesquisa();
86  
87          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
88  
89          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
90          getContentPane().setLayout(layout);
91          layout.setHorizontalGroup(
92              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
93              .addGroup(layout.createSequentialGroup()
94                  .addContainerGap()
95                  .addComponent(painelPesquisaTest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
96                  .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
97          );
98          layout.setVerticalGroup(
99              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
100             .addGroup(layout.createSequentialGroup()
101                 .addContainerGap()
102                 .addComponent(painelPesquisaTest, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
103                 .addContainerGap(229, Short.MAX_VALUE))
104         );
105 
106         pack();
107     }// </editor-fold>//GEN-END:initComponents
108 
109     /**
110      * @param args the command line arguments
111      */
112     @Test
113     public void testMain() {
114         /*
115          * Set the Nimbus look and feel
116          */
117         //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
118         /*
119          * If Nimbus (introduced in Java SE 6) is not available, stay with the
120          * default look and feel. For details see
121          * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
122          */
123         try {
124             for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
125                 if ("Nimbus".equals(info.getName())) {
126                     javax.swing.UIManager.setLookAndFeel(info.getClassName());
127                     break;
128                 }
129             }
130         } catch (ClassNotFoundException ex) {
131             java.util.logging.Logger.getLogger(PainelPesquisaFrameTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
132         } catch (InstantiationException ex) {
133             java.util.logging.Logger.getLogger(PainelPesquisaFrameTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
134         } catch (IllegalAccessException ex) {
135             java.util.logging.Logger.getLogger(PainelPesquisaFrameTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
136         } catch (javax.swing.UnsupportedLookAndFeelException ex) {
137             java.util.logging.Logger.getLogger(PainelPesquisaFrameTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
138         }
139         //</editor-fold>
140 
141         WindowInterceptor.init(new Trigger() {
142             @Override
143             public void run() {
144                 PAINEL_PESQUISA_FRAME_TEST = new PainelPesquisaFrameTest();
145                 PAINEL_PESQUISA_FRAME_TEST.setVisible(true);
146             }
147         }).process(new WindowHandler("PainelPesquisaFrameTest") {
148             @Override
149             public Trigger process(Window window) throws Exception {
150                 assertTrue(window.titleContains("PainelPesquisaFrameTest").isTrue());
151                 System.out.println("Tittle: " + window.getTitle());
152                 return Trigger.DO_NOTHING;
153             }
154         }).run();
155     }
156     // Variables declaration - do not modify//GEN-BEGIN:variables
157     private net.sf.webphotos.gui.component.PainelPesquisa painelPesquisaTest;
158     // End of variables declaration//GEN-END:variables
159 }