Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
9   97   4   2.25
0   32   0.44   4
4     1  
1    
7.1% of code in this file is excluded from these metrics.
 
  Containers       Line # 34 9 7.1% 4 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on Apr 28, 2009
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2009-2010 the original author or authors.
15    */
16    package org.fest.swing.fixture;
17   
18    import static org.fest.swing.edt.GuiActionRunner.execute;
19   
20    import java.awt.Container;
21   
22    import javax.swing.JFrame;
23   
24    import org.fest.swing.annotation.RunsInEDT;
25    import org.fest.swing.core.Robot;
26    import org.fest.swing.edt.GuiQuery;
27   
28    /**
29    * Understands utility methods related to <code>{@link Container}</code>s.
30    * @since 1.2
31    *
32    * @author Alex Ruiz
33    */
 
34    public final class Containers {
35   
36    /** Name of the <code>JFrame</code>s created by this class. */
37    public static final String CREATED_FRAME_NAME = "org.fest.swing.CreatedFrameForContainer";
38   
39    /**
40    * Creates a new <code>{@link JFrame}</code> and uses the given <code>{@link Container}</code> as its content pane.
41    * The created <code>JFrame</code> is wrapped and displayed by a <code>{@link FrameFixture}</code>.
42    * <p>
43    * <strong>Note:</strong>This method creates a new <code>{@link Robot}</code>. When using this method, please do not
44    * create any additional instances of <code>Robot</code>. Only one instance of <code>Robot</code> can exist per
45    * test class.
46    * </p>
47    * @param contentPane the <code>Container</code> to use as content pane for the <code>JFrame</code> to create.
48    * @return the created <code>FrameFixture</code>.
49    * @see #frameFor(Container)
50    */
 
51  1 toggle @RunsInEDT
52    public static FrameFixture showInFrame(Container contentPane) {
53  1 FrameFixture frameFixture = frameFixtureFor(contentPane);
54  1 frameFixture.show();
55  1 return frameFixture;
56    }
57   
58    /**
59    * Creates a new <code>{@link JFrame}</code> and uses the given <code>{@link Container}</code> as its content pane.
60    * The created <code>JFrame</code> is wrapped by a <code>{@link FrameFixture}</code>. Unlike
61    * <code>{@link #showInFrame(Container)}</code>, this method does <strong>not</strong> display the created
62    * <code>JFrame</code>.
63    * <p>
64    * <strong>Note:</strong>This method creates a new <code>{@link Robot}</code>. When using this method, please do not
65    * create any additional instances of <code>Robot</code>. Only one instance of <code>Robot</code> can exist per
66    * test class.
67    * </p>
68    * @param contentPane the <code>Container</code> to use as content pane for the <code>JFrame</code> to create.
69    * @return the created <code>FrameFixture</code>.
70    * @see #frameFor(Container)
71    */
 
72  2 toggle @RunsInEDT
73    public static FrameFixture frameFixtureFor(Container contentPane) {
74  2 return new FrameFixture(frameFor(contentPane));
75    }
76   
77    /**
78    * Creates a new <code>{@link JFrame}</code> and uses the given <code>{@link Container}</code> as its content pane.
79    * The created <code>JFrame</code> has the name specified by <code>{@link #CREATED_FRAME_NAME}</code>. This method
80    * is executed in the Event Dispatch Thread (EDT.)
81    * @param contentPane the <code>Container</code> to use as content pane for the <code>JFrame</code> to create.
82    * @return the created <code>JFrame</code>.
83    */
 
84  2 toggle @RunsInEDT
85    public static JFrame frameFor(final Container contentPane) {
86  2 return execute(new GuiQuery<JFrame>() {
 
87  2 toggle protected JFrame executeInEDT() throws Throwable {
88  2 JFrame frame = new JFrame("Created by FEST");
89  2 frame.setName(CREATED_FRAME_NAME);
90  2 frame.setContentPane(contentPane);
91  2 return frame;
92    }
93    });
94    }
95   
 
96    toggle private Containers() {}
97    }