source: josm/trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java @ 12564

Last change on this file since 12564 was 12564, checked in by Don-vip, 3 months ago

fix unit tests

  • Property svn:eol-style set to native
File size: 4.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.dialogs.relation.actions;
3
4import org.junit.Rule;
5import org.junit.Test;
6import org.openstreetmap.josm.data.osm.DataSet;
7import org.openstreetmap.josm.data.osm.Relation;
8import org.openstreetmap.josm.gui.dialogs.relation.GenericRelationEditorTest;
9import org.openstreetmap.josm.gui.dialogs.relation.IRelationEditor;
10import org.openstreetmap.josm.gui.dialogs.relation.MemberTable;
11import org.openstreetmap.josm.gui.dialogs.relation.MemberTableModel;
12import org.openstreetmap.josm.gui.dialogs.relation.SelectionTableModel;
13import org.openstreetmap.josm.gui.layer.OsmDataLayer;
14import org.openstreetmap.josm.gui.tagging.TagEditorModel;
15import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
16import org.openstreetmap.josm.testutils.JOSMTestRules;
17
18import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19
20/**
21 * Unit tests for relation editor actions.
22 */
23public class RelationEditorActionsTest {
24    /**
25     * Plattform for tooltips.
26     */
27    @Rule
28    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
29    public JOSMTestRules test = new JOSMTestRules().preferences().platform().main();
30
31    /**
32     * Check that all actions do not crash.
33     */
34    @Test
35    public void testAllActions() {
36        final DataSet ds = new DataSet();
37        final Relation orig = new Relation(1);
38        ds.addPrimitive(orig);
39        final OsmDataLayer layer = new OsmDataLayer(ds, "test", null);
40        MemberTableModel memberTableModel = new MemberTableModel(orig, layer, null);
41        SelectionTableModel selectionTableModel = new SelectionTableModel(layer);
42
43        IRelationEditor editor = GenericRelationEditorTest.newRelationEditor(orig, layer);
44
45        MemberTable memberTable = new MemberTable(layer, editor.getRelation(), memberTableModel);
46        TagEditorModel tagModel = new TagEditorModel();
47        AutoCompletingTextField tfRole = new AutoCompletingTextField();
48
49        new AddSelectedAfterSelection(memberTableModel, selectionTableModel, editor).actionPerformed(null);
50        new AddSelectedBeforeSelection(memberTableModel, selectionTableModel, editor).actionPerformed(null);
51        new AddSelectedAtStartAction(memberTableModel, selectionTableModel, editor).actionPerformed(null);
52        new AddSelectedAtEndAction(memberTableModel, selectionTableModel, editor).actionPerformed(null);
53
54        new ApplyAction(memberTable, memberTableModel, tagModel, layer, editor).actionPerformed(null);
55        new RefreshAction(memberTable, memberTableModel, tagModel, layer, editor).actionPerformed(null);
56        new OKAction(memberTable, memberTableModel, tagModel, layer, editor, tfRole).actionPerformed(null);
57        new CancelAction(memberTable, memberTableModel, tagModel, layer, editor, tfRole).actionPerformed(null);
58
59        new CopyMembersAction(memberTableModel, layer, editor).actionPerformed(null);
60        new PasteMembersAction(memberTable, layer, editor).actionPerformed(null);
61
62        new DeleteCurrentRelationAction(layer, editor).actionPerformed(null);
63
64        new DownloadIncompleteMembersAction(memberTable, memberTableModel, "downloadincomplete", layer, editor).actionPerformed(null);
65        new DownloadSelectedIncompleteMembersAction(memberTable, memberTableModel, null, layer, editor).actionPerformed(null);
66
67        new DuplicateRelationAction(memberTableModel, tagModel, layer).actionPerformed(null);
68        new EditAction(memberTable, memberTableModel, layer).actionPerformed(null);
69
70        new MoveDownAction(memberTable, memberTableModel, "movedown").actionPerformed(null);
71        new MoveUpAction(memberTable, memberTableModel, "moveup").actionPerformed(null);
72        new RemoveAction(memberTable, memberTableModel, "remove").actionPerformed(null);
73
74        new RemoveSelectedAction(memberTableModel, selectionTableModel, layer).actionPerformed(null);
75        new SelectedMembersForSelectionAction(memberTableModel, selectionTableModel, layer).actionPerformed(null);
76
77        new SelectPrimitivesForSelectedMembersAction(memberTable, memberTableModel, layer).actionPerformed(null);
78
79        new SortAction(memberTable, memberTableModel).actionPerformed(null);
80        new SortBelowAction(memberTable, memberTableModel).actionPerformed(null);
81        new ReverseAction(memberTable, memberTableModel).actionPerformed(null);
82
83        new SetRoleAction(memberTable, memberTableModel, tfRole).actionPerformed(null);
84    }
85}
Note: See TracBrowser for help on using the repository browser.