diff --git a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/remoteDev/JTreeFixtureAdapter.kt b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/remoteDev/JTreeFixtureAdapter.kt index 29c2a61fb705..45ea29b57b68 100644 --- a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/remoteDev/JTreeFixtureAdapter.kt +++ b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/remoteDev/JTreeFixtureAdapter.kt @@ -5,6 +5,7 @@ import com.intellij.driver.model.TreePathToRowList import com.intellij.driver.sdk.ui.CellRendererReader import com.intellij.driver.sdk.ui.components.JTreeFixtureRef import com.intellij.driver.sdk.ui.components.JTreeUiComponent +import com.intellij.driver.sdk.ui.remote.Component import com.intellij.driver.sdk.ui.remote.Robot import java.awt.Point import javax.swing.JTree @@ -99,4 +100,8 @@ class JTreeFixtureAdapter(robot: Robot, component: BeControlComponentBase) : override fun replaceCellRendererReader(reader: CellRendererReader) { fixture.replaceCellRendererReader(reader) } + + override fun getComponentAtRow(row: Int): Component { + return fixture.getComponentAtRow(row) + } } \ No newline at end of file diff --git a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JListUI.kt b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JListUI.kt index 58f5f03c8553..0e3021dc1574 100644 --- a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JListUI.kt +++ b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JListUI.kt @@ -3,12 +3,9 @@ package com.intellij.driver.sdk.ui.components import com.intellij.driver.client.Remote import com.intellij.driver.model.OnDispatcher import com.intellij.driver.sdk.invokeAction -import com.intellij.driver.sdk.ui.AccessibleNameCellRendererReader -import com.intellij.driver.sdk.ui.CellRendererReader -import com.intellij.driver.sdk.ui.Finder -import com.intellij.driver.sdk.ui.QueryBuilder +import com.intellij.driver.sdk.ui.* +import com.intellij.driver.sdk.ui.remote.Component import com.intellij.driver.sdk.ui.remote.REMOTE_ROBOT_MODULE_ID -import com.intellij.driver.sdk.ui.xQuery import org.intellij.lang.annotations.Language import java.awt.Point import java.awt.Rectangle @@ -105,6 +102,8 @@ open class JListUiComponent(data: ComponentData) : UiComponent(data) { fun getCellBounds(index: Int): Rectangle = driver.withContext(OnDispatcher.EDT) { listComponent.getCellBounds(index, index) } + fun getComponentAt(index: Int): Component = fixture.getComponentAtIndex(index) + protected fun findItemIndex(itemText: String, fullMatch: Boolean): Int? = fixture.collectItems().indexOfFirst { if (fullMatch) it == itemText @@ -123,6 +122,7 @@ interface JListFixtureRef { fun collectSelectedItems(): List fun clickItemAtIndex(index: Int) fun collectIconsAtIndex(index: Int): List + fun getComponentAtIndex(index: Int): Component } @Remote("javax.swing.JList") diff --git a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JTableUi.kt b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JTableUi.kt index 8f7d443248e2..9a0f80aacfd5 100644 --- a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JTableUi.kt +++ b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JTableUi.kt @@ -5,6 +5,7 @@ import com.intellij.driver.model.StringTable import com.intellij.driver.sdk.ui.CellRendererReader import com.intellij.driver.sdk.ui.Finder import com.intellij.driver.sdk.ui.QueryBuilder +import com.intellij.driver.sdk.ui.remote.Component import com.intellij.driver.sdk.ui.remote.REMOTE_ROBOT_MODULE_ID import com.intellij.driver.sdk.ui.xQuery import org.intellij.lang.annotations.Language @@ -29,6 +30,7 @@ open class JTableUiComponent(data: ComponentData) : UiComponent(data) { fun replaceCellRendererReader(reader: CellRendererReader) = fixture.replaceCellRendererReader(reader) fun isRowSelected(row: Int): Boolean = tableComponent.isRowSelected(row) fun getSelectedRow(): Int = tableComponent.getSelectedRow() + fun getComponentAt(row: Int, column: Int): Component = fixture.getComponentAt(row, column) } @Remote("com.jetbrains.performancePlugin.remotedriver.fixtures.JTableTextFixture", plugin = REMOTE_ROBOT_MODULE_ID) @@ -40,6 +42,7 @@ interface JTableFixtureRef { fun rightClickCell(row: Int, column: Int) fun doubleClickCell(row: Int, column: Int) fun replaceCellRendererReader(reader: CellRendererReader) + fun getComponentAt(row: Int, column: Int): Component } @Remote("javax.swing.JTable") diff --git a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JTreeUI.kt b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JTreeUI.kt index 82b3b6311710..b8ae637a8b7e 100644 --- a/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JTreeUI.kt +++ b/platform/remote-driver/test-sdk/src/com/intellij/driver/sdk/ui/components/JTreeUI.kt @@ -154,6 +154,8 @@ open class JTreeUiComponent(data: ComponentData) : UiComponent(data) { click(fixture.getRowPoint(row).apply { translate(shift.x, shift.y) }) } + fun getComponentAtRow(row: Int): Component = fixture.getComponentAtRow(row) + class PathNotFoundException(message: String? = null) : Exception(message) { constructor(path: List) : this("$path not found") } @@ -181,6 +183,7 @@ interface JTreeFixtureRef : Component { fun expandAll(timeoutMs: Int) fun getRowPoint(row: Int): Point fun replaceCellRendererReader(reader: CellRendererReader) + fun getComponentAtRow(row: Int): Component } @Remote("javax.swing.JTree") diff --git a/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JListTextFixture.kt b/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JListTextFixture.kt index d68608e7f963..21ee6d71a77b 100644 --- a/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JListTextFixture.kt +++ b/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JListTextFixture.kt @@ -7,6 +7,7 @@ import org.assertj.swing.core.Robot import org.assertj.swing.driver.BasicJListCellReader import org.assertj.swing.driver.CellRendererReader import org.assertj.swing.fixture.JListFixture +import java.awt.Component import java.awt.Container import javax.swing.JLabel import javax.swing.JList @@ -32,11 +33,7 @@ class JListTextFixture(robot: Robot, component: JList<*>) : JListFixture(robot, } fun collectIconsAtIndex(index: Int): List { - val itemComponent = computeOnEdt { - val list = target() - @Suppress("UNCHECKED_CAST") val renderer = list.cellRenderer as ListCellRenderer - renderer.getListCellRendererComponent(JList(), list.model.getElementAt(index), index, list.isSelectedIndex(index), false) - } + val itemComponent = getComponentAtIndex(index) if (itemComponent is Container) { return BasicComponentFinder.finderWithCurrentAwtHierarchy().findAll(itemComponent) { it is JLabel && it.icon != null }.map { (it as JLabel).icon.toString() @@ -44,4 +41,12 @@ class JListTextFixture(robot: Robot, component: JList<*>) : JListFixture(robot, } return emptyList() } + + fun getComponentAtIndex(index: Int): Component { + return computeOnEdt { + val list = target() + @Suppress("UNCHECKED_CAST") val renderer = list.cellRenderer as ListCellRenderer + renderer.getListCellRendererComponent(JList(), list.model.getElementAt(index), index, list.isSelectedIndex(index), list.hasFocus() && list.isSelectedIndex(index)) + } + } } \ No newline at end of file diff --git a/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JTableTextFixture.kt b/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JTableTextFixture.kt index f0216b4fe805..ad182d7adac2 100644 --- a/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JTableTextFixture.kt +++ b/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JTableTextFixture.kt @@ -2,11 +2,13 @@ package com.jetbrains.performancePlugin.remotedriver.fixtures import com.intellij.driver.model.StringTable import com.jetbrains.performancePlugin.remotedriver.dataextractor.TextCellRendererReader +import com.jetbrains.performancePlugin.remotedriver.dataextractor.computeOnEdt import org.assertj.swing.core.Robot import org.assertj.swing.data.TableCell.row import org.assertj.swing.driver.BasicJTableCellReader import org.assertj.swing.driver.CellRendererReader import org.assertj.swing.fixture.JTableFixture +import java.awt.Component import java.awt.Dimension import javax.swing.JTable @@ -40,4 +42,11 @@ class JTableTextFixture(robot: Robot, component: JTable) : JTableFixture(robot, fun doubleClickCell(row: Int, column: Int) { cell(row(row).column(column)).doubleClick() } + + fun getComponentAt(row: Int, column: Int): Component { + return computeOnEdt { + val table = target() + table.prepareRenderer (table.getCellRenderer(row, column), row, column) + } + } } \ No newline at end of file diff --git a/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JTreeTextFixture.kt b/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JTreeTextFixture.kt index acc9e26c4774..07f1c97df8f9 100644 --- a/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JTreeTextFixture.kt +++ b/plugins/performanceTesting/remote-driver/src/com/jetbrains/performancePlugin/remotedriver/fixtures/JTreeTextFixture.kt @@ -10,6 +10,7 @@ import org.assertj.swing.core.Robot import org.assertj.swing.driver.BasicJTreeCellReader import org.assertj.swing.driver.CellRendererReader import org.assertj.swing.fixture.JTreeFixture +import java.awt.Component import java.awt.Point import javax.swing.JTree @@ -69,4 +70,17 @@ open class JTreeTextFixture(robot: Robot, private val component: JTree) : JTreeF TreeUtil.promiseExpandAll(component).blockingGet(timeoutMs) } } + + fun getComponentAtRow(row: Int): Component { + return computeOnEdt { + val tree = target() + tree.cellRenderer.getTreeCellRendererComponent(tree, + tree.getPathForRow(row).lastPathComponent, + tree.isRowSelected(row), + tree.isExpanded(row), + false, + row, + tree.hasFocus() && tree.isRowSelected(row)) + } + } } \ No newline at end of file