mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Add test for listeners in optional dependencies
GitOrigin-RevId: 4ca7ee503b22dcef3ead7c9f7a00d3f1c1eb7f59
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e937a9c8dc
commit
0685ecc3d5
@@ -55,6 +55,7 @@ class DynamicPluginsTest {
|
||||
val projectRule = ProjectRule()
|
||||
|
||||
val receivedNotifications = mutableListOf<UISettings>()
|
||||
val receivedNotifications2 = mutableListOf<UISettings>()
|
||||
}
|
||||
|
||||
@Rule
|
||||
@@ -376,6 +377,55 @@ class DynamicPluginsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun loadOptionalDependencyListener() {
|
||||
receivedNotifications.clear()
|
||||
receivedNotifications2.clear()
|
||||
|
||||
val plugin1Disposable = loadPluginWithOptionalDependency(
|
||||
"""
|
||||
<idea-plugin>
|
||||
<id>foo</id>
|
||||
<depends optional="true" config-file="bar.xml">bar</depends>
|
||||
<applicationListeners>
|
||||
<listener class="${MyUISettingsListener::class.java.name}" topic="com.intellij.ide.ui.UISettingsListener"/>
|
||||
</applicationListeners>
|
||||
</idea-plugin>
|
||||
""",
|
||||
"""
|
||||
<idea-plugin>
|
||||
<applicationListeners>
|
||||
<listener class="${MyUISettingsListener2::class.java.name}" topic="com.intellij.ide.ui.UISettingsListener"/>
|
||||
</applicationListeners>
|
||||
</idea-plugin>
|
||||
""")
|
||||
try {
|
||||
ApplicationManager.getApplication().messageBus.syncPublisher(UISettingsListener.TOPIC).uiSettingsChanged(UISettings())
|
||||
assertThat(receivedNotifications).hasSize(1)
|
||||
|
||||
val plugin2Disposable = loadPluginWithText("""
|
||||
<idea-plugin>
|
||||
<id>bar</id>
|
||||
</idea-plugin>
|
||||
""".trimIndent(), DynamicPluginsTest::class.java.classLoader)
|
||||
try {
|
||||
ApplicationManager.getApplication().messageBus.syncPublisher(UISettingsListener.TOPIC).uiSettingsChanged(UISettings())
|
||||
assertThat(receivedNotifications).hasSize(2)
|
||||
assertThat(receivedNotifications2).hasSize(1)
|
||||
}
|
||||
finally {
|
||||
Disposer.dispose(plugin2Disposable)
|
||||
}
|
||||
|
||||
ApplicationManager.getApplication().messageBus.syncPublisher(UISettingsListener.TOPIC).uiSettingsChanged(UISettings())
|
||||
assertThat(receivedNotifications).hasSize(3)
|
||||
assertThat(receivedNotifications2).hasSize(1)
|
||||
}
|
||||
finally {
|
||||
Disposer.dispose(plugin1Disposable)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testProjectService() {
|
||||
val project = projectRule.project
|
||||
@@ -508,6 +558,12 @@ class DynamicPluginsTest {
|
||||
}
|
||||
}
|
||||
|
||||
private class MyUISettingsListener2 : UISettingsListener {
|
||||
override fun uiSettingsChanged(uiSettings: UISettings) {
|
||||
receivedNotifications2.add(uiSettings)
|
||||
}
|
||||
}
|
||||
|
||||
private data class MyPersistentState(@Attribute var stateData: String? = "")
|
||||
|
||||
@State(name = "MyTestState", storages = [Storage("other.xml")], allowLoadInTests = true)
|
||||
|
||||
Reference in New Issue
Block a user