package jetbrains.mps.lang.editor.menus.style.tests.tests;

/*Generated by MPS */

import jetbrains.mps.MPSLaunch;
import jetbrains.mps.lang.test.runtime.BaseTransformationTest;
import org.junit.jupiter.api.extension.RegisterExtension;
import jetbrains.mps.lang.test.runtime.TestParametersCacheExtension;
import jetbrains.mps.lang.test.runtime.TestParametersCache;
import org.junit.jupiter.api.Test;
import jetbrains.mps.lang.test.runtime.BaseEditorTestBody;
import jetbrains.mps.lang.test.runtime.TransformationTest;
import jetbrains.mps.lang.test.runtime.EditorTestUtil;
import jetbrains.mps.nodeEditor.cellMenu.NodeSubstituteChooser;
import org.junit.Assert;
import jetbrains.mps.openapi.editor.cells.SubstituteAction;
import jetbrains.mps.nodeEditor.cellMenu.EditorMenuItemStyleImpl;
import java.util.Objects;
import java.awt.Color;

@MPSLaunch
public class TestCompletionCustomization_Style_Test extends BaseTransformationTest {
  @RegisterExtension
  private static final TestParametersCacheExtension ourParametersCacheExtension = new TestParametersCacheExtension(new TestParametersCache(TestCompletionCustomization_Style_Test.class, "${mps_home}", "r:e67a2364-cd3f-43c0-b822-e9e7747803fc(jetbrains.mps.lang.editor.menus.style.tests.tests@tests)", false));

  public TestCompletionCustomization_Style_Test() {
    super(ourParametersCacheExtension.getParametersCache());
  }

  @Test
  public void test_TestCompletionCustomization_Style() throws Throwable {
    new TestBody(this).testMethod();
  }

  /*package*/ static class TestBody extends BaseEditorTestBody {

    /*package*/ TestBody(TransformationTest owner) {
      super(owner);
    }

    @Override
    public void testMethodImpl() throws Exception {
      initEditorComponent("8199816903239854353", "");

      EditorTestUtil.runWithCompletionStyling(() -> {
        invokeAction("jetbrains.mps.ide.editor.actions.Complete_Action");
        NodeSubstituteChooser nodeSubstituteChooser = getEditorComponent().getNodeSubstituteChooser();
        Assert.assertTrue(nodeSubstituteChooser.getNumberOfActions() == 1);
        SubstituteAction currentSubstituteAction = nodeSubstituteChooser.getCurrentSubstituteAction();
        EditorMenuItemStyleImpl impl = new EditorMenuItemStyleImpl();
        currentSubstituteAction.customize("", impl);
        Assert.assertTrue(impl.isBold());
        Assert.assertTrue(impl.isItalic());
        Assert.assertTrue(impl.isStrikeout());
        Assert.assertTrue(Objects.equals(impl.getDescriptionText().orElse(null), "custom_description"));
        Assert.assertTrue(Objects.equals(impl.getBackgroundColor().orElse(null), Color.BLUE));
        Assert.assertTrue(Objects.equals(impl.getTextColor().orElse(null), Color.YELLOW));
      }, true);
    }
  }
}
