package com.jetbrains.edu.coursecreator.actions;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.testFramework.MapDataContext;
import com.intellij.testFramework.TestActionEvent;
import com.jetbrains.edu.coursecreator.CCTestCase;
import com.jetbrains.edu.learning.StudyUtils;
import com.jetbrains.edu.learning.courseFormat.TaskFile;
import org.jetbrains.annotations.NotNull;

public class CCTaskFileActionTest extends CCTestCase {
  public void testHideTaskFile() {
    VirtualFile virtualFile = configureByTaskFile("taskFile.txt");
    launchAction(virtualFile, new CCHideFromStudent());
    assertNull(StudyUtils.getTaskFile(getProject(), virtualFile));
    UndoManager.getInstance(getProject()).undo(FileEditorManager.getInstance(getProject()).getSelectedEditor(virtualFile));
    TaskFile taskFile = StudyUtils.getTaskFile(getProject(), virtualFile);
    assertNotNull(taskFile);
    checkHighlighters(taskFile, myFixture.getEditor().getMarkupModel());
  }

  public void testAddTaskFile() {
    VirtualFile virtualFile = copyFileToTask("nonTaskFile.txt");
    myFixture.configureFromExistingVirtualFile(virtualFile);
    launchAction(virtualFile, new CCAddAsTaskFile());
    TaskFile taskFile = StudyUtils.getTaskFile(getProject(), virtualFile);
    assertNotNull(taskFile);
    FileEditor fileEditor = FileEditorManager.getInstance(getProject()).getSelectedEditor(virtualFile);
    UndoManager.getInstance(getProject()).undo(fileEditor);
    assertNull(StudyUtils.getTaskFile(getProject(), virtualFile));
  }

  private void launchAction(VirtualFile virtualFile, AnAction action) {
    TestActionEvent e = getActionEvent(virtualFile, action);
    action.beforeActionPerformedUpdate(e);
    assertTrue(e.getPresentation().isEnabled() && e.getPresentation().isVisible());
    action.actionPerformed(e);
  }

  @NotNull
  private TestActionEvent getActionEvent(VirtualFile virtualFile, AnAction action) {
    MapDataContext context = new MapDataContext();
    context.put(CommonDataKeys.VIRTUAL_FILE, virtualFile);
    context.put(CommonDataKeys.PROJECT, getProject());
    return new TestActionEvent(context, action);
  }

  @Override
  protected String getBasePath() {
    return super.getBasePath() + "/actions/taskFileActions";
  }
}

@@ -2283,18 +2283,42 @@
 UAL_FILE
-, 
+_ARRAY, new VirtualFile%5B%5D%7B
 virtualF
@@ -2316,24 +2316,25 @@
 %7BvirtualFile
+%7D
 );%0A    conte

fix failing edu tests