@@ -7,47 +7,34 @@ import com.intellij.codeInsight.CodeInsightSettings
77import com.intellij.openapi.Disposable
88import com.intellij.openapi.application.ApplicationManager
99import com.intellij.openapi.util.Disposer
10- import com.intellij.testFramework.ProjectExtension
11- import com.intellij.testFramework.junit5.TestDisposable
10+ import com.intellij.testFramework.HeavyPlatformTestCase
1211import com.intellij.testFramework.replaceService
1312import org.assertj.core.api.Assertions.assertThat
14- import org.junit.jupiter.api.BeforeEach
15- import org.junit.jupiter.api.Test
16- import org.junit.jupiter.api.extension.RegisterExtension
1713import org.mockito.kotlin.spy
1814import org.mockito.kotlin.times
1915import org.mockito.kotlin.verify
2016
21- class CodeInsightsSettingsFacadeTest {
17+ class CodeInsightsSettingsFacadeTest : HeavyPlatformTestCase () {
2218 private lateinit var settings: CodeInsightSettings
2319 private lateinit var sut: CodeInsightsSettingsFacade
2420
25- @TestDisposable
26- private lateinit var disposable: Disposable
27-
28- companion object {
29- @JvmField
30- @RegisterExtension
31- val projectExtension = ProjectExtension ()
32- }
33-
34- @BeforeEach
35- fun setUp () {
21+ override fun setUp () {
22+ super .setUp()
3623 sut = spy(CodeInsightsSettingsFacade ())
3724 settings = spy { CodeInsightSettings () }
3825
3926 ApplicationManager .getApplication().replaceService(
4027 CodeInsightSettings ::class .java,
4128 settings,
42- disposable
29+ testRootDisposable
4330 )
4431 }
4532
46- @Test
47- fun `disableCodeInsightUntil should revert when parent is disposed` () {
48- val myFakePopup = Disposable {}.also {
49- Disposer .register(disposable, it)
33+ fun testDisableCodeInsightUntilShouldRevertWhenParentIsDisposed () {
34+ val myFakePopup = object : Disposable {
35+ override fun dispose () {}
5036 }
37+ Disposer .register(testRootDisposable, myFakePopup)
5138
5239 // assume users' enable the following two codeinsight functionalities
5340 settings.TAB_EXITS_BRACKETS_AND_QUOTES = true
@@ -71,14 +58,13 @@ class CodeInsightsSettingsFacadeTest {
7158 assertThat(settings.AUTO_POPUP_COMPLETION_LOOKUP ).isTrue
7259 }
7360
74- @Test
75- fun `revertAll should revert back all changes made by codewhisperer` () {
61+ fun testRevertAllShouldRevertBackAllChangesMadeByCodewhisperer () {
7662 settings.TAB_EXITS_BRACKETS_AND_QUOTES = true
7763 assertThat(settings.TAB_EXITS_BRACKETS_AND_QUOTES ).isTrue
7864 settings.AUTOCOMPLETE_ON_CODE_COMPLETION = true
7965 assertThat(settings.AUTO_POPUP_COMPLETION_LOOKUP ).isTrue
8066
81- sut.disableCodeInsightUntil(disposable )
67+ sut.disableCodeInsightUntil(testRootDisposable )
8268
8369 assertThat(settings.TAB_EXITS_BRACKETS_AND_QUOTES ).isFalse
8470 assertThat(settings.AUTO_POPUP_COMPLETION_LOOKUP ).isFalse
@@ -91,14 +77,16 @@ class CodeInsightsSettingsFacadeTest {
9177 assertThat(settings.AUTO_POPUP_COMPLETION_LOOKUP ).isTrue
9278 }
9379
94- @Test
95- fun `disableCodeInsightUntil should always flush pending reverts before making next changes` () {
96- val myFakePopup = Disposable {}.also {
97- Disposer .register(disposable, it)
80+ fun testDisableCodeInsightUntilShouldAlwaysFlushPendingRevertsBeforeMakingNextChanges () {
81+ val myFakePopup = object : Disposable {
82+ override fun dispose () {}
9883 }
99- val myAnotherFakePopup = Disposable {}.also {
100- Disposer .register(disposable, it)
84+ Disposer .register(testRootDisposable, myFakePopup)
85+
86+ val myAnotherFakePopup = object : Disposable {
87+ override fun dispose () {}
10188 }
89+ Disposer .register(testRootDisposable, myAnotherFakePopup)
10290
10391 // assume users' enable the following two codeinsight functionalities
10492 settings.TAB_EXITS_BRACKETS_AND_QUOTES = true
@@ -129,8 +117,7 @@ class CodeInsightsSettingsFacadeTest {
129117 assertThat(settings.AUTO_POPUP_COMPLETION_LOOKUP ).isTrue
130118 }
131119
132- @Test
133- fun `dispose should call revertAll to revert all changes made by CodeWhisperer` () {
120+ fun testDisposeShouldCallRevertAllToRevertAllChangesMadeByCodeWhisperer () {
134121 sut.dispose()
135122 verify(sut).revertAll()
136123 }
0 commit comments