package jetbrains.mps.editor.contextActionsTool.tests;
/*Generated by MPS */
import junit.framework.TestCase;
import jetbrains.mps.openapi.editor.menus.transformation.TransformationMenuItem;
import jetbrains.mps.smodel.runtime.IconResource;
import java.util.List;
import jetbrains.mps.editor.contextActionsTool.pluginSolution.plugin.ToolComponent;
import jetbrains.mps.editor.contextActionsTool.pluginSolution.plugin.ItemConverter;
import java.util.Collections;
import junit.framework.Assert;
import jetbrains.mps.internal.collections.runtime.ListSequence;
import jetbrains.mps.openapi.editor.menus.transformation.ActionItemBase;
import jetbrains.mps.editor.contextActionsTool.lang.menus.runtime.SidebarActionItem;
public class IconLoading_Test extends TestCase {
public void test_noClassDefFoundErrorWhenLoadingIcon() throws Exception {
TransformationMenuItem item = new IconLoading_Test.SidebarItemBase() {
@Override
public IconResource getIcon() {
throw new NoClassDefFoundError("Simulated error when loading an icon");
}
};
List<ToolComponent.IItem> converted = ItemConverter.convertItems(Collections.singletonList(item));
Assert.assertNull(ListSequence.fromList(converted).getElement(0).getIcon());
}
public void test_runtimeExceptionWhenLoadingIcon() throws Exception {
TransformationMenuItem item = new IconLoading_Test.SidebarItemBase() {
@Override
public IconResource getIcon() {
throw new RuntimeException("Simulated exception when loading an icon");
}
};
List<ToolComponent.IItem> converted = ItemConverter.convertItems(Collections.singletonList(item));
Assert.assertNull(ListSequence.fromList(converted).getElement(0).getIcon());
}
private class SidebarItemBase extends ActionItemBase implements SidebarActionItem {
@Override
public String getTooltipText() {
return null;
}
@Override
public IconResource getIcon() {
return null;
}
}
}