-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unifies objectProperty for layer selection
Signed-off-by: Frank Gasdorf <[email protected]>
- Loading branch information
Showing
8 changed files
with
163 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
.../src/org/locationtech/udig/project/ui/operations/LayerSelectionPropertyParameterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* uDig - User Friendly Desktop Internet GIS client | ||
* http://udig.refractions.net | ||
* (C) 2020, Refractions Research Inc. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD | ||
* License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). | ||
* | ||
*/ | ||
package org.locationtech.udig.project.ui.operations; | ||
|
||
import static org.easymock.EasyMock.createNiceMock; | ||
import static org.easymock.EasyMock.expect; | ||
import static org.easymock.EasyMock.replay; | ||
import static org.easymock.EasyMock.verify; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.locationtech.udig.project.ILayer; | ||
import org.opengis.filter.Filter; | ||
|
||
@RunWith(Parameterized.class) | ||
public class LayerSelectionPropertyParameterTest { | ||
private Boolean expectedResult; | ||
|
||
private Filter givenFilter; | ||
|
||
private String givenValue; | ||
|
||
@SuppressWarnings("rawtypes") | ||
@Parameterized.Parameters | ||
public static Collection primeNumbers() { | ||
return Arrays.asList(new Object[][] { | ||
// no selection on layer | ||
{ false, Filter.EXCLUDE, "true" }, { false, Filter.EXCLUDE, "TRUE" }, | ||
{ false, Filter.EXCLUDE, null }, { false, Filter.EXCLUDE, "True" }, | ||
{ true, Filter.EXCLUDE, "false" }, { true, Filter.EXCLUDE, "FALSE" }, | ||
{ true, Filter.EXCLUDE, "False" }, | ||
|
||
// layer has selection | ||
{ true, Filter.INCLUDE, "true" }, { true, Filter.INCLUDE, "TRUE" }, | ||
{ true, Filter.INCLUDE, "True" }, { true, Filter.INCLUDE, null }, | ||
{ false, Filter.INCLUDE, "false" }, { false, Filter.INCLUDE, "FALSE" }, | ||
{ false, Filter.INCLUDE, "False" }, | ||
|
||
// without value or anything else than boolean values it does not really make sense | ||
{ true, Filter.EXCLUDE, "whatever" }, { false, Filter.INCLUDE, "whatever" }, }); | ||
} | ||
|
||
public LayerSelectionPropertyParameterTest(boolean expected, Filter givenFilter, | ||
String givenValue) { | ||
this.expectedResult = expected; | ||
this.givenFilter = givenFilter; | ||
this.givenValue = givenValue; | ||
} | ||
|
||
ILayer layerMock = createNiceMock(ILayer.class); | ||
|
||
@Test | ||
public void testHasSelection() { | ||
expect(layerMock.getFilter()).andReturn(givenFilter).anyTimes(); | ||
LayerSelectionProperty layerSelectionProperty = new LayerSelectionProperty(); | ||
replay(layerMock); | ||
assertEquals( | ||
MessageFormat.format("for {0} with expectedValue {1}", givenFilter, givenValue), | ||
expectedResult, layerSelectionProperty.isTrue(layerMock, givenValue)); | ||
|
||
verify(layerMock); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
....ui.tests/src/org/locationtech/udig/project/ui/operations/LayerSelectionPropertyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* uDig - User Friendly Desktop Internet GIS client | ||
* http://udig.refractions.net | ||
* (C) 2020, Refractions Research Inc. | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* (http://www.eclipse.org/legal/epl-v10.html), and the Refractions BSD | ||
* License v1.0 (http://udig.refractions.net/files/bsd3-v10.html). | ||
* | ||
*/ | ||
package org.locationtech.udig.project.ui.operations; | ||
|
||
import static org.easymock.EasyMock.anyObject; | ||
import static org.easymock.EasyMock.createNiceMock; | ||
import static org.easymock.EasyMock.expect; | ||
import static org.easymock.EasyMock.expectLastCall; | ||
import static org.easymock.EasyMock.replay; | ||
import static org.easymock.EasyMock.verify; | ||
import static org.junit.Assert.assertFalse; | ||
|
||
import org.junit.Test; | ||
import org.locationtech.udig.project.ILayer; | ||
import org.locationtech.udig.project.internal.Layer; | ||
import org.locationtech.udig.ui.operations.IOpFilterListener; | ||
import org.opengis.filter.Filter; | ||
|
||
public class LayerSelectionPropertyTest { | ||
|
||
ILayer layerMock = createNiceMock(Layer.class); | ||
|
||
IOpFilterListener listenerMock = createNiceMock(IOpFilterListener.class); | ||
|
||
@Test | ||
public void testLayerGetsNotificationOnFilterChange() { | ||
expect(layerMock.getFilter()).andReturn(Filter.EXCLUDE).anyTimes(); | ||
layerMock.addListener(anyObject()); | ||
expectLastCall().times(2); | ||
|
||
LayerSelectionProperty layerSelectionProperty = new LayerSelectionProperty(); | ||
replay(layerMock, listenerMock); | ||
// first call tries to add Listener | ||
layerSelectionProperty.isTrue(layerMock, "Whatever"); | ||
// second call tries to add Listener again | ||
layerSelectionProperty.isTrue(layerMock, "Whatever"); | ||
|
||
verify(layerMock, listenerMock); | ||
} | ||
|
||
@Test | ||
public void testCachingIsDisabled() { | ||
assertFalse(new LayerSelectionProperty().canCacheResult()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 0 additions & 50 deletions
50
...tool.select/src/org/locationtech/udig/tool/select/internal/LayerHasSelectionProperty.java
This file was deleted.
Oops, something went wrong.