mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
AT-4096 [remote-driver]: fix JComboBoxTextFixture
(cherry picked from commit 7ca5e5d98a7de3291de277d909d4a25affed1e59) IJ-CR-193921 GitOrigin-RevId: 2fb20c05e990d5fc9d7feab513de22f7384fd1c6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
45d64c25fc
commit
70d730eab9
+37
-1
@@ -2,9 +2,11 @@
|
||||
package com.jetbrains.performancePlugin.remotedriver.fixtures
|
||||
|
||||
import com.jetbrains.performancePlugin.remotedriver.dataextractor.TextCellRendererReader
|
||||
import com.jetbrains.performancePlugin.remotedriver.dataextractor.computeOnEdt
|
||||
import org.assertj.swing.core.Robot
|
||||
import org.assertj.swing.driver.BasicJComboBoxCellReader
|
||||
import org.assertj.swing.driver.CellRendererReader
|
||||
import org.assertj.swing.driver.ComponentPreconditions
|
||||
import org.assertj.swing.fixture.JComboBoxFixture
|
||||
import javax.swing.JComboBox
|
||||
|
||||
@@ -18,7 +20,10 @@ class JComboBoxTextFixture(robot: Robot, component: JComboBox<*>) : JComboBoxFix
|
||||
}
|
||||
|
||||
fun select(text: String) {
|
||||
selectItem(text)
|
||||
checkEnabledAndShowing()
|
||||
showDropDownList()
|
||||
select(findItemIndex(text))
|
||||
hideDropDownList()
|
||||
}
|
||||
|
||||
fun selectedText(): String = selectedItem() ?: ""
|
||||
@@ -26,4 +31,35 @@ class JComboBoxTextFixture(robot: Robot, component: JComboBox<*>) : JComboBoxFix
|
||||
fun listValues(): List<String> {
|
||||
return contents().toList()
|
||||
}
|
||||
|
||||
fun getItemCount(): Int = computeOnEdt { target().itemCount }
|
||||
|
||||
private fun select(index: Int) {
|
||||
require(index in 0..<getItemCount()) { "Index $index is out of range [0, ${getItemCount()}]" }
|
||||
computeOnEdt {
|
||||
target().selectedIndex = index
|
||||
}
|
||||
robot().waitForIdle()
|
||||
}
|
||||
|
||||
private fun checkEnabledAndShowing() {
|
||||
computeOnEdt {
|
||||
ComponentPreconditions.checkEnabledAndShowing(target())
|
||||
}
|
||||
}
|
||||
|
||||
private fun showDropDownList() {
|
||||
computeOnEdt { target().showPopup() }
|
||||
robot().waitForIdle()
|
||||
}
|
||||
|
||||
private fun hideDropDownList() {
|
||||
computeOnEdt { target().hidePopup() }
|
||||
robot().waitForIdle()
|
||||
}
|
||||
|
||||
private fun findItemIndex(text: String): Int {
|
||||
val items = listValues()
|
||||
return checkNotNull(items.indexOf(text).takeIf { it >= 0 }) { "No such item in combobox: $text, contents: $items" }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user