View Javadoc
1   /*
2    * #%L
3    * IsisFish
4    * 
5    * $Id: InputIT.java 4284 2015-06-23 14:46:29Z echatellier $
6    * $HeadURL: https://svn.codelutin.com/isis-fish/tags/isis-fish-4.4.0.2/src/test/java/fr/ifremer/isisfish/ui/input/InputIT.java $
7    * %%
8    * Copyright (C) 2015 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.input;
26  
27  import java.io.File;
28  import java.io.IOException;
29  
30  import org.assertj.swing.core.matcher.JButtonMatcher;
31  import org.junit.Assert;
32  import org.junit.Before;
33  import org.junit.Test;
34  
35  import fr.ifremer.isisfish.ui.AbstractAssertjIT;
36  
37  /**
38   * Swing tests.
39   * 
40   * @author Eric Chatellier
41   */
42  public class InputIT extends AbstractAssertjIT {
43  
44      @Before
45      @Override
46      public void setUp() {
47          super.setUp();
48          mainWindow.tabbedPane("simulTabs").selectTab(0);
49      }
50  
51      protected void openDemoRegion() {
52          mainWindow.comboBox("fieldCurrentRegion").selectItem("DemoRegion");
53      }
54  
55      /**
56       * Just open test.
57       */
58      @Test
59      public void testOpenDemoRegion() {
60          openDemoRegion();
61          mainWindow.comboBox("fieldCurrentRegion").requireSelection(1);
62      }
63  
64      /**
65       * Edit and save region test.
66       */
67      @Test
68      public void testEditRegionName() {
69          openDemoRegion();
70          mainWindow.tree("fisheryRegionTree").selectRow(0);
71          mainWindow.textBox("fieldRegion").selectAll().enterText("New region name");
72          mainWindow.button("save").click();
73          Assert.assertEquals(mainWindow.tree("fisheryRegionTree").valueAt(0), "New region name");
74      }
75  
76      /**
77       * Open, export, import and rename region test.
78       * 
79       * @throws IOException
80       */
81      @Test
82      public void testImportRegion() throws IOException {
83          openDemoRegion();
84          mainWindow.menuItem("menuRegionExport").click();
85          File f = File.createTempFile("isis-export", ".zip"); // bug file exists
86          f.deleteOnExit();
87          mainWindow.fileChooser().selectFile(f).approve();
88          mainWindow.optionPane().yesButton().click(); // bug file exists
89          mainWindow.menuItem("menuRegionImportRename").click();
90          mainWindow.fileChooser().selectFile(f).approve();
91  
92          mainWindow.dialog().textBox().enterText("Testimport");
93          mainWindow.dialog().button(JButtonMatcher.withText("OK")).click();
94          mainWindow.comboBox("fieldCurrentRegion").selectItem("Testimport");
95          Assert.assertEquals(mainWindow.tree("fisheryRegionTree").valueAt(0), "Testimport");
96      }
97  }