From f7e44776536e85f905af1b3308a90f5c70c6667c Mon Sep 17 00:00:00 2001 From: Alexey Merkulov Date: Tue, 10 Jul 2018 16:34:38 +0300 Subject: [PATCH] Updated typing tests IDEA-CR-34781 --- .../yaml/editing/YAMLTypingTest.java | 39 +++++++++++++++++-- ...ceItem.txt => newIndentedSequenceItem.txt} | 0 ...ceItem.yml => newIndentedSequenceItem.yml} | 0 .../data/newSequenceItemZeroIndent.txt | 3 ++ .../data/newSequenceItemZeroIndent.yml | 2 + 5 files changed, 41 insertions(+), 3 deletions(-) rename plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/{newSequenceItem.txt => newIndentedSequenceItem.txt} (100%) rename plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/{newSequenceItem.yml => newIndentedSequenceItem.yml} (100%) create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItemZeroIndent.txt create mode 100644 plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItemZeroIndent.yml diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/editing/YAMLTypingTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/editing/YAMLTypingTest.java index 761acead7b55..a58c2734e82b 100644 --- a/plugins/yaml/testSrc/org/jetbrains/yaml/editing/YAMLTypingTest.java +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/editing/YAMLTypingTest.java @@ -1,8 +1,13 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.yaml.editing; +import com.intellij.application.options.CodeStyle; import com.intellij.openapi.application.ex.PathManagerEx; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase; +import com.intellij.util.ObjectUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.yaml.formatter.YAMLCodeStyleSettings; public class YAMLTypingTest extends LightPlatformCodeInsightFixtureTestCase { @Override @@ -22,8 +27,20 @@ public class YAMLTypingTest extends LightPlatformCodeInsightFixtureTestCase { doTest("\n"); } - public void testNewSequenceItem() { - doTest("\n"); + public void testNewIndentedSequenceItem_indentedSequence() { + checkSameResultForAnySequenceIndent("\n", true); + } + + public void testNewIndentedSequenceItem_sameIndent() { + checkSameResultForAnySequenceIndent("\n", false); + } + + public void testNewSequenceItemZeroIndent_indentedSequence() { + checkSameResultForAnySequenceIndent("\n", true); + } + + public void testNewSequenceItemZeroIndent_sameIndent() { + checkSameResultForAnySequenceIndent("\n", false); } public void testEmptyInlinedValue() { @@ -51,10 +68,26 @@ public class YAMLTypingTest extends LightPlatformCodeInsightFixtureTestCase { } @SuppressWarnings("SameParameterValue") - private void doTest(String insert) { + private void doTest(@NotNull String insert) { String testName = getTestName(true); myFixture.configureByFile(testName + ".yml"); myFixture.type(insert); myFixture.checkResultByFile(testName + ".txt"); } + + @SuppressWarnings("SameParameterValue") + private void checkSameResultForAnySequenceIndent(@NotNull String insert, boolean indentSequenceVal) { + String testName = getTestName(true); + String fileName = ObjectUtils.notNull(StringUtil.substringBefore(testName, "_"), testName); + myFixture.configureByFile(fileName + ".yml"); + + getCustomSettings().INDENT_SEQUENCE_VALUE = indentSequenceVal; + myFixture.type(insert); + myFixture.checkResultByFile(fileName + ".txt"); + } + + @NotNull + private YAMLCodeStyleSettings getCustomSettings() { + return CodeStyle.getCustomSettings(myFixture.getFile(), YAMLCodeStyleSettings.class); + } } diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItem.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newIndentedSequenceItem.txt similarity index 100% rename from plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItem.txt rename to plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newIndentedSequenceItem.txt diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItem.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newIndentedSequenceItem.yml similarity index 100% rename from plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItem.yml rename to plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newIndentedSequenceItem.yml diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItemZeroIndent.txt b/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItemZeroIndent.txt new file mode 100644 index 000000000000..a76e2e464607 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItemZeroIndent.txt @@ -0,0 +1,3 @@ +top: +- hello + diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItemZeroIndent.yml b/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItemZeroIndent.yml new file mode 100644 index 000000000000..32fe4089e3a8 --- /dev/null +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/editing/data/newSequenceItemZeroIndent.yml @@ -0,0 +1,2 @@ +top: +- hello