diff options
Diffstat (limited to 'google-login-plugin/testSrc/com/google/gct/login2/settings/GoogleLoginApplicationSettingsConfigurableUiTest.kt')
-rw-r--r-- | google-login-plugin/testSrc/com/google/gct/login2/settings/GoogleLoginApplicationSettingsConfigurableUiTest.kt | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/google-login-plugin/testSrc/com/google/gct/login2/settings/GoogleLoginApplicationSettingsConfigurableUiTest.kt b/google-login-plugin/testSrc/com/google/gct/login2/settings/GoogleLoginApplicationSettingsConfigurableUiTest.kt index c99072b..e7a5afd 100644 --- a/google-login-plugin/testSrc/com/google/gct/login2/settings/GoogleLoginApplicationSettingsConfigurableUiTest.kt +++ b/google-login-plugin/testSrc/com/google/gct/login2/settings/GoogleLoginApplicationSettingsConfigurableUiTest.kt @@ -49,6 +49,7 @@ import com.intellij.ui.components.AnActionLink import com.intellij.ui.components.BrowserLink import com.intellij.ui.components.JBLabel import com.intellij.ui.components.JBList +import com.intellij.util.ui.UIUtil import icons.GoogleLoginIcons import java.awt.Color import java.awt.GradientPaint @@ -333,4 +334,54 @@ class GoogleLoginApplicationSettingsConfigurableUiTest { } createModalDialogAndInteractWithIt({ dialog.show() }) { body() } } + + @Test + @RunsInEdt + fun testAllowButton() { + loginUsersRule.setActiveUser("user2", setOf(loginFeatureRule.FEATURE2)) + loginUsersRule.setActiveUser("user1", setOf(loginFeatureRule.FEATURE1)) + + val component = + GoogleLoginApplicationSettingsConfigurableUi() + .also { Disposer.register(disposableRule.disposable, it) } + .component + val list = component.flatten().filterIsInstance<JBList<*>>().single() + + list.setSelectedValue(loginUsersRule.getUser("user2"), false) + UIUtil.dispatchAllInvocationEvents() + + val button1 = + component + .flatten() + .single { it.name == "test_feature_1 panel" } + .flatten() + .filterIsInstance<JButton>() + .single() + val button2 = + component + .flatten() + .single { it.name == "test_feature_2 panel" } + .flatten() + .filterIsInstance<JButton>() + .single() + + assertThat(button1.isEnabled).isTrue() + assertThat(button1.text).isEqualTo("Allow") + assertThat(button2.isEnabled).isFalse() + assertThat(button2.text).isEqualTo("Allowed") + + list.setSelectedValue(loginUsersRule.getUser("user1"), false) + UIUtil.dispatchAllInvocationEvents() + + assertThat(button2.isEnabled).isTrue() + assertThat(button2.text).isEqualTo("Allow") + assertThat(button1.isEnabled).isFalse() + assertThat(button1.text).isEqualTo("Allowed") + + button2.actionListeners.forEach { it.actionPerformed(null) } + UIUtil.dispatchAllInvocationEvents() + waitForCondition(1.seconds) { !button2.isEnabled } + assertThat(button2.text).isEqualTo("Allowed") + assertThat(loginUsersRule.getUser("user2")?.isLoggedIn(loginFeatureRule.FEATURE2)).isTrue() + } } |