diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/formatter/KotlinCodeStyleSettingsTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/formatter/KotlinCodeStyleSettingsTest.kt
index c7745d3f8f5d..820cab946d95 100644
--- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/formatter/KotlinCodeStyleSettingsTest.kt
+++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/formatter/KotlinCodeStyleSettingsTest.kt
@@ -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 {
diff --git a/plugins/kotlin/idea/tests/testData/codeStyle/emptyCodeStyleScheme.xml b/plugins/kotlin/idea/tests/testData/codeStyle/emptyCodeStyleScheme.xml
new file mode 100644
index 000000000000..44e47773f937
--- /dev/null
+++ b/plugins/kotlin/idea/tests/testData/codeStyle/emptyCodeStyleScheme.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/plugins/kotlin/idea/tests/testData/codeStyle/officialCodeStyleScheme.xml b/plugins/kotlin/idea/tests/testData/codeStyle/officialCodeStyleScheme.xml
index 89564f239d14..1282504a268d 100644
--- a/plugins/kotlin/idea/tests/testData/codeStyle/officialCodeStyleScheme.xml
+++ b/plugins/kotlin/idea/tests/testData/codeStyle/officialCodeStyleScheme.xml
@@ -1 +1,8 @@
-
+
+
+
+
+
+
+
+