mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
testing lockProfile() (cherry picked from commit df99c3f)
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.codeInspection.ex.InspectionProfileImpl;
|
||||
import com.intellij.codeInspection.ex.InspectionToolRegistrar;
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInspection.ex.*;
|
||||
import com.intellij.openapi.util.JDOMUtil;
|
||||
import com.intellij.profile.codeInspection.InspectionProfileManager;
|
||||
import com.intellij.testFramework.LightIdeaTestCase;
|
||||
@@ -25,6 +25,8 @@ import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.testFramework.PlatformTestUtil.assertElementsEqual;
|
||||
|
||||
@@ -171,4 +173,51 @@ public class InspectionProfileTest extends LightIdeaTestCase {
|
||||
profile.writeExternal(copy);
|
||||
assertElementsEqual(element, copy);
|
||||
}
|
||||
|
||||
public void testLockProfile() throws Exception {
|
||||
|
||||
final List<InspectionToolWrapper> list = new ArrayList<InspectionToolWrapper>();
|
||||
list.add(createTool("foo"));
|
||||
|
||||
InspectionToolRegistrar registrar = new InspectionToolRegistrar(null) {
|
||||
@Override
|
||||
public List<InspectionToolWrapper> createTools() {
|
||||
LocalInspectionEP foo = new LocalInspectionEP();
|
||||
foo.shortName = "foo";
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
||||
InspectionProfileImpl profile = new InspectionProfileImpl("Foo", registrar, InspectionProfileManager.getInstance());
|
||||
profile.setBaseProfile(null);
|
||||
List<ScopeToolState> tools = profile.getAllTools();
|
||||
assertEquals(1, tools.size());
|
||||
ModifiableModel model = profile.getModifiableModel();
|
||||
model.lockProfile(true);
|
||||
model.commit();
|
||||
Element element = new Element("element");
|
||||
profile.writeExternal(element);
|
||||
|
||||
list.add(createTool("bar"));
|
||||
|
||||
profile = new InspectionProfileImpl("Foo", registrar, InspectionProfileManager.getInstance());
|
||||
profile.readExternal(element);
|
||||
|
||||
profile.setBaseProfile(null);
|
||||
tools = profile.getAllTools();
|
||||
assertEquals(2, tools.size());
|
||||
|
||||
assertTrue(profile.isProfileLocked());
|
||||
assertFalse(profile.isToolEnabled(HighlightDisplayKey.find("bar")));
|
||||
}
|
||||
|
||||
private static LocalInspectionToolWrapper createTool(String s) {
|
||||
LocalInspectionEP foo = new LocalInspectionEP();
|
||||
foo.shortName = s;
|
||||
foo.displayName = s;
|
||||
foo.groupDisplayName = s;
|
||||
foo.level = "ERROR";
|
||||
foo.enabledByDefault = true;
|
||||
return new LocalInspectionToolWrapper(foo);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user