1 /*
2 * #%L
3 * IsisFish
4 *
5 * $Id: AbstractAssertjIT.java 4286 2015-06-23 15:06:36Z echatellier $
6 * $HeadURL: https://svn.codelutin.com/isis-fish/tags/isis-fish-4.4.0.2/src/test/java/fr/ifremer/isisfish/ui/AbstractAssertjIT.java $
7 * %%
8 * Copyright (C) 2009 - 2012 Ifremer, Code Lutin, 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 package fr.ifremer.isisfish.ui;
26
27 import org.assertj.swing.edt.FailOnThreadViolationRepaintManager;
28 import org.assertj.swing.edt.GuiActionRunner;
29 import org.assertj.swing.edt.GuiQuery;
30 import org.assertj.swing.exception.WaitTimedOutError;
31 import org.assertj.swing.fixture.FrameFixture;
32 import org.junit.After;
33 import org.junit.Assume;
34 import org.junit.Before;
35 import org.junit.BeforeClass;
36
37 import fr.ifremer.isisfish.AbstractIsisFishTest;
38
39 /**
40 * Test commun qui permet d'instancier une fenetre Isis à partir de laquelle dépendent
41 * tous les tests.
42 *
43 * @author Eric Chatellier
44 */
45 public abstract class AbstractAssertjIT extends AbstractIsisFishTest {
46
47 protected FrameFixture mainWindow;
48
49 @BeforeClass
50 public static void setUpOnce() throws Exception {
51 Assume.assumeTrue(!java.awt.GraphicsEnvironment.isHeadless());
52 FailOnThreadViolationRepaintManager.install();
53 }
54
55 @Before
56 public void setUp() {
57 WelcomeUI frame = GuiActionRunner.execute(new GuiQuery<WelcomeUI>() {
58 protected WelcomeUI executeInEDT() {
59 return new WelcomeUI(new WelcomeContext());
60 }
61 });
62 mainWindow = new FrameFixture(frame);
63 try {
64 mainWindow.show(); // shows the frame to test
65 } catch (WaitTimedOutError e) {
66 // ok, but not a problem, isis is so slow...
67 }
68 mainWindow.maximize();
69 }
70
71 @After
72 public void tearDown() {
73 mainWindow.cleanUp();
74 }
75 }