source: josm/trunk/test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java@ 12632

Last change on this file since 12632 was 12632, checked in by Don-vip, 7 years ago

see #15182 - fix unit tests

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs;
3
4import static org.junit.Assert.assertFalse;
5import static org.junit.Assert.assertTrue;
6
7import org.junit.Rule;
8import org.junit.Test;
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.TestUtils;
11import org.openstreetmap.josm.command.Command;
12import org.openstreetmap.josm.data.osm.DataSet;
13import org.openstreetmap.josm.gui.MainApplication;
14import org.openstreetmap.josm.gui.MapFrame;
15import org.openstreetmap.josm.gui.layer.OsmDataLayer;
16import org.openstreetmap.josm.testutils.JOSMTestRules;
17
18import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19
20/**
21 * Unit tests of {@link CommandStackDialog} class.
22 */
23public class CommandStackDialogTest {
24
25 /**
26 * Setup tests
27 */
28 @Rule
29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
30 public JOSMTestRules test = new JOSMTestRules().main().platform().projection();
31
32 /**
33 * Unit test of {@link CommandStackDialog} class - empty case.
34 */
35 @Test
36 public void testCommandStackDialogEmpty() {
37 CommandStackDialog dlg = new CommandStackDialog();
38 dlg.showDialog();
39 assertTrue(dlg.isVisible());
40 dlg.hideDialog();
41 assertFalse(dlg.isVisible());
42 }
43
44 /**
45 * Unit test of {@link CommandStackDialog} class - not empty case.
46 */
47 @Test
48 public void testCommandStackDialogNotEmpty() {
49 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
50 Main.getLayerManager().addLayer(layer);
51 try {
52 Command cmd1 = TestUtils.newCommand();
53 Command cmd2 = TestUtils.newCommand();
54 Main.main.undoRedo.add(cmd1);
55 Main.main.undoRedo.add(cmd2);
56 Main.main.undoRedo.undo(1);
57
58 assertFalse(Main.main.undoRedo.commands.isEmpty());
59 assertFalse(Main.main.undoRedo.redoCommands.isEmpty());
60
61 MapFrame map = MainApplication.getMap();
62 CommandStackDialog dlg = new CommandStackDialog();
63 map.addToggleDialog(dlg);
64 dlg.unfurlDialog();
65 assertTrue(dlg.isVisible());
66 map.removeToggleDialog(dlg);
67 dlg.hideDialog();
68 assertFalse(dlg.isVisible());
69 } finally {
70 Main.main.undoRedo.clean();
71 Main.getLayerManager().removeLayer(layer);
72 }
73 }
74}
Note: See TracBrowser for help on using the repository browser.