Skip to content

Commit

Permalink
Add test case for loading MarkerFields via marker content generator e…
Browse files Browse the repository at this point in the history
  • Loading branch information
travkin79 committed Aug 15, 2024
1 parent 8ad21aa commit 19a2cf9
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
import org.eclipse.ui.internal.views.markers.FiltersConfigurationDialog;
import org.eclipse.ui.internal.views.markers.MarkerContentGenerator;
import org.eclipse.ui.tests.harness.util.UITestCase;
import org.eclipse.ui.views.markers.MarkerField;
import org.eclipse.ui.views.markers.MarkerSupportView;
import org.eclipse.ui.views.markers.internal.ContentGeneratorDescriptor;
import org.eclipse.ui.views.markers.internal.MarkerMessages;
import org.eclipse.ui.views.markers.internal.MarkerSupportRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -125,6 +128,27 @@ public void limitDisabled() throws Exception {
assertFalse(isLimitEnabled);
}

@Test
public void markerContentGeneratorExtensionLoaded() throws Exception {
MarkerSupportView view = (MarkerSupportView) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().showView(PROBLEM_VIEW_ID);

MarkerContentGenerator generator = getMarkerContentGenerator(view);
ContentGeneratorDescriptor descriptor = MarkerSupportRegistry.getInstance()
.getContentGenDescriptor(generator.getId());
MarkerField[] allFields = descriptor.getAllFields();

boolean foundAdditionalFieldRegisteredViaExtension = false;
for (MarkerField field : allFields) {
if (ProblemKeyMarkerField.class.equals(field.getClass())) {
foundAdditionalFieldRegisteredViaExtension = true;
break;
}
}

assertTrue(foundAdditionalFieldRegisteredViaExtension);
}

public static MarkerContentGenerator getMarkerContentGenerator(MarkerSupportView view) {
MarkerContentGenerator generator = null;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.eclipse.ui.tests.markers;

import org.eclipse.ui.views.markers.MarkerField;
import org.eclipse.ui.views.markers.MarkerItem;

public class ProblemKeyMarkerField extends MarkerField {

@Override
public String getValue(MarkerItem item) {
if (item == null) {
return "";
}
return item.getAttributeValue("problemKey", "");
}

}
39 changes: 38 additions & 1 deletion tests/org.eclipse.ui.tests/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3411,7 +3411,30 @@
</markerContentGenerator>
<markerContentGenerator
id="org.eclipse.ui.tests.customScopeContentGenerator">
</markerContentGenerator>
</markerContentGenerator>
<markerField
class="org.eclipse.ui.tests.markers.ProblemKeyMarkerField"
id="org.eclipse.ui.tests.markerField.problemKey"
name="Problem Key">
</markerField>
<markerContentGenerator
id="org.eclipse.ui.tests.additionalProblemMarkerContentGenerator"
name="Additional Problem Marker Content Generator">
<markerFieldReference
id="org.eclipse.ui.tests.markerField.problemKey">
</markerFieldReference>
<markerTypeReference
id="org.eclipse.ui.tests.markers.static.analysis.problem">
</markerTypeReference>
</markerContentGenerator>
<markerContentGeneratorExtension
generatorId="org.eclipse.ui.ide.problemsGenerator"
id="org.eclipse.ui.tests.additionalProblemMarkerContentGenerator">
</markerContentGeneratorExtension>
<markerContentGeneratorExtension
generatorId="org.eclipse.ui.ide.allMarkersGenerator"
id="org.eclipse.ui.tests.additionalProblemMarkerContentGenerator">
</markerContentGeneratorExtension>
</extension>
<extension
id="categoryTestMarker"
Expand Down Expand Up @@ -4838,5 +4861,19 @@
categoryId="org.eclipse.ui.tests.issue1832">
</categoryActivityBinding>
</extension>
<extension
id="markers.static.analysis.problem"
name="Static Analysis Test Problem"
point="org.eclipse.core.resources.markers">
<super
type="org.eclipse.core.resources.problemmarker">
</super>
<persistent
value="true">
</persistent>
<attribute
name="problemKey">
</attribute>
</extension>

</plugin>

0 comments on commit 19a2cf9

Please sign in to comment.