mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[remote-driver] AT-2977 add UndoActionInDiffEditorUiTest
GitOrigin-RevId: 1620d246f8cc672d0d0e5d565aad40e806f527ec
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b47123c534
commit
53fd309632
@@ -1,18 +1,13 @@
|
||||
package com.intellij.driver.sdk.ui
|
||||
|
||||
import com.intellij.driver.client.Remote
|
||||
import com.intellij.driver.model.RemoteMouseButton
|
||||
import com.intellij.driver.sdk.jdk.getSystemProperty
|
||||
import com.intellij.driver.sdk.ui.components.UiComponent
|
||||
import java.awt.Point
|
||||
import java.awt.datatransfer.DataFlavor
|
||||
import java.awt.event.KeyEvent
|
||||
|
||||
fun UiRobot.pasteText(text: String) {
|
||||
driver.utility(ToolkitRef::class)
|
||||
.getDefaultToolkit()
|
||||
.getSystemClipboard()
|
||||
.setContents(driver.new(StringSelectionRef::class, text), null)
|
||||
driver.copyToClipboard(text)
|
||||
|
||||
keyboard {
|
||||
val keyEvent = if (driver.getSystemProperty("os.name").lowercase().startsWith("mac")) KeyEvent.VK_META else KeyEvent.VK_CONTROL
|
||||
@@ -20,11 +15,6 @@ fun UiRobot.pasteText(text: String) {
|
||||
}
|
||||
}
|
||||
|
||||
fun UiRobot.getClipboardText(): Object = driver.utility(ToolkitRef::class)
|
||||
.getDefaultToolkit()
|
||||
.getSystemClipboard()
|
||||
.getData(DataFlavor.stringFlavor)
|
||||
|
||||
fun UiRobot.dragAndDrop(start: Point, end: Point) {
|
||||
try {
|
||||
moveMouse(start)
|
||||
@@ -33,7 +23,8 @@ fun UiRobot.dragAndDrop(start: Point, end: Point) {
|
||||
Thread.sleep(500)
|
||||
moveMouse(end)
|
||||
Thread.sleep(500)
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
robot.releaseMouse(RemoteMouseButton.LEFT)
|
||||
}
|
||||
}
|
||||
@@ -41,21 +32,3 @@ fun UiRobot.dragAndDrop(start: Point, end: Point) {
|
||||
fun UiComponent.dragAndDrop(to: Point) {
|
||||
driver.ui.dragAndDrop(this.center, to)
|
||||
}
|
||||
|
||||
@Remote("java.awt.Toolkit")
|
||||
interface ToolkitRef {
|
||||
fun getDefaultToolkit(): ToolkitRef
|
||||
fun getSystemClipboard(): ClipboardRef
|
||||
}
|
||||
|
||||
@Remote("java.awt.datatransfer.Clipboard")
|
||||
interface ClipboardRef {
|
||||
fun setContents(content: StringSelectionRef, ownerRef: ClipboardOwnerRef?)
|
||||
fun getData(flavor: DataFlavor): Object
|
||||
}
|
||||
|
||||
@Remote("java.awt.datatransfer.ClipboardOwner")
|
||||
interface ClipboardOwnerRef
|
||||
|
||||
@Remote("java.awt.datatransfer.StringSelection")
|
||||
interface StringSelectionRef
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.driver.client.Remote
|
||||
import com.intellij.driver.client.impl.RefWrapper
|
||||
import com.intellij.driver.model.OnDispatcher
|
||||
import com.intellij.driver.sdk.Project
|
||||
import com.intellij.driver.sdk.invokeAction
|
||||
import com.intellij.driver.sdk.ui.components.UiComponent
|
||||
import com.intellij.driver.sdk.ui.remote.Component
|
||||
import com.intellij.driver.sdk.ui.remote.REMOTE_ROBOT_MODULE_ID
|
||||
@@ -12,6 +13,7 @@ import com.intellij.driver.sdk.waitFor
|
||||
import com.intellij.openapi.diagnostic.fileLogger
|
||||
import java.awt.Point
|
||||
import java.awt.Rectangle
|
||||
import java.awt.datatransfer.DataFlavor
|
||||
import kotlin.time.Duration
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@@ -25,6 +27,15 @@ fun Driver.requestFocusFromIde(project: Project?) {
|
||||
}
|
||||
}
|
||||
|
||||
fun Driver.copyToClipboard(text: String) {
|
||||
getSystemClipboard().setContents(new(StringSelectionRef::class, text), null)
|
||||
}
|
||||
|
||||
fun UiComponent.pasteText(text: String) {
|
||||
driver.copyToClipboard(text)
|
||||
driver.invokeAction($$"$Paste", component = component)
|
||||
}
|
||||
|
||||
@Remote(value = "com.intellij.ide.impl.ProjectUtil")
|
||||
interface ProjectUtil {
|
||||
fun focusProjectWindow(project: Project?, stealFocusIfAppInactive: Boolean)
|
||||
@@ -36,10 +47,11 @@ interface IdeEventQueue {
|
||||
fun flushQueue()
|
||||
}
|
||||
|
||||
val UiComponent.center: Point get() {
|
||||
val location = component.getLocationOnScreen()
|
||||
return Point(location.x + component.width / 2, location.y + component.height / 2)
|
||||
}
|
||||
val UiComponent.center: Point
|
||||
get() {
|
||||
val location = component.getLocationOnScreen()
|
||||
return Point(location.x + component.width / 2, location.y + component.height / 2)
|
||||
}
|
||||
|
||||
val UiComponent.boundsOnScreen
|
||||
get() = component.let { c ->
|
||||
@@ -88,8 +100,32 @@ fun printableString(toPrint: String): String {
|
||||
return resultString
|
||||
}
|
||||
|
||||
fun Driver.getClipboardText(): Any = getSystemClipboard().getData(DataFlavor.stringFlavor)
|
||||
|
||||
fun Driver.getSystemClipboard(): ClipboardRef = utility(ToolkitRef::class)
|
||||
.getDefaultToolkit()
|
||||
.getSystemClipboard()
|
||||
|
||||
@Remote("org.assertj.swing.driver.CellRendererReader")
|
||||
interface CellRendererReader
|
||||
|
||||
@Remote("com.jetbrains.performancePlugin.remotedriver.fixtures.AccessibleNameCellRendererReader", plugin = REMOTE_ROBOT_MODULE_ID)
|
||||
interface AccessibleNameCellRendererReader: CellRendererReader
|
||||
interface AccessibleNameCellRendererReader : CellRendererReader
|
||||
|
||||
@Remote("java.awt.Toolkit")
|
||||
interface ToolkitRef {
|
||||
fun getDefaultToolkit(): ToolkitRef
|
||||
fun getSystemClipboard(): ClipboardRef
|
||||
}
|
||||
|
||||
@Remote("java.awt.datatransfer.Clipboard")
|
||||
interface ClipboardRef {
|
||||
fun setContents(content: StringSelectionRef, ownerRef: ClipboardOwnerRef?)
|
||||
fun getData(flavor: DataFlavor): Any
|
||||
}
|
||||
|
||||
@Remote("java.awt.datatransfer.ClipboardOwner")
|
||||
interface ClipboardOwnerRef
|
||||
|
||||
@Remote("java.awt.datatransfer.StringSelection")
|
||||
interface StringSelectionRef
|
||||
|
||||
Reference in New Issue
Block a user