Skip to content

Commit fcbbfed

Browse files
authored
test(clion): the settings run reads the settled text, and a plugin change runs the real IDEs (#20)
The settings run types into the field once it owns the focus and polls for the settled text, so a keystroke that arrives before the focus no longer fails the run. ci.yml runs clion-stable after every successful CLion build of a change, not only after a backend change.
1 parent 9ec5773 commit fcbbfed

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,11 @@ jobs:
650650

651651
# Both stable families load the exact same packaged ZIP. These are actual
652652
# IDE startup/session checks, in addition to the static Plugin Verifier.
653+
# Whenever the plugin was built here: a change of the plugin alone skips the backend's jobs, and a
654+
# skipped job upstream would otherwise skip this one too.
653655
clion-stable:
654656
needs: clion
657+
if: ${{ !cancelled() && needs.clion.result == 'success' }}
655658
uses: ./.github/workflows/clion-stable.yml
656659
with:
657660
plugin_artifact: mcpp-clion-zip

‎mide-plugins/clion/integration-tests/src/test/kotlin/SettingsInteractionTest.kt‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ interface SettingsTextRemote {
4545
fun getText(): String
4646
fun setText(value: String)
4747
fun requestFocusInWindow(): Boolean
48+
fun isFocusOwner(): Boolean
4849
}
4950

5051
@Remote("com.intellij.openapi.application.PathManager")
@@ -129,6 +130,10 @@ class SettingsInteractionTest {
129130
val apply = dialog.x("//div[@visible_text='Apply' or @text='Apply']")
130131
fun typeValue(target: SettingsTextRemote, value: String) {
131132
assertTrue(withContext(OnDispatcher.EDT) { target.requestFocusInWindow() })
133+
// Keys go to the focus owner, which the request makes it only once the EDT has run it.
134+
val focused = System.nanoTime() + java.util.concurrent.TimeUnit.SECONDS.toNanos(10)
135+
while (!withContext(OnDispatcher.EDT) { target.isFocusOwner() } && System.nanoTime() < focused) Thread.sleep(50)
136+
assertTrue(withContext(OnDispatcher.EDT) { target.isFocusOwner() }, "the input owns the keyboard before it is typed into")
132137
label.keyboard {
133138
// This check exercises actual text-input events, which
134139
// notify the native Settings editor of modifications.
@@ -137,7 +142,11 @@ class SettingsInteractionTest {
137142
backspace()
138143
if (value.isNotEmpty()) typeText(value)
139144
}
140-
assertEquals(value, target.getText(), "the real input receives the typed value")
145+
// The typed keys are events the EDT handles after they are posted: the text is read once it
146+
// has settled, not as the last key is posted.
147+
val typed = System.nanoTime() + java.util.concurrent.TimeUnit.SECONDS.toNanos(10)
148+
while (withContext(OnDispatcher.EDT) { target.getText() } != value && System.nanoTime() < typed) Thread.sleep(50)
149+
assertEquals(value, withContext(OnDispatcher.EDT) { target.getText() }, "the real input receives the typed value")
141150
}
142151
fun setAndApply(value: String) {
143152
typeValue(field, value)

0 commit comments

Comments
 (0)