1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertFalse;
|
---|
5 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
---|
6 |
|
---|
7 | import java.util.concurrent.atomic.AtomicBoolean;
|
---|
8 |
|
---|
9 | import org.junit.jupiter.api.BeforeEach;
|
---|
10 | import org.junit.jupiter.api.Test;
|
---|
11 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
12 | import org.openstreetmap.josm.gui.layer.MapViewPaintable.PaintableInvalidationListener;
|
---|
13 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
14 |
|
---|
15 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Test of the base {@link AbstractMapViewPaintable} class
|
---|
19 | * @author Michael Zangl
|
---|
20 | */
|
---|
21 | class AbstractMapViewPaintableTest {
|
---|
22 | /**
|
---|
23 | * No special test rules
|
---|
24 | */
|
---|
25 | @RegisterExtension
|
---|
26 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
27 | public JOSMTestRules test = new JOSMTestRules();
|
---|
28 |
|
---|
29 | private Layer testLayer;
|
---|
30 |
|
---|
31 | /**
|
---|
32 | * Create test layer
|
---|
33 | */
|
---|
34 | @BeforeEach
|
---|
35 | public void setUp() {
|
---|
36 | testLayer = new LayerManagerTest.TestLayer();
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Test {@link Layer#invalidate()}
|
---|
41 | */
|
---|
42 | @Test
|
---|
43 | void testInvalidate() {
|
---|
44 | AtomicBoolean fired = new AtomicBoolean();
|
---|
45 | PaintableInvalidationListener listener = l -> fired.set(true);
|
---|
46 | testLayer.addInvalidationListener(listener);
|
---|
47 | assertFalse(fired.get());
|
---|
48 | testLayer.invalidate();
|
---|
49 | assertTrue(fired.get());
|
---|
50 |
|
---|
51 | fired.set(false);
|
---|
52 | testLayer.removeInvalidationListener(listener);
|
---|
53 | testLayer.invalidate();
|
---|
54 | assertFalse(fired.get());
|
---|
55 | }
|
---|
56 | }
|
---|