mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Kotlin] Added more tests for making the official Kotlin Code Style the default
KTIJ-20988 GitOrigin-RevId: 78aed365348e444df6bfbf8a7e72b259891efcd7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4f740edb72
commit
330289ae80
+23
-2
@@ -34,8 +34,29 @@ class KotlinCodeStyleSettingsTest : LightPlatformTestCase() {
|
||||
it.kotlinCommonSettings.BRACE_STYLE = 10
|
||||
}
|
||||
|
||||
fun `test official code style scheme`() = doTestWithScheme(KotlinStyleGuideCodeStyle.INSTANCE, "officialCodeStyleScheme.xml")
|
||||
fun `test obsolete code style scheme`() = doTestWithScheme(KotlinObsoleteCodeStyle.INSTANCE, "obsoleteCodeStyleScheme.xml")
|
||||
fun `test write official code style scheme`() = doTestWithScheme(KotlinStyleGuideCodeStyle.INSTANCE, "officialCodeStyleScheme.xml")
|
||||
fun `test write obsolete code style scheme`() = doTestWithScheme(KotlinObsoleteCodeStyle.INSTANCE, "obsoleteCodeStyleScheme.xml")
|
||||
|
||||
fun `test read official code style scheme`() = testRead(KotlinStyleGuideCodeStyle.INSTANCE, "officialCodeStyleScheme.xml")
|
||||
fun `test read obsolete code style scheme`() = testRead(KotlinObsoleteCodeStyle.INSTANCE, "obsoleteCodeStyleScheme.xml")
|
||||
// New default when empty is the official code style
|
||||
fun `test empty code style scheme`() = testRead(KotlinStyleGuideCodeStyle.INSTANCE, "emptyCodeStyleScheme.xml")
|
||||
|
||||
private fun testRead(expected: KotlinPredefinedCodeStyle, fileName: String) {
|
||||
|
||||
doWithTemporarySettings {
|
||||
val expectedSettings = CodeStyleSettingsManager.getInstance().cloneSettings(CodeStyle.getSettings(project))
|
||||
expected.apply(expectedSettings)
|
||||
val expectedCustomSettings = expectedSettings.kotlinCustomSettings
|
||||
val expectedCommonSettings = expectedSettings.kotlinCommonSettings
|
||||
|
||||
val projectSettings = CodeStyle.getSettings(project)
|
||||
val settingsElement = JDOMUtil.load(getTestFile(fileName).readText())
|
||||
projectSettings.readExternal(settingsElement)
|
||||
assertEquals(projectSettings.kotlinCustomSettings, expectedCustomSettings)
|
||||
assertEquals(projectSettings.kotlinCommonSettings, expectedCommonSettings)
|
||||
}
|
||||
}
|
||||
|
||||
private fun doTestWithScheme(codeStyle: KotlinPredefinedCodeStyle, fileName: String) {
|
||||
doWithTemporarySettings {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<code_scheme name="Project" version="173">
|
||||
</code_scheme>
|
||||
@@ -1 +1,8 @@
|
||||
<code_scheme name="Project" version="173" />
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
|
||||
Reference in New Issue
Block a user