Skip to content

Commit

Permalink
[starter examples] Add example using driver
Browse files Browse the repository at this point in the history
GitOrigin-RevId: c128940d1a964caf15ac1703e04734825515bbcd
  • Loading branch information
MaXal authored and intellij-monorepo-bot committed Jun 19, 2024
1 parent 562b4c5 commit 48410a4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions intellij.tools.ide.starter.examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ dependencies {
testImplementation 'com.jetbrains.intellij.tools:ide-metrics-collector:LATEST-EAP-SNAPSHOT'
testImplementation 'com.jetbrains.intellij.tools:ide-metrics-collector-starter:LATEST-EAP-SNAPSHOT'
testImplementation 'com.jetbrains.intellij.tools:ide-performance-testing-commands:LATEST-EAP-SNAPSHOT'
testImplementation 'com.jetbrains.intellij.tools:ide-starter-driver:LATEST-EAP-SNAPSHOT'
testImplementation 'com.jetbrains.intellij.driver:driver-client:LATEST-EAP-SNAPSHOT'
testImplementation 'com.jetbrains.intellij.driver:driver-sdk:LATEST-EAP-SNAPSHOT'
testImplementation 'com.jetbrains.intellij.driver:driver-model:LATEST-EAP-SNAPSHOT'
testImplementation "org.kodein.di:kodein-di-jvm:7.20.2"

testImplementation 'junit:junit:4.13.2'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.intellij.ide.starter.examples.driver

import com.intellij.driver.sdk.singleProject
import com.intellij.driver.sdk.waitForIndicators
import com.intellij.driver.sdk.waitForProjectOpen
import com.intellij.ide.starter.driver.PlaybackRunnerService
import com.intellij.ide.starter.driver.engine.runIdeWithDriver
import com.intellij.ide.starter.examples.data.TestCases
import com.intellij.ide.starter.junit5.hyphenateWithClass
import com.intellij.ide.starter.runner.CurrentTestMethod
import com.intellij.ide.starter.runner.Starter
import com.intellij.ide.starter.driver.execute
import com.intellij.tools.ide.performanceTesting.commands.CommandChain
import com.intellij.tools.ide.performanceTesting.commands.exitApp
import org.junit.jupiter.api.Test
import kotlin.time.Duration.Companion.minutes

import com.intellij.driver.client.service
import com.intellij.driver.sdk.ProjectManager
import com.intellij.driver.sdk.getOpenProjects
import com.intellij.ide.starter.examples.driver.model.LafManager
import com.intellij.tools.ide.performanceTesting.commands.openFile
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue

class PerfTestWithDriver {
@Test
fun openGradleJitPack() {
val testContext = Starter
.newContext(CurrentTestMethod.hyphenateWithClass(), TestCases.IC.GradleJitPackSimple)
.prepareProjectCleanImport()

testContext.runIdeWithDriver().useDriverAndCloseIde{
waitForIndicators(5.minutes) // driver don't wait by default so we need to add waiter
execute(CommandChain().openFile("build.gradle")) //invocation of command via JMX call
assertEquals(1, getOpenProjects().size ) // JMX call using predefined interfaces
assertEquals(service<LafManager>().getCurrentUIThemeLookAndFeel().getName(), "Dark") //JMX call with custom interfaces
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.intellij.ide.starter.examples.driver.model

import com.intellij.driver.client.Remote

@Remote("com.intellij.ide.ui.LafManager")
interface LafManager {
fun getCurrentUIThemeLookAndFeel(): UiThemeLookAndFeelInfo
}
@Remote("com.intellij.ide.ui.laf.UIThemeLookAndFeelInfo")
interface UiThemeLookAndFeelInfo {
fun getName(): String
}

0 comments on commit 48410a4

Please sign in to comment.