-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
9 additions
and
38 deletions.
There are no files selected for viewing
47 changes: 9 additions & 38 deletions
47
test/src/com/dmarcotte/handlebars/editor/actions/HbMoverTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,36 @@ | ||
package com.dmarcotte.handlebars.editor.actions; | ||
|
||
import com.dmarcotte.handlebars.util.HbTestUtils; | ||
import com.intellij.codeInsight.editorActions.moveUpDown.MoveStatementUpAction; | ||
import com.intellij.openapi.command.WriteCommandAction; | ||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler; | ||
import com.intellij.openapi.actionSystem.IdeActions; | ||
import com.intellij.testFramework.PlatformTestCase; | ||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; | ||
import org.jetbrains.annotations.NonNls; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.File; | ||
|
||
|
||
public class HbMoverTest extends LightPlatformCodeInsightFixtureTestCase { | ||
|
||
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors") | ||
public HbMoverTest() { | ||
PlatformTestCase.initPlatformLangPrefix(); | ||
} | ||
|
||
public void testMoveXmlWhenOpenHtmlAsHandlebars() throws Exception { | ||
public void testMoveXmlWhenOpenHtmlAsHandlebars() { | ||
HbTestUtils.setOpenHtmlAsHandlebars(true, getProject(), getTestRootDisposable()); | ||
doTest("hbs"); | ||
} | ||
|
||
public void testMoveHbsTag() throws Exception { | ||
public void testMoveHbsTag() { | ||
doTest("hbs"); | ||
} | ||
|
||
private void doTest(String ext) throws Exception { | ||
final String baseName = getBasePath() + '/' + getTestName(true); | ||
final String fileName = baseName + "." + ext; | ||
|
||
@NonNls String afterFileName = baseName + "_after." + ext; | ||
EditorActionHandler handler = new MoveStatementUpAction().getHandler(); | ||
performAction(fileName, handler, afterFileName); | ||
} | ||
|
||
private void performAction(final String fileName, final EditorActionHandler handler, final String afterFileName) throws Exception { | ||
myFixture.configureByFile(fileName); | ||
final boolean enabled = handler.isEnabled(myFixture.getEditor(), null); | ||
assertEquals("not enabled for " + afterFileName, new File(getTestDataPath(), afterFileName).exists(), enabled); | ||
if (enabled) { | ||
WriteCommandAction.runWriteCommandAction(null, new Runnable() { | ||
@Override | ||
public void run() { | ||
handler.execute(myFixture.getEditor(), null); | ||
} | ||
}); | ||
myFixture.checkResultByFile(afterFileName); | ||
} | ||
private void doTest(@NotNull String ext) { | ||
myFixture.configureByFile(getTestName(true) + "." + ext); | ||
myFixture.performEditorAction(IdeActions.ACTION_MOVE_STATEMENT_UP_ACTION); | ||
myFixture.checkResultByFile(getTestName(true) + "_after." + ext); | ||
} | ||
|
||
@Override | ||
protected String getBasePath() { | ||
return "mover"; | ||
} | ||
|
||
|
||
@NotNull | ||
@Override | ||
protected String getTestDataPath() { | ||
return HbTestUtils.BASE_TEST_DATA_PATH; | ||
return HbTestUtils.BASE_TEST_DATA_PATH + "/mover"; | ||
} | ||
} |