-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed commit of the following: commit 24db6db Author: Enda O Brien <[email protected]> Date: Fri Sep 20 13:19:55 2024 +0100 579498 filter dialog types #144 Squashed commit of the following: commit 94f352d Author: Enda O Brien <[email protected]> Date: Thu Apr 4 17:07:02 2024 +0100 Fixed a couple of warnings in test code commit 49a195d Author: Enda O Brien <[email protected]> Date: Wed Aug 24 15:54:38 2022 +0100 put add and addAll back in previous order commit 7dd8032 Author: Enda O Brien <[email protected]> Date: Wed Aug 24 15:11:23 2022 +0100 Moved copyright to be first lines in files commit 87763b5 Author: Enda O Brien <[email protected]> Date: Wed Aug 24 14:41:46 2022 +0100 Modified copyright message in test code to include my name commit 1b08d4a Author: Enda O Brien <[email protected]> Date: Wed Aug 24 14:09:12 2022 +0100 updated documentation of markerSupport.exsd commit 579fca0 Author: Enda O Brien <[email protected]> Date: Wed Aug 24 12:04:44 2022 +0100 Added copyright notice to test code commit 1271c95 Author: Enda O Brien <[email protected]> Date: Wed Aug 24 11:49:13 2022 +0100 Fixed whitespace differences commit 36e50cd Author: Enda O Brien <[email protected]> Date: Thu Jun 9 14:16:44 2022 +0100 Test code for application attribute on marker type reference commit 01940b2 Author: Enda O Brien <[email protected]> Date: Thu Jun 9 10:57:55 2022 +0100 Added application attribute to type reference in marker content generator
- Loading branch information
1 parent
0986115
commit 99c91af
Showing
9 changed files
with
346 additions
and
4 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
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
18 changes: 18 additions & 0 deletions
18
...g.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/NoApplicationAttribTestView.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,18 @@ | ||
package org.eclipse.ui.tests; | ||
|
||
import org.eclipse.ui.views.markers.MarkerSupportView; | ||
|
||
/** | ||
* @since 3.5 | ||
* | ||
*/ | ||
public class NoApplicationAttribTestView extends MarkerSupportView { | ||
public static final String ID = "org.eclipse.ui.tests.noApplicationAttribTestView"; | ||
|
||
static final String CONTENT_GEN_ID = "org.eclipse.ui.tests.noApplicationAttribTestViewContentGenerator"; | ||
|
||
public NoApplicationAttribTestView() { | ||
super(CONTENT_GEN_ID); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/SubTypeOnlyTestView.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,25 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Enda O'Brien and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which accompanies this distribution, | ||
* and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.ui.tests; | ||
|
||
import org.eclipse.ui.views.markers.MarkerSupportView; | ||
|
||
public class SubTypeOnlyTestView extends MarkerSupportView { | ||
public static final String ID = "org.eclipse.ui.tests.subTypeOnlyTestView"; | ||
|
||
static final String CONTENT_GEN_ID = "org.eclipse.ui.tests.subTypeOnlyTestViewContentGenerator"; | ||
|
||
public SubTypeOnlyTestView() { | ||
super(CONTENT_GEN_ID); | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeAndSubTypeTestView.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,25 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Enda O'Brien and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which accompanies this distribution, | ||
* and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.ui.tests; | ||
|
||
import org.eclipse.ui.views.markers.MarkerSupportView; | ||
|
||
public class TypeAndSubTypeTestView extends MarkerSupportView { | ||
public static final String ID = "org.eclipse.ui.tests.typeAndSubTypeTestView"; | ||
|
||
static final String CONTENT_GEN_ID = "org.eclipse.ui.tests.typeAndSubTypeTestViewContentGenerator"; | ||
|
||
public TypeAndSubTypeTestView() { | ||
super(CONTENT_GEN_ID); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/TypeOnlyTestView.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,26 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Enda O'Brien and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which accompanies this distribution, | ||
* and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.ui.tests; | ||
|
||
import org.eclipse.ui.views.markers.MarkerSupportView; | ||
|
||
public class TypeOnlyTestView extends MarkerSupportView { | ||
|
||
public static final String ID = "org.eclipse.ui.tests.typeOnlyTestView"; | ||
|
||
static final String CONTENT_GEN_ID = "org.eclipse.ui.tests.typeOnlyTestViewContentGenerator"; | ||
|
||
public TypeOnlyTestView() { | ||
super(CONTENT_GEN_ID); | ||
} | ||
|
||
} |
142 changes: 142 additions & 0 deletions
142
...s/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/markers/MarkerTypeTests.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,142 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 Enda O'Brien and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which accompanies this distribution, | ||
* and is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.ui.tests.markers; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
|
||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.ui.internal.views.markers.ExtendedMarkersView; | ||
import org.eclipse.ui.internal.views.markers.MarkerContentGenerator; | ||
import org.eclipse.ui.tests.NoApplicationAttribTestView; | ||
import org.eclipse.ui.tests.SubTypeOnlyTestView; | ||
import org.eclipse.ui.tests.TypeAndSubTypeTestView; | ||
import org.eclipse.ui.tests.TypeOnlyTestView; | ||
import org.eclipse.ui.views.markers.MarkerSupportView; | ||
import org.eclipse.ui.views.markers.internal.ContentGeneratorDescriptor; | ||
import org.eclipse.ui.views.markers.internal.MarkerType; | ||
import org.eclipse.ui.views.markers.internal.MarkerTypesModel; | ||
import org.junit.Test; | ||
|
||
public class MarkerTypeTests { | ||
|
||
static final String PROBLEM_MARKER = "org.eclipse.core.resources.problemmarker"; | ||
|
||
@Test | ||
public void canIncludeTypeOnly() throws Exception { | ||
MarkerSupportView view = (MarkerSupportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow() | ||
.getActivePage().showView(TypeOnlyTestView.ID); | ||
|
||
MarkerContentGenerator generator = getMarkerContentGenerator(view); | ||
Collection<MarkerType> filterDialogTypes = getMarkerTypes(generator); | ||
|
||
assertEquals(1, filterDialogTypes.size()); | ||
assertEquals(PROBLEM_MARKER, filterDialogTypes.stream().map(type -> type.getId()).findFirst().get()); | ||
} | ||
|
||
@Test | ||
public void canIncludeTypeAndSubTypes() throws Exception { | ||
MarkerSupportView view = (MarkerSupportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow() | ||
.getActivePage().showView(TypeAndSubTypeTestView.ID); | ||
|
||
MarkerContentGenerator generator = getMarkerContentGenerator(view); | ||
Collection<MarkerType> filterDialogTypes = getMarkerTypes(generator); | ||
|
||
Collection<MarkerType> markerTypes = new HashSet<>(); | ||
markerTypes.add(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER)); | ||
markerTypes.addAll(Arrays.asList(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER).getAllSubTypes())); | ||
|
||
assertEquals(markerTypes.size(), filterDialogTypes.size()); | ||
assertEquals(PROBLEM_MARKER, filterDialogTypes.stream().map(type -> type.getId()) | ||
.filter(s -> s.equals(PROBLEM_MARKER)).findFirst().get()); | ||
|
||
for (MarkerType type : markerTypes) { | ||
assertTrue(filterDialogTypes.contains(type)); | ||
} | ||
} | ||
|
||
@Test | ||
public void canIncludeSubtypesOnly() throws Exception { | ||
MarkerSupportView view = (MarkerSupportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow() | ||
.getActivePage().showView(SubTypeOnlyTestView.ID); | ||
|
||
MarkerContentGenerator generator = getMarkerContentGenerator(view); | ||
Collection<MarkerType> filterDialogTypes = getMarkerTypes(generator); | ||
|
||
Collection<MarkerType> markerTypes = new HashSet<>(); | ||
markerTypes.addAll(Arrays.asList(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER).getAllSubTypes())); | ||
|
||
assertEquals(markerTypes.size(), filterDialogTypes.size()); | ||
assertTrue(PROBLEM_MARKER, filterDialogTypes.stream().map(type -> type.getId()) | ||
.filter(s -> s.equals(PROBLEM_MARKER)).findFirst().isEmpty()); | ||
for (MarkerType type : markerTypes) { | ||
assertTrue(filterDialogTypes.contains(type)); | ||
} | ||
} | ||
|
||
@Test | ||
public void typeAndSubTypesIsDefault() throws Exception { | ||
MarkerSupportView view = (MarkerSupportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow() | ||
.getActivePage().showView(NoApplicationAttribTestView.ID); | ||
|
||
MarkerContentGenerator generator = getMarkerContentGenerator(view); | ||
Collection<MarkerType> filterDialogTypes = getMarkerTypes(generator); | ||
|
||
Collection<MarkerType> markerTypes = new HashSet<>(); | ||
markerTypes.add(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER)); | ||
markerTypes.addAll(Arrays.asList(MarkerTypesModel.getInstance().getType(PROBLEM_MARKER).getAllSubTypes())); | ||
|
||
assertEquals(markerTypes.size(), filterDialogTypes.size()); | ||
assertEquals(PROBLEM_MARKER, filterDialogTypes.stream().map(type -> type.getId()) | ||
.filter(s -> s.equals(PROBLEM_MARKER)).findFirst().get()); | ||
|
||
for (MarkerType type : markerTypes) { | ||
assertTrue(filterDialogTypes.contains(type)); | ||
} | ||
} | ||
|
||
public static MarkerContentGenerator getMarkerContentGenerator(MarkerSupportView view) { | ||
MarkerContentGenerator generator = null; | ||
try { | ||
Field fieldGenerator = ExtendedMarkersView.class.getDeclaredField("generator"); | ||
fieldGenerator.setAccessible(true); | ||
generator = (MarkerContentGenerator) fieldGenerator.get(view); | ||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { | ||
} | ||
return generator; | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public static Collection<MarkerType> getMarkerTypes(MarkerContentGenerator generator) { | ||
Collection<MarkerType> selectedTypesCollection = null; | ||
try { | ||
Field generatorDescriptor = MarkerContentGenerator.class.getDeclaredField("generatorDescriptor"); | ||
generatorDescriptor.setAccessible(true); | ||
|
||
ContentGeneratorDescriptor contentGeneratorDescriptor = (ContentGeneratorDescriptor) generatorDescriptor | ||
.get(generator); | ||
|
||
Field markerTypesField = ContentGeneratorDescriptor.class.getDeclaredField("markerTypes"); | ||
markerTypesField.setAccessible(true); | ||
|
||
selectedTypesCollection = (Collection<MarkerType>) markerTypesField.get(contentGeneratorDescriptor); | ||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { | ||
} | ||
return selectedTypesCollection; | ||
} | ||
} |
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